Alex2k15 Posted August 6, 2015 Share Posted August 6, 2015 Yeah idk what's wrong and i want some help. Let's start with edit.php <?php session_start(); include_once 'dbconnect.php'; if(!isset($_SESSION['user'])) { header("Location: index.php"); } $res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']); $userRow=mysql_fetch_array($res); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Home - <?php echo $userRow['username']; ?></title> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <div id="header"> <div id="left"> <label>Chillz</label> </div> <div id="right"> <div id="content"> Welcome, <?php echo $userRow['username']; ?> <a href="logout.php?logout">Sign Out</a> </div> </div> </div> <div id="body"> <b>Edit your Profile</b> <br><br> Please enter your details below to update your profile. <br><br> <form method="post" action="editprofile.php" name="editform" id="editform"> <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0> <b>Required Information:</b><br><br> <tr><td> <b>Username:</b> </td><td> <?php echo $username; ?> </td></tr><tr><td> <b>Email Address:</b> </td><td> <input type="text" name="email" id="email" value="<?php echo $email; ?>"> </td></tr></table></td><td valign=top> <table border=0> <b>Optional Information:</b><br><br> <tr><td> <b>Location:</b> </td><td> <input type="text" name="location" id="location" value="<?php echo $location; ?>"> </td></tr><tr><td> <b>Your Website:</b> </td><td> <input type="text" name="website" id="website" value="<?php echo $website; ?>"> </tr></td><tr><td valign=top> <b>Short About:</b> </td><td> <textarea name="about" id="about" rows="10" cols="20"><?php echo $about; ?></textarea> </td></tr></td> </table> </td></tr> </table> <input type="submit" name="register" id="register" value="Update" class=btn /> </form> </div> <?php $editquery = mysql_query("Update users (email, location, website, about) VALUES('".$email."', '".$location."', '".$website."', '".$about."')"); if($editquery ==) { echo "<b>Success!</b>"; echo "Your profile was successfully updated. Please click<a href=\"viewprofile.php\"> here </a>to view."; } else { echo "<b>Error</b>"; echo "<p>Sorry, your profile update failed. Please go back and try again.</p>"; } ?> </div> </body> </html> I can't upload an image but here is the urls: http://i.imgur.com/ZkHMM4a.jpg http://i.imgur.com/HsAhfiM.jpg I want to remove the error part. Plus i was hoping someone can help me work on the profile part Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/ Share on other sites More sharing options...
NomadicJosh Posted August 6, 2015 Share Posted August 6, 2015 You are using INSERT syntax instead of UPDATE syntax. Your UPDATE query should follow this syntax: UPDATE table_name SET field1=new-value1, field2=new-value2 WHERE field = value; Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518182 Share on other sites More sharing options...
Alex2k15 Posted August 7, 2015 Author Share Posted August 7, 2015 You are using INSERT syntax instead of UPDATE syntax. Your UPDATE query should follow this syntax: UPDATE table_name SET field1=new-value1, field2=new-value2 WHERE field = value; It does say update Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518185 Share on other sites More sharing options...
scootstah Posted August 7, 2015 Share Posted August 7, 2015 Yes but it's using the INSERT syntax, not UPDATE syntax. Look at his example compared to your code. Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518187 Share on other sites More sharing options...
Alex2k15 Posted August 7, 2015 Author Share Posted August 7, 2015 so pretty much like this $editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id=._SESSION['user']); Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518231 Share on other sites More sharing options...
NomadicJosh Posted August 8, 2015 Share Posted August 8, 2015 Yes, that is the correct syntax, but in your example, you're missing the closing quotation, so you have to be careful of that. Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518234 Share on other sites More sharing options...
Alex2k15 Posted August 8, 2015 Author Share Posted August 8, 2015 Yes, that is the correct syntax, but in your example, you're missing the closing quotation, so you have to be careful of that. This is how it looks: <?php session_start(); include_once 'dbconnect.php'; if(!isset($_SESSION['user'])) { header("Location: index.php"); } $res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']); $userRow=mysql_fetch_array($res); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Home - <?php echo $userRow['username']; ?></title> <link rel="stylesheet" href="css/style.css" type="text/css" /> </head> <body> <div id="header"> <div id="left"> <label>Chillz</label> </div> <div id="right"> <div id="content"> Welcome, <?php echo $userRow['username']; ?> <a href="logout.php?logout">Sign Out</a> </div> </div> </div> <div id="body"> <b>Edit your Profile</b> <br><br> Please enter your details below to update your profile. <br><br> <form method="post" action="editprofile.php" name="editform" id="editform"> <table width=700px border=0 cellspacing=10><tr><td valign=top><table border=0> <b>Required Information:</b><br><br> <tr><td> <b>Username:</b> </td><td> <?php echo $username; ?> </td></tr><tr><td> <b>Email Address:</b> </td><td> <input type="text" name="email" id="email" value="<?php echo $email; ?>"> </td></tr></table></td><td valign=top> <table border=0> <b>Optional Information:</b><br><br> <tr><td> <b>Location:</b> </td><td> <input type="text" name="location" id="location" value="<?php echo $location; ?>"> </td></tr><tr><td> <b>Your Website:</b> </td><td> <input type="text" name="website" id="website" value="<?php echo $website; ?>"> </tr></td><tr><td valign=top> <b>Short About:</b> </td><td> <textarea name="about" id="about" rows="10" cols="20"><?php echo $about; ?></textarea> </td></tr></td> </table> </td></tr> </table> <input type="submit" name="register" id="register" value="Update" class=btn /> </form> <?php $editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id=._$SESSION['user']); if($editquery) { echo "<b>Success!</b>"; echo "Your profile was successfully updated. Please click<a href=\"profile.php\"> here </a>to view."; } else { echo "<b>Error</b>"; echo "<p>Sorry, your profile update failed. Please go back and try again.</p>"; } ?> </div> </body> </html> i feel like i did the WHERE part wrong. Plus i get this error. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/u890091543/public_html/login/edit.php on line 68 Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518236 Share on other sites More sharing options...
NomadicJosh Posted August 8, 2015 Share Posted August 8, 2015 Just like I said, you are missing the ending quotation at the end of the where clause. It should look something like this: <?php $editquery = mysql_query("UPDATE users SET email=$email, password=$password, location=$location, picture=$picture, website=$website, about=$about WHERE user_id='" ._$SESSION['user'] . "'"); ?> Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518237 Share on other sites More sharing options...
Alex2k15 Posted August 8, 2015 Author Share Posted August 8, 2015 http://i.imgur.com/rkCyozv.jpg Look at the botom part. That is suppose to show only after i edit the profile. Can we fix that? Link to comment https://forums.phpfreaks.com/topic/297671-php-profile-help/#findComment-1518309 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.