Page 1 of 1
php&mysql question
Posted: Wed May 26, 2004 12:58 pm
by bobemf
the values [$name2] come from a form on the previous page.
Code: Select all
<body bgcolor="#F3F3F3">
<font color="#808080" size="2"><?
$conn = @mysql_connect("localhost", "lh", "edit")
or die("Could not connect to MySQL Database.");
$rs = @mysql_select_db("profiles",$conn)
or die("Could not select MySQL database");
$sql ="REPLACE INTO profile (real_name, aboutme, email, age) values ("$real_name2","$aboutme2","$email2","$age2") WHERE `user`='$autheduser'";
$rs = @mysql_query($sql,$conn)
or die("Could not execute SQL query");
echo 'If there are no errors above ... your profile update was successful.';
?>
Im getting
so it must be something with replace into or something? im not sure.
thanks for the help!
Posted: Wed May 26, 2004 1:00 pm
by bobemf
Heres the previous page, JUST in case.
Code: Select all
<body bgcolor="#F3F3F3">
<?php
$autheduser = $_COOKIE['account'];
if($autheduser != null) {
$acct = $_COOKIE['account'];
$conn=@mysql_connect("localhost", "lh", "")
or die("Error: Connection - Please contact site administrator if this happens again, thank you!");
$rs = @mysql_select_db("profiles",$conn)
or die("Error: Db - Please contact site administrator if this happens again, thank you!");
$sql = "SELECT * FROM profiles WHERE `user`='$autheduser'";
$rs = @mysql_query($sql,$conn)
or die("Error: Query - Please contact site administrator if this happens again, thank you!");
while( $row = mysql_fetch_array($rs) )
{
$user = $row['user'];
$aboutme = $row['aboutme'];
$icon = $row['icon'];
$email = $row['email'];
$realname = $row['real_name'];
$age = $row['age'];
}
?>
<font color="#808080" size="2">
<?
$form="<form action="creating.php" method="post">
Editing profile for:<br>
$autheduser<br><br>
Real Name<br><textarea name="real_name2" type="text">$realname</textarea><br>
Age<br><textarea name="age2" type="text">$age</textarea><br>
Your Email<br><textarea name="email2" type="text">$email</textarea><br>
About You<br>
<textarea name="aboutme2" cols="50" rows="10">$aboutme</textarea><br>
<input name="Submit" type="Submit" value="Submit">
</form>";
?>
<? } else { echo("<font color="#808080" size="2">You are not logged in."); }
echo $form
?>
Posted: Wed May 26, 2004 1:14 pm
by lostboy
Code: Select all
$sql ="UPDATE profile set real_name='$real_name2', aboutme='$aboutme2', email= '$email2', age$age2 WHERE `user`='$autheduser'";
Posted: Wed May 26, 2004 1:43 pm
by bobemf
nope.
could not execute query.
Posted: Wed May 26, 2004 1:45 pm
by lostboy
Code: Select all
$sql ="UPDATE profile set real_name='$real_name2', aboutme='$aboutme2', email= '$email2', age=$age2 WHERE `user`='$autheduser'";
Missed the equal sign in the
age section
Posted: Wed May 26, 2004 1:47 pm
by bobemf
this is what i have
Code: Select all
<body bgcolor="#F3F3F3">
<font color="#808080" size="2"><?
$conn = @mysql_connect("localhost", "lh", "")
or die("Could not connect to MySQL Database.");
$rs = @mysql_select_db("profiles",$conn)
or die("Could not select MySQL database");
$sql ="UPDATE profile set real_name='$real_name2', aboutme='$aboutme2', email= '$email2', age=$age2 WHERE `user`='$autheduser'";
$rs = @mysql_query($sql,$conn)
or die("Could not execute SQL query");
echo 'If there are no errors above ... your profile update was successful.';
?>
Still didnt work

(
Posted: Wed May 26, 2004 1:58 pm
by lostboy
You are using the same variable for the recordset $rs and the database selection $rs...shoudn't matter though....
remove the @ symbol to see what the real error is
Posted: Wed May 26, 2004 2:10 pm
by bobemf
remove the @ symbol where?
<-- there?
Posted: Wed May 26, 2004 3:41 pm
by Draco_03
everywhere
Posted: Thu May 27, 2004 1:25 pm
by bobemf
ok i removed the @ everywhere..
and i still didnt get any error besides my die message Could not execute query.
Posted: Thu May 27, 2004 1:27 pm
by feyd
switch that to die(mysql_error()), and please report back what it kicks out.
Posted: Thu May 27, 2004 9:51 pm
by bobemf
I got it working now!! Thanks for your help guys!