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

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.