| | |
simple mysql question..plz answer :)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Ok so what i'd like to know is how to have two where statements in a mysql delete query. I get an error if i do this:
Any help would be much appreciated, I know this is a silly question, but i havnt done any php programming for a couple of months and need to get back into it!
Thanks,
jakx12
mysql_query("DELETE FROM user_notifications WHERE username='$acc' AND WHERE notification='$note2'")
or die(mysql_error());Any help would be much appreciated, I know this is a silly question, but i havnt done any php programming for a couple of months and need to get back into it!
Thanks,
jakx12
mysql_query("DELETE FROM user_notifications WHERE username='".$acc."' AND notification='".$note2."' "); that should be fine. if its not, try checking your $acc and $note2 variables...
Last edited by peter_budo; Mar 1st, 2009 at 6:27 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Ill solve somebody's thread someday! xD
•
•
•
•
mysql_query("DELETE FROM user_notifications WHERE username='".$acc."' AND notification='".$note2."' ");
that should be fine. if its not, try checking your $acc and $note2 variables...
php Syntax (Toggle Plain Text)
mysql_query("DELETE FROM `user_notifications` WHERE `username`='".mysql_real_escape_string($acc)."' AND `notification`='".mysql_real_escape_string($note2)."' ") or die(mysql_error());
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
•
•
Join Date: Apr 2008
Posts: 28
Reputation:
Solved Threads: 3
To be a better php programmer always use single quotes like this,
bcoz: php parser will search and parse full string while using double quotes.
- might look simple - but usefull tip(i think so)
php Syntax (Toggle Plain Text)
mysql_query('DELETE FROM user_notifications WHERE username="'.mysql_real_escape_string($acc).'" AND notification="'.mysql_real_escape_string($note2).'"') or die(mysql_error());
- might look simple - but usefull tip(i think so) Last edited by peter_budo; Mar 8th, 2009 at 6:41 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
•
•
To be a better php programmer always use single quotes like this,
mysql_query('DELETE FROM user_notifications WHERE username="'.mysql_real_escape_string($acc).'" AND notification="'.mysql_real_escape_string($note2).'"')
or die(mysql_error());
bcoz: php parser will search and parse full string while using double quotes.- might look simple - but usefull tip(i think so)
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
•
•
Join Date: Apr 2008
Posts: 28
Reputation:
Solved Threads: 3
while using double quotes.. parser will search for php variable("my name is vinoth" instead use 'my name is vinoth') inside that string...(execution/parsing time will be greater). If we want to display the string with out any php variable('my name is '.$name)... then better to use single quotes...
its truth.... in PHP (I may not know about other languages)
its truth.... in PHP (I may not know about other languages)
•
•
•
•
while using double quotes.. parser will search for php variable("my name is vinoth" instead use 'my name is vinoth') inside that string...(execution/parsing time will be greater). If we want to display the string with out any php variable('my name is '.$name)... then better to use single quotes...
its truth.... in PHP (I may not know about other languages)
php Syntax (Toggle Plain Text)
$var="line1\nline2"; mysql_query('INSERT INTO `table` SET `column`="'.$var.'"');
PHP Syntax (Toggle Plain Text)
line1 line2
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
Other Threads in the PHP Forum
- Previous Thread: insert csv file into mysql through php
- Next Thread: Using and processing XML from multiple sources
Views: 614 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic echo email error file files folder form format forms forum function functions google headmethod href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail malfunctioning menu methods mlm mod_rewrite multiple mysql oop parse parsing paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






but there is no error 