Re: Why this doesn't work ?

From: Date: Mon, 24 Oct 2005 17:49:13 +0000
Subject: Re: Why this doesn't work ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-224568@lists.php.net to get a copy of this message
hi mario, first of all, make sure that your query works from the mysql console or phpmyadmin or some other tool (copy-paste the query from the code and replace $loging with something reasonable). then try the following: $query = "SELECT COUNT (login) FROM formacao WHERE login = '$login'"; // check to see if the $login variable has been filled in - // maybe $login is empty? echo $query; $result = mysql_query($query); if (!$result) { // mysql will tell you what's wrong echo mysql_error(); } mysql_fetch_row($result); and btw. mysql_fetch_row() doesn't require a connection resource, it will default to the last opened when none is given. so you only need to give the 2nd parameter if you have more than one mysql-db connection open. regards, phillip --- Mário Gamito schrieb: > Hi, > > Why this doesn't work ? > > --- > $query = "SELECT COUNT (login) FROM WHERE login = '$login'"; > $result = mysql_query($query); > mysql_fetch_row($result); > --- > > It gives me > Warning: mysql_fetch_row(): supplied argument is not a valid MySQL > result resource in /var/www/html/registar_action.php on line 22 > > Any help would be apreciated. > > Warm Regards, > Mário Gamito

« previous php.general (#224568) next »