slj90 Posted January 17, 2010 Share Posted January 17, 2010 Whats wrong with my script? Error I get is... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /userReceipt.php on line 15 <?php include ("connection.php"); // (2)gather details of CustomerID sent $customerId = $_GET['CustomerID'] ; // (3)create query $query = "SELECT * FROM customer WHERE CustomerID = $customerId"; // (4) Run the query on the customer table through the connection $result = mysql_query ($query); // (5) print message with ID of inserted record if ($row = mysql_fetch_array($result)) { print "The following Customer was added"; print "<br>Customer ID: " . $row["CustomerID"]; print "<br>First Name: " . $row["Firstname"]; print "<br>Surname: " . $row["Surname"]; print "<br>User Name: " . $row["Username"]; print "<br>Email: " . $row["Email"]; print "<br>Password: " . $row["Password"]; print "<br>Address: " . $row["Address"]; print "<br>PostCode: " . $row["PostCode"]; print "<br>City: " . $row["City"]; print "<br>Country: " . $row["Country"]; } ?> Line 15 is.. if ($row = mysql_fetch_array($result)) Thanks Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
Buddski Posted January 17, 2010 Share Posted January 17, 2010 $result = mysql_query($query) or trigger_error(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-996551 Share on other sites More sharing options...
slj90 Posted January 17, 2010 Author Share Posted January 17, 2010 What do you mean? Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-996557 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 He means change: // (4) Run the query on the customer table through the connection $result = mysql_query ($query); To: // (4) Run the query on the customer table through the connection $result = mysql_query($query) or trigger_error(mysql_error()); This will display any errors if the query was made incorrectly. EDIT: And do you mean a while instead of an IF loop? It shouldn't be an IF. Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-996561 Share on other sites More sharing options...
slj90 Posted January 17, 2010 Author Share Posted January 17, 2010 Thank you, it displayed an error telling me the table didnt exsist. I hadn't used a capital letter in the code ! Thank you! Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-996564 Share on other sites More sharing options...
oni-kun Posted January 17, 2010 Share Posted January 17, 2010 Thank you, it displayed an error telling me the table didnt exsist. I hadn't used a capital letter in the code ! Thank you! No problem! Link to comment https://forums.phpfreaks.com/topic/188768-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-996565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.