Nov 21, 2009
Pages: 1, 2

[mysql/php]need Som Basic Help

free web hosting

Read Latest Entries..: (Post #13) by coldasice on Dec 22 2007, 01:27 AM.
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.....
read more.
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > MODERATED AREA > Computers > Programming Languages > PHP Programming

[mysql/php]need Som Basic Help

coldasice
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");
}
if(isset($_POST['submit'])){

$email = $_POST['email'];
$msn = $_POST['msn'];
$info = $_POST['info'];

$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'
WHERE username = '$username'";

mysql_query($updateemail) or die("culd not edit your info");

echo "info updated";
}
// Display logout link
echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";

echo "$email";
echo "$msn";
echo "$info";

$username = $_SESSION["username"];

$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>
";
?

 

 

 


Comment/Reply (w/o sign-up)

sonesay
try moving $username above before your update query like this

CODE
$username = $_SESSION["username"];

$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'
WHERE username = '$username'";

Comment/Reply (w/o sign-up)

coldasice
QUOTE(sonesay @ Dec 22 2007, 12:27 AM) *
try moving $username above before your update query like this

CODE
$username = $_SESSION["username"];

$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'
WHERE username = '$username'";



this just delete the whole row in my user name sad.gif so all go blank sad.gif

Comment/Reply (w/o sign-up)

sonesay
QUOTE(coldasice @ Dec 22 2007, 12:34 PM) *
this just delete the whole row in my user name sad.gif so all go blank sad.gif



post your other code too

include "database.php";
include "edit.inc.php";

and also include your database table layout

Comment/Reply (w/o sign-up)

coldasice
CODE
<?

/**
* Connect to the mysql database.
*/
$conn = mysql_connect("localhost", "root", "cold") or die(mysql_error());
mysql_select_db('new', $conn) or die(mysql_error());

?>


thats my database..

inc is not a script i was just testing out to see what happened if i made the last part a function ;=)

basilcy the same

it deletes all ;O

Comment/Reply (w/o sign-up)

sonesay
try this

CODE

$username = $_SESSION["username"];

if(isset($_POST['submit'])){

$email = $_POST['email'];
$msn = $_POST['msn'];
$info = $_POST['info'];

$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'
WHERE username = '$username'";

mysql_query($updateemail) or die("culd not edit your info");

echo "info updated";
}
// Display logout link
echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";

echo "$email";
echo "$msn";
echo "$info";



$username = $_SESSION["username"]; before the if statement

 

 

 


Comment/Reply (w/o sign-up)

coldasice
QUOTE(sonesay @ Dec 22 2007, 12:46 AM) *
try this

CODE

$username = $_SESSION["username"];

if(isset($_POST['submit'])){

$email = $_POST['email'];
$msn = $_POST['msn'];
$info = $_POST['info'];

$updateemail = "UPDATE users SET email = '$email', msn = '$msn', info = '$info'
WHERE username = '$username'";

mysql_query($updateemail) or die("culd not edit your info");

echo "info updated";
}
// Display logout link
echo "<p><a href=\"member.php\">Click here to go back to info page!</a></p>";

echo "$email";
echo "$msn";
echo "$info";



$username = $_SESSION["username"]; before the if statement


still dont work sad.gif it still deletes the whole username row ;/

Comment/Reply (w/o sign-up)

sonesay
what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty.

maybe try move the echo after the query is done

CODE


$username = $_SESSION["username"];

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$all = mysql_fetch_array($query);

$email = $all['email'];
$msn = $all['msn'];
$info = $all['info'];

echo "$email";
echo "$msn";
echo "$info";

Comment/Reply (w/o sign-up)

coldasice
QUOTE(sonesay @ Dec 22 2007, 01:01 AM) *
what do you mean delete? I only see an update statement and a select statement for displaying. If you get empty fields maybe the mysql database table is empty.

maybe try move the echo after the query is done

CODE


$username = $_SESSION["username"];

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$all = mysql_fetch_array($query);

$email = $all['email'];
$msn = $all['msn'];
$info = $all['info'];

echo "$email";
echo "$msn";
echo "$info";


well as far as i register.. the update querry dont do *BLEEP*.......

and i moved echo.. dosnt work ;O

Comment/Reply (w/o sign-up)

sonesay
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.

Comment/Reply (w/o sign-up)

Latest Entries

coldasice
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]

Comment/Reply (w/o sign-up)

sonesay
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

Comment/Reply (w/o sign-up)

jlhaslip
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?

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : Mysqlphpneed Som


    Looking for , mysql, php, som, basic

Searching Video's for , mysql, php, som, basic
See Also,
advertisement


[mysql/php]need Som Basic Help

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com