Jump to content

supplied argument is not a valid MySQL result resource


slj90

Recommended Posts

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

 

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.