Twister1004 Posted October 27, 2008 Share Posted October 27, 2008 ooh geese, this is rediclious. I am getting problems like crazy D=. anyone wish to help me? Objective: Don't know why but I'm getting the error with $sql = ('UPDATE `account` WHERE (age, email, dob) VALUES ("'.$age.'", "'.$email.'", "'.$dob.'")'); $result = mysql_query($sql); if($result){ echo "Part one was successfully completed"; } else{ echo "There was an error with some information. Please contact an Admin.1"; exit();a } and $sql2 = ('UPDATE `profile` WHERE (looking, sexual, status, life) VALUES ("'.$looking.'", "'.$going.'", "'.$status.'", "'.$life.'")'); $result2 = mysql_query($sql2); if($result2){ echo "Part one was successfully completed"; } else{ echo "There was an error with some information. Please contact an Admin.2"; exit(); } <?php session_start(); error_reporting(E_ALL); require("login.php"); // DO NOT USE THIS PAGE!!!!!!?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>iMatch | Edit You</title> <style> #Banner { position:absolute; left:0px; top:0px; width:960px; height:119px; z-index:2; background-color: #FF00FF; } </style> </head> <body> <?php if(!isset($_SESSION['login_id'])) { die('You can not view this page unless you are logged in'); } ?> <div id="Banner"><img src="images/bannertest1.jpg" alt="iMatch!" width="960" height="119" /></div> <?php $sql = mysql_query("SELECT about FROM `profile` WHERE `accountid` = '{$_SESSION['login_id']}'"); /*$sql2 = mysql_query("SELECT ");*/ $result = mysql_fetch_row($sql); ?> <div style="position:absolute; top:150px; left:139px;"> Edit your profile information:<br /> <form METHOD="POST" ACTION=""> <table width="396" border="1" cellspacing="1" cellpadding="2"> <tr> <td><center>Your Age:</center></td> <td><center><input type="text" name="age" maxlength="2" ></center></td> </tr> <tr> <td><center>E-mail:<br/> Please do not fake your E-mail</center></td> <td><center><input type="text" name="email" maxlength="30" ></center></td> </tr> <tr> <td><center>Date of Birth:<br/>YYYY-MM-DD</center></td> <td><center><input type="text" name="dob" value="YYYY-MM-DD"maxlength="10" ></center></td> </tr> <tr> <td><center>Second or Real Life?</center></td> <td><center> <select name="life"> <option value="Real">Real Life</option> <option value="Second" selected="selected">Second Life</option> </select> </center></td> </tr> <tr> <td><center>Looking for:</center></td> <td><center> <select name="looking"> <option value="Friends" selected="selected">Friends</option> <option value="Men">Male</option> <option value="Women">Female</option> </select> </center></td> </tr> <tr> <td><center>Sexuality:</center></td> <td><center> <select name="going"> <option value="Straight">Straight</option> <option value="Gay">Gay</option> <option value="Bi">Bi</option> </select> </center></td> </tr> <tr> <td><center>Status:</center></td> <td><center> <select name="status"> <option value="unknown">Not Telling</option> <option value="Single">Single</option> <option value="Married">Married</option> </select> </center></td> </tr> </table> <input name="submit" type="submit" id="submit" value="Submit" /><br/> <?php if(!isset($_POST['submit'])){ // echo "Sorry, your information could not be completed at this time. Please contact an Admin."; } else{ isset($_SESSION['login_user']); $age = mysql_real_escape_string($_POST['age']); $email = mysql_real_escape_string($_POST['email']); $dob = mysql_real_escape_string($_POST['dob']); $status = mysql_real_escape_string($_POST['status']); $going = mysql_real_escape_string($_POST['going']); $looking = mysql_real_escape_string($_POST['looking']); $life = mysql_real_escape_string($_POST['life']); if($age == ""){ echo "Please put in your age."; exit(); } if($email == ""){ echo "Please enter your E-mail. Please also do not put in a fake E-mail!"; exit(); } if($dob == ""){ echo "Please enter your birth day by the following, YYYY-MM-DD."; exit(); } $sql = ('UPDATE `account` WHERE (age, email, dob) VALUES ("'.$age.'", "'.$email.'", "'.$dob.'")'); $result = mysql_query($sql); if($result){ echo "Part one was successfully completed"; } else{ echo "There was an error with some information. Please contact an Admin.1"; exit();a } $sql2 = ('UPDATE `profile` WHERE (looking, sexual, status, life) VALUES ("'.$looking.'", "'.$going.'", "'.$status.'", "'.$life.'")'); $result2 = mysql_query($sql2); if($result2){ echo "Part one was successfully completed"; } else{ echo "There was an error with some information. Please contact an Admin.2"; exit(); } echo "Your information was altered successfully!"; } ?> </form> </div> </body> </html> The problem is with the SQL statements. I can't really figure it out O_o. Thanks for any hints tips reading or helping =) Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/ Share on other sites More sharing options...
Jeremysr Posted October 27, 2008 Share Posted October 27, 2008 Your UPDATE queries should look like this: UPDATE `account` SET age = "'.$age.'", email = "'.$email.'", dob = "'.$dob.'" This will update ALL rows in the table to those values, however, so you might want to add a WHERE clause to only update one row. Something like: UPDATE `account` SET age = "'.$age.'", email = "'.$email.'", dob = "'.$dob.'" WHERE user_id = "'.$user_id.'"' Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675275 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 So your saying the statements need to be like this? <?php $sql = mysql_query("UPDATE `account` SET age = "'.$age.'", email = "'.$email.'", dob = "'.$dob.'" WHERE `accountid` = {$_SESSION['login_id']}"); ?> Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675282 Share on other sites More sharing options...
AndyB Posted October 27, 2008 Share Posted October 27, 2008 You'll find spending a few minutes at http://www.tizag.com/mysqlTutorial/ will solve a lot of future problems for you. Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675285 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 I already know how to work with the database. I just forgot about the function of UPDATE. Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675291 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 Lol, I'm stuck here <?php $sql = mysql_query('UPDATE `account` SET `age` = '$age', `email` = '$email', `dob` = '$dob' WHERE `accountid` = $_SESSION['login_id']'); ?> Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675298 Share on other sites More sharing options...
corbin Posted October 27, 2008 Share Posted October 27, 2008 Variables don't parse inside of single quotes. Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675299 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 I have no idea what I just did, but now it actually fixed and loaded the page. Now I'm getting like 50 errors on the page X_X Notice: Undefined index: age in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 96 Notice: Undefined index: email in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 97 Notice: Undefined index: dob in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 98 Notice: Undefined index: status in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 99 Notice: Undefined index: going in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 100 Notice: Undefined index: looking in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 101 Notice: Undefined index: life in C:\Documents and Settings\Compaq_Owner\Desktop\Server Files\Web Server\xampp\htdocs\dreamweaver sites\iMatch\edit_info.php on line 102 Please put in your age. Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675301 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 Omg I'm getting close. I fixed those btw ^_~ Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675317 Share on other sites More sharing options...
Twister1004 Posted October 27, 2008 Author Share Posted October 27, 2008 Yay I fixed it. Thanks to Jeremysr, for a code and the other for a website, plus extra help =D Link to comment https://forums.phpfreaks.com/topic/130209-solved-lol-help-with-syntax-d/#findComment-675320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.