Jump to content

[SOLVED] Lol help with syntax? =D


Twister1004

Recommended Posts

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

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.'"'

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.

Archived

This topic is now archived and is closed to further replies.

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