Welcome Guest ( Log In | Register)



2 Pages V  < 1 2  
Reply to this topicStart new topic
> [mysql/php]need Som Basic Help
coldasice
post 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



QUOTE(sonesay @ Dec 22 2007, 01:20 AM) *
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 sad.gif

well all i can say is that update dosnt work sad.gif


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 sad.gif

This post has been edited by coldasice: Dec 22 2007, 12:44 AM
Go to the top of the page
 
+Quote Post
jlhaslip
post 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 Icon

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
Spam Patrol



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?
Go to the top of the page
 
+Quote Post
sonesay
post 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 biggrin.gif

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
Go to the top of the page
 
+Quote Post
coldasice
post 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



QUOTE(jlhaslip @ Dec 22 2007, 02:18 AM) *
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 wink.gif thanks for trying wink.gif

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.. wink.gif

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
Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Problem On Mysql "order By"(5)
  2. Php News Script(19)
  3. Increment A Mysql Column(7)
  4. Can You Add Images Into A Mysql Database?(20)
  5. Subquery In Mysql(5)
  6. Creating Profiles In Php/mysql ?(7)
  7. Php Search Engine Script For Mysql Database(11)
  8. Editing Information In A Mysql Database And Deleting Rows(5)
  9. Putting Data Of 2 Pages In Mysql At Once(1)
  10. Mysql Query(2)
  11. Simple Mysql Query Limiting(9)
  12. Some Mysql Basics(4)
  13. Php, Mysql, Apache(4)
  14. Php And Mysql Applications(3)
  15. Getting Php 5 To Work With Mysql(0)
  1. Problem With A Mysql Join(2)
  2. The Artists Tutorials :mysql Basic Commands(0)
  3. [mysql]get Id Of Loged In User?(7)
  4. [php/mysql]id Trouble [resolved](3)
  5. Mysql Won't Update(4)
  6. Php + Mysql Question!(4)
  7. Tools Needed!(9)
  8. Best Sites For Learning Php-mysql(4)
  9. Php And Mysql Programming(2)
  10. Best Php And Mysql Editor For Noobs(6)
  11. Html Form!(4)
  12. Mysql Error(3)
  13. Create Table - Mysql Code - Help(1)


 



- Lo-Fi Version Time is now: 11th October 2008 - 07:16 AM