|
|
|
|
![]() ![]() |
Dec 22 2007, 12:27 AM
Post
#11
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 34 Joined: 10-December 07 From: Norway Member No.: 54,556 |
the query update looks ok to me. The only reasons it wont update is if there is no record to update, If there is error because of wrong field names etc the error should return. I would check and make sure $username is assigned when used in your query, and check your database it self. say if you want to update user 'bob' check if 'bob' exist in users and 'bob' is assigned properly to $username before doing query, maybe output it just to test on the screen. I cant think of any other reasons why it will not work if its not givng back any errors. Also try to remember to assign your variables before attempting to use it. It wont work if you try and use $username and you actually assign it futher down the code because it will be blank when you are calling it before. well i replaced $username with my username... coldasice... as in db.. and it still wouldnt work well all i can say is that update dosnt work QUOTE <?php session_start(); include "database.php"; include "edit.inc.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: main.php"); } $username = $_SESSION["username"]; if(isset($_POST['submit'])){ $email2 = $_POST['email']; $msn2 = $_POST['msn']; $info2 = $_POST['info']; $updateemail = "UPDATE users SET email = '$email2', msn = '$msn2', info = '$info2' WHERE username = '$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated"; } echo "$username"; echo "$email"; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $all = mysql_fetch_array($query); $email = $all['email']; $msn = $all['msn']; $info = $all['info']; echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> </tr> "; echo " </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table> "; echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>"; ?> this is my current code yes phpmyadmin.. is what i use evry time i press submit.. well.. i go pms.. and insert email = asdasdasd info = asdasdasdasdasdasdasdasdasdasdasdasdasdasdasdasdsadasdasda and then i go to edit.php.. and all is there.. then i press submit... boom.. all emty.. it emptyes.. my damn row where the user name is inserted................... now my guess is that its somthing wrong with update This post has been edited by coldasice: Dec 22 2007, 12:44 AM |
|
|
|
Dec 22 2007, 01:18 AM
Post
#12
|
|
|
A computer once beat me at chess, but it was no match for me at kick boxing. ![]() Group: [MODERATOR] Posts: 4,071 Joined: 24-July 05 From: Linix, DOS and Windows…the good, the bad and the ugly Member No.: 9,787 ![]() |
CODE $username = $_SESSION["username"]; have you tried single quotes here? Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting. And does the select work correctly in phpmyadmin? |
|
|
|
Dec 22 2007, 01:20 AM
Post
#13
|
|
|
|||[ n00b King ]||| ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: [HOSTED] Posts: 685 Joined: 20-June 07 From: Auckland Member No.: 45,102 |
i need some bigger glasses
CODE <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=username value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=password value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name=\"'info'\" id=\"'info'\">$info</textarea></td> change the name='' to the corret names CODE <td width='160'><input tabindex=1 type=text name='email' value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name='msn' value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows=\"10\" cols=\"45\" name='info' >$info</textarea></td> man this is what happens when you ignore the obvious This post has been edited by sonesay: Dec 22 2007, 01:23 AM |
|
|
|
Dec 22 2007, 01:27 AM
Post
#14
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 34 Joined: 10-December 07 From: Norway Member No.: 54,556 |
CODE $username = $_SESSION["username"]; have you tried single quotes here? Basic debugging would suggest that you display (print) the data in the query before and after the query, along with the results of the query after the select. This will confirm the values the query is using, and the results it is getting. And does the select work correctly in phpmyadmin? thanks for ur respons.. but.. lol ;O that dont help =D and yeah.. its a part of a learning login.. so basicly my username is in the session and its solved here is code =D and thank to you sonesay. for helping me =D this happende bcouse i made the thig from scratch.. but..... i got some kind of error.. but i dont remember what error it was... so i found some boxes on net.. and copyed source and edited it to fit what i wanted.. and just so you know be4 u posted.. i solved this.. i got fed up.. and saw trough code. and saw it.. CODE <?php session_start(); include "database.php"; if (!$_SESSION["valid_user"]) { // User not logged in, redirect to login page Header("Location: main.php"); } $username = $_SESSION["username"]; if(isset($_POST['submit'])){ $email2 = $_POST['email']; $msn2 = $_POST['msn']; $info2 = $_POST['info']; $updateemail = "UPDATE users SET email='$email2', msn='$msn2', info='$info2' WHERE username='$username'"; mysql_query($updateemail) or die("culd not edit your info"); echo "info updated"; } $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $all = mysql_fetch_array($query); $email = $all['email']; $msn = $all['msn']; $info = $all['info']; echo " <table width=\"100%\" border=0 cellpadding=1 cellspacing=0> <form name=login action='$PHP_SELF' method=post> <tr> <td width=80>Email: </td> <td width='160'><input tabindex=1 type=text name=email value='$email' style='width:150;'></td> </tr> <tr> <td>MSN: </td> <td><input type=text name=msn value='$msn' style='width:150'></td> </tr> <tr> <td>Info: </td> <td><textarea rows='10' cols='45' name='info' id='info'>$info</textarea></td> </tr> </tr> <tr> <td> <td colspan=\"3\"> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td width=50%> <input type=\"submit\" name=\"submit\" id=\"submit\" value=\"submit\" /> </form> </table>"; echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>"; ?> [SOLVED] This post has been edited by coldasice: Dec 22 2007, 01:46 AM |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 11th October 2008 - 07:16 AM |