PHP mysql problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
z3r0nin3
Forum Newbie
Posts: 3
Joined: Sat Jan 08, 2011 9:20 pm

PHP mysql problem

Post 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?
thecodewall
Forum Commoner
Posts: 33
Joined: Sun Dec 26, 2010 8:37 am

Re: PHP mysql problem

Post 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
z3r0nin3
Forum Newbie
Posts: 3
Joined: Sat Jan 08, 2011 9:20 pm

Re: PHP mysql problem

Post 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...
z3r0nin3
Forum Newbie
Posts: 3
Joined: Sat Jan 08, 2011 9:20 pm

Re: PHP mysql problem

Post 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'");

?>
Last edited by Benjamin on Mon Jan 10, 2011 1:31 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
Post Reply