aim25 Posted June 21, 2008 Share Posted June 21, 2008 <?php $dbHost = 'localhost'; $dbUser = 'AIM25'; $dbName = 'dbuser'; $dbPass = '********'; $dbLink = mysql_connect($dbHost, $dbUser, $dbPass); if(!$dbLink) die("Could not connect to database. " . mysql_error()); mysql_select_db($dbName); $queryNameCheck = mysql_query("SELECT * FROM members WHERE userid = '$userName'", $dbLink); $intNamesInUse = mysql_num_rows($queryNameCheck); echo $intNamesInUse; ?> when i run that i get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource. not sure how to fix it but i think its $queryNameCheck. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/ Share on other sites More sharing options...
perezf Posted June 21, 2008 Share Posted June 21, 2008 Try it like this <?php $dbHost = 'localhost'; $dbUser = 'AIM25'; $dbName = 'dbuser'; $dbPass = '********'; $dbLink = mysql_connect($dbHost, $dbUser, $dbPass); if(!$dbLink) die("Could not connect to database. " . mysql_error()); mysql_select_db($dbName); $queryNameCheck = mysql_query("SELECT * FROM members WHERE userid = '$userName'"); $intNamesInUse = mysql_num_rows($queryNameCheck); echo $intNamesInUse; ?> Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570745 Share on other sites More sharing options...
Stephen Posted June 21, 2008 Share Posted June 21, 2008 There is no variable $userName. Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570746 Share on other sites More sharing options...
aim25 Posted June 21, 2008 Author Share Posted June 21, 2008 thank you for the replies, but no cake , still getting that error. can it just be my computer? Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570747 Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Holy. Crap. ANOTHER post where they don't add "or die(mysql_error());" to debug their queries. It highlights the problem for you! It's like a huge, neon sign with an arrow saying "HERE I AM". =/ $queryNameCheck = mysql_query("SELECT * FROM members WHERE userid = '$userName'") OR die(mysql_error()); ... Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570749 Share on other sites More sharing options...
.josh Posted June 21, 2008 Share Posted June 21, 2008 well if you're not getting your die message from your connect, then you must be connecting okay. Add a die to your select_db see if that gives you an error (spelled right? does it exist?) also add a die to your mysql_query it should tell you something helpful as well. Also, i don't see where $userName is actually being assigned anything, so you may be connecting proper and all but it's returning nothing, causing your num_rows to fail. Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570750 Share on other sites More sharing options...
aim25 Posted June 21, 2008 Author Share Posted June 21, 2008 WOW I HAVE BEEN CORRECTED BEYOND COMPARE. thank you alot, this is going to come in really useful. Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570751 Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 No problem. Hope you actually use it, unlike half the people who I tell that to, because 20 minutes later, they're back with a topic like "mysql_num_rows say i no has valid resorse" and a post like "how to fix?". Yeah. Quote Link to comment https://forums.phpfreaks.com/topic/111201-solved-mysql-help/#findComment-570755 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.