DeepakJ Posted July 27, 2007 Share Posted July 27, 2007 The error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\verification.php on line 28 The code: <html><head><title>AlibreCam Verification System</title></head> <center><h3>AlibreCam Verification System</h3></center> <center><TABLE border=0 cellpadding=3><form name="input" action="verification.php" method="get"> <tr><td><center>Customer ID:</center></td> <td><input type="text" name="user"></td></tr> <tr><td colspan=2><center><input type="submit" value="Submit"></center></td></tr> </form><br></table><br> <?php $hostname = "localhost"; $username = "root"; $password = "98989lol"; $dbname = "licensinginformation"; $value=0; $customer = $_GET['user']; mysql_connect($hostname, $username, $password) or DIE("Unable to connect to MySQL server $hostname"); $selected = mysql_select_db($dbname) or DIE("Could not select requested db $dbname"); $query= sprintf("SELECT * FROM invoiceid WHERE customerid=%s",$customer); //$query= "SELECT * FROM invoiceid WHERE //customerid==".$customer.""; $query= mysql_real_escape_string($query); $cResult= mysql_query($query); while($row=mysql_fetch_array($cResult)){ $value=$value+$row['numoflicenses']; } echo "Total number of licenses purchased: ".$value; ?> </html> Help would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/ Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 change your query to be something like: $query= "SELECT * FROM invoiceid WHERE customerid=$customer"; Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308956 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Doesn't work Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308966 Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 k...try this: $query= "SELECT * FROM invoiceid WHERE customerid=$customer"; remove this line: $query= mysql_real_escape_string($query); $cResult= mysql_query($query); Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308971 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Doesn't work Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308975 Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 What happens when you try it? What error messages, etc? Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308977 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 The error message stated in post. Apparently my query didn't go through or something. Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-308992 Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 k...try this: do not use the sprintf stuff. single quote $customer, double quote entire select statement. $query = "SELECT * FROM invoiceid WHERE customerid='$customer'"; remove this line: $query= mysql_real_escape_string($query); $cResult = mysql_query($query) or die ("<p>Cannot select from invoiceid: query = " . $query . " mysql_error = " . mysql_error() . "</p>); This will give you more of an error message. copy, paste and post the results please. Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309002 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Same exact error message Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309014 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 Cannot select from invoiceid: query = SELECT * FROM invoiceid WHERE customerid= mysql_error = You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 New error message ^ Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309027 Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 There is not value for $customer. Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309028 Share on other sites More sharing options...
DeepakJ Posted July 27, 2007 Author Share Posted July 27, 2007 YOU FIXED IT DUDE I LOVE YOU ::D:D:D:::D Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309029 Share on other sites More sharing options...
dbair Posted July 27, 2007 Share Posted July 27, 2007 Welcome! Link to comment https://forums.phpfreaks.com/topic/62052-solved-error-warning-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-resu/#findComment-309040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.