Page 1 of 1

PHP mysql problem

Posted: Sat Jan 08, 2011 9:33 pm
by z3r0nin3
hello

im new to this forum, i hope someone could help me on this...

i have a problem on updating a database...

my code is

mysql_query("UPDATE test_table SET subscribe = ' ', unsubscribe = 'True' WHERE email = '$email'");

the problem is on the records on the email column, if the record is test@test.com the email won't compare with $email (where $email has a value of test@test.com), it doesn't update the subscribe or unsubscribe column

but if the record on my email column is test and the value of $email is test it updates my database...

can anyone help on this?

Re: PHP mysql problem

Posted: Sat Jan 08, 2011 9:50 pm
by thecodewall
I try to create your table but there's a problem in naming field to subscribe , I think you need to check it.

codewall.blogspot.com

Re: PHP mysql problem

Posted: Sat Jan 08, 2011 10:00 pm
by z3r0nin3
i left subscribe to be blank because the record on it on the database is true,

my code is when the email and $mail matches the record on subscribe would be blank and the unsubcribe will have a record of true...

my problem is when the record is something like "test@test.com" the query won't work but if the record is something like "test" the query works...

Re: PHP mysql problem

Posted: Sat Jan 08, 2011 10:21 pm
by z3r0nin3
here is my code

---------------- this one doesn't work

Code: Select all

<?php

$email = 'test@test.com';
$connect = mysql_connect("localhost","root","123456");

$conToDB = mysql_select_db("test_database",$connect);

$result = mysql_query("SELECT * FROM test_database");
mysql_query("UPDATE test_table SET subscribe = '', unsubscribe = 'True' WHERE email = '$email'");

?>

--------------- this one works

Code: Select all

<?php

$email = 'test';
$connect = mysql_connect("localhost","root","123456");

$conToDB = mysql_select_db("test_database",$connect);

$result = mysql_query("SELECT * FROM test_database");
mysql_query("UPDATE test_table SET subscribe = '', unsubscribe = 'True' WHERE email = '$email'");

?>