ryanschefke
04-13-2004, 06:56 PM
Can anyone help me here. I'm making two MySQL queries. The MySQL query in the middle works fine standalone (in red). However, when I add another MySQL query on top (in blue) I'm getting the error below when the query in the middle (in red) executes:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Apache\Apache2\html\tgwedding\TMPpcyr9w49u2.php on line 101
<?php
echo $login_ck;
////////// query the database for sticky form
require_once ("mysql_connect.php");
$query = "SELECT * FROM customers WHERE accountName='$login_ck'";
$result = @mysql_query($query); // run the query
if (mysql_num_rows($result) == 1) {
$row = mysql_fetch_array($result, MYSQL_ASSOC);//store this record as an array "row"
mysql_free_result($result);
echo $row['email'];
}
mysql_close(); // close the db connection
////////// end of query for sticky form
////// MAIN CONDITIONAL LOOP //////// begin checking for errors in the script
if (isset($save)) { //handle the form
require_once ("mysql_connect.php");
// connect to the db
....
....
....
....
..... more conditionals
///////////////////////////////////////////////////////////////////////////////////
if ($ap && $fn && $ln && $ad && $ci && $st && $co && $zi) { // if everything is filled out
$query = "SELECT * FROM customers WHERE accountName='$login_ck'";
$result = @mysql_query($query); // run the query
if (mysql_num_rows($result) == 1) { ////////////////////////////////this is where the problem is
$row = mysql_fetch_array($result, MYSQL_ASSOC);//store this record as an array "row"
echo "the 2nd query was successful";
// make the query
$query = "UPDATE customers SET accountPassword='$ap', firstName='$fn', lastName='$ln', address='$ad', city='$ci',
state='$st', country='$co', zipcode='$zi', sitePassword='$wp', personalInfoUpdated=NOW() WHERE customerID=$row[customerID]";
$result = @mysql_query ($query); // run the query
if (($result) AND (mysql_affected_rows() == 1)) { //if the query ran successfully
//do something here.
$message = '<p>Account Update Successfull</p>';
} else { //if it did not run okay
$message = "<p>You could not update your info due to a system error. We apologize for any inconvenience</p><p>" . mysql_error() . "</p>";
}
} else {
$message = '<p>That username is not registered with us. Please sign up.</p>';
}
mysql_close(); // close the db connection.
/////////////////////////////////////////////////////////////////////////////
} else {
$message .= "<p>Please try again</p><br>";
}
} // end of the main conditional loop
?>
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Apache\Apache2\html\tgwedding\TMPpcyr9w49u2.php on line 101
<?php
echo $login_ck;
////////// query the database for sticky form
require_once ("mysql_connect.php");
$query = "SELECT * FROM customers WHERE accountName='$login_ck'";
$result = @mysql_query($query); // run the query
if (mysql_num_rows($result) == 1) {
$row = mysql_fetch_array($result, MYSQL_ASSOC);//store this record as an array "row"
mysql_free_result($result);
echo $row['email'];
}
mysql_close(); // close the db connection
////////// end of query for sticky form
////// MAIN CONDITIONAL LOOP //////// begin checking for errors in the script
if (isset($save)) { //handle the form
require_once ("mysql_connect.php");
// connect to the db
....
....
....
....
..... more conditionals
///////////////////////////////////////////////////////////////////////////////////
if ($ap && $fn && $ln && $ad && $ci && $st && $co && $zi) { // if everything is filled out
$query = "SELECT * FROM customers WHERE accountName='$login_ck'";
$result = @mysql_query($query); // run the query
if (mysql_num_rows($result) == 1) { ////////////////////////////////this is where the problem is
$row = mysql_fetch_array($result, MYSQL_ASSOC);//store this record as an array "row"
echo "the 2nd query was successful";
// make the query
$query = "UPDATE customers SET accountPassword='$ap', firstName='$fn', lastName='$ln', address='$ad', city='$ci',
state='$st', country='$co', zipcode='$zi', sitePassword='$wp', personalInfoUpdated=NOW() WHERE customerID=$row[customerID]";
$result = @mysql_query ($query); // run the query
if (($result) AND (mysql_affected_rows() == 1)) { //if the query ran successfully
//do something here.
$message = '<p>Account Update Successfull</p>';
} else { //if it did not run okay
$message = "<p>You could not update your info due to a system error. We apologize for any inconvenience</p><p>" . mysql_error() . "</p>";
}
} else {
$message = '<p>That username is not registered with us. Please sign up.</p>';
}
mysql_close(); // close the db connection.
/////////////////////////////////////////////////////////////////////////////
} else {
$message .= "<p>Please try again</p><br>";
}
} // end of the main conditional loop
?>