Portal Home > Knowledgebase > Articles Database > PHP & mySQL question
PHP & mySQL question
Posted by dhui, 08-10-2008, 01:42 PM |
Can anyone tell me why I get nothing when I echo "$num_result"? I copy and pasted the SELECT statement I have here into phpMyAdmin's query analyzer and it comes up with the result I want, but for some reason I can't get it to work in my PHP.
$sql = "SELECT * FROM USERPROFILE WHERE login = 'test'";
$result = mysql_query($sql);
$num_result = mysql_num_rows($result);
echo $num_result;
|
Posted by etogre, 08-10-2008, 04:33 PM |
I'm not sure why you'd have problems with that code, it is completely correct (assuming you have a successful db connection and the table name / login field are present).
|
Posted by Xlusive, 08-10-2008, 04:46 PM |
try
|
Posted by Eiolon, 08-10-2008, 04:48 PM |
Do you have the same problem if you make the echo statement separate from your query?
|
Posted by sc_freak, 08-10-2008, 05:17 PM |
write:
$result = mysql_query($sql) or die(mysql_error());
so we know if there's anything wrong with your query
|
Posted by dhui, 08-10-2008, 09:16 PM |
I figured it out, thanks for everyone's help
|
Posted by juangake, 08-11-2008, 06:38 AM |
So what was the problem? So this thread can become useful for somebody? Please?
|
Posted by Chris Drew, 08-11-2008, 07:38 AM |
I reccomend you checking out mysql_fetch_assoc(),
it gives the array relavent names
|
Posted by JustinNoel, 08-11-2008, 11:02 AM |
can be some port error/problem which was actually out of the coding issues.
|
Add to Favourites Print this Article
Also Read