Hi guys, i'm working on an account update page and I'm getting some weird behaviors. When i submit click the submit button i get the error message :
Warning: Supplied argument is not a valid MySQL result resource in /var/www/html/editprofile2.php on line 65
But line 65 works on the first time i load the page. So why does it stop working when i submit?
Here is a snippet of the code i'm using.. I put a
// HERE IS LINE 65 on the line in question.
<center>
<table width=100% border=1 cellspacing=0 cellpadding=1 valign=top>
<form method=post action="<?php echo $PHP_SELF?>">
<?php
$UID=$_GET['UID'];
$Uname=$_GET['Uname'];
$PWD=$_GET['PWD'];
$EML=$_GET['EML'];
printf ("<tr><td bgcolor=darkgray><p>IM Number:</p></td><td align=center><p>$UID</p></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Username:</p></td><td align=center><p>$Uname</p></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Email:</p></td><td align=center><input type=Text name=email value=$EML></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>New Password:</p></td><td align=center><input type=Password name=password1 value=$PWD></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Confirm Password:</p></td><td align=center><input type=Password name=password2 value=$PWD></td></tr>");
// Connect to the database
$db = mysql_connect("localhost", "root");
mysql_select_db("basmentIM",$db);
// Select Current Info and Display an update form
$sql = "SELECT * FROM Profiles WHERE Account_ID=$UID";
$result = mysql_query($sql);
$number_results = mysql_num_rows($result); // HERE IS LINE 65
$myrow = mysql_fetch_row($result);
if ($number_results==0) {
printf ("<tr><td bgcolor=darkgray><p>Real Name:</p></td><td align=center><input type=Text name=realname></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Age:</p></td><td align=center><input type=Text name=age></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Location:</p></td><td align=center><input type=Text name=location></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Marital Status:</p></td><td align=center><SELECT Name=mstat><Option value=single>Single<Option value=married>Married<Option value=divorced>Divorced</SELECT></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>Homepage:</p></td><td align=center><input type=Text name=homepage></td></tr>");
printf ("<tr><td bgcolor=darkgray><p>About:</p></td><td align=center><textarea name=about rows=3 cols=40></textarea></td></tr>");
printf ("</table>");
} else {
printf ("<tr><td bgcolor=darkgray><p>Real Name:</p></td><td align=center><input type=Text name=realname value=%s></td></tr>", $myrow[1]);
printf ("<tr><td bgcolor=darkgray><p>Age:</p></td><td align=center><input type=Text name=age value=%s></td></tr>", $myrow[2]);
printf ("<tr><td bgcolor=darkgray><p>Location:</p></td><td align=center><input type=Text name=location value=%s></td></tr>", $myrow[3]);
printf ("<tr><td bgcolor=darkgray><p>Marital Status:</p></td><td align=center><SELECT Name=mstat value=%s><Option value=single>Single<Option value=married>Married<Option value=divorced>Divorced</SELECT></td></tr>", $myrow[4]);
printf ("<tr><td bgcolor=darkgray><p>Homepage:</p></td><td align=center><input type=Text name=homepage value=%s></td></tr>", $myrow[6]);
printf ("<tr><td bgcolor=darkgray><p>About:</p></td><td align=center><textarea name=about rows=8 cols=55>%s</textarea></td></tr>", htmlentities($myrow[5]));
printf ("</table>");
}
?>
<br><input type="Submit" name="submit" value="Update">
</form>
<?php
if ($submit) {
echo "$UID";
}
?>
</center>
any help you could give me would be greatly appreciated.