aeboi80 Posted April 9, 2010 Share Posted April 9, 2010 I have a basic form. User inputs their email address and hits submit. <form method="post" action="resend3.php" name="getemail"> <label>Email Address</label><input name="emailaddress" size="50" maxlength="100" /><br /> <input type="submit" name="submit" value="Resend »" /> <input type="hidden" name="getemail" /> </form> When the I enter an email address which IS in the database I keep getting the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/buzzwah/public_html/resend3.php on line 18 Here is the contents of the file resend3.php which the form is submitting to: $link=mysql_connect($DBHOST, $DBUSER, $DBPASSWORD); mysql_select_db($DBNAME, $link); $emailaddress = $_POST["emailaddress"]; echo "this is email".$emailaddress; $query = "SELECT USERID FROM members WHERE email =$emailaddress"; $result = mysql_query($query); while ($name_row = mysql_fetch_row($result)) { echo $name_row[0]; } As you can see I am setting the $_Post variable of email address = $emailaddress and that actually prints out to the screen. I am not sure what is causing the mysql error. Thanks Link to comment https://forums.phpfreaks.com/topic/198152-variable-posts-on-submit-but-kee-getting-a-warning/ Share on other sites More sharing options...
Ken2k7 Posted April 9, 2010 Share Posted April 9, 2010 Added quotes. $query = "SELECT USERID FROM members WHERE email = '$emailaddress'"; But please read up on mysql_real_escape_string to secure your input and prevent SQL injections. Link to comment https://forums.phpfreaks.com/topic/198152-variable-posts-on-submit-but-kee-getting-a-warning/#findComment-1039683 Share on other sites More sharing options...
aeboi80 Posted April 9, 2010 Author Share Posted April 9, 2010 Thank you and I will I am merely trying to learn this and appreciate the assitance of a noobie Link to comment https://forums.phpfreaks.com/topic/198152-variable-posts-on-submit-but-kee-getting-a-warning/#findComment-1039686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.