PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1845
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Problem with mySQL "update" query. Posted by Neak on 8 Sept 2004 at 7:51 PM
Well. This is the second time I'm posting this... For some reason when I looked at the board today my post wasn't there. This has happened twice before also... I don't know why.

Anyway, on to the question! I have been having trouble with the mySQL query "UPDATE." I am getting an error if I have it give me a die() message. Here is the query:
mysql_query("UPDATE news SET title = '$title', name = '$name', date = '$date', content = '$content' WHERE title = '$get_title'");
The connection is fine because in the same file, but a different loop, this query works:
$rows = mysql_query("SELECT * FROM news WHERE title = '$get_title'");

Am I getting something wrong with the syntax of the "UPDATE" query? I've looked on various sites about this and found nothing. Thanks for the help, baby.
Report
Re: Problem with mySQL "update" query. Posted by DarQ on 9 Sept 2004 at 5:37 AM
make sure there are NO ' characters in $content or $title etc. i don't see any syntax error either. doesnt mysql give you an error message?

: Well. This is the second time I'm posting this... For some reason when

I looked at the board today my post wasn't there. This has happened twice before also... I don't know why.
:
: Anyway, on to the question! I have been having trouble with the mySQL query "UPDATE." I am getting an error if I have it give me a die() message. Here is the query:
mysql_query("UPDATE news SET title = '$title', name = '$name', date = '$date', content = '$content' WHERE title = '$get_title'");
The connection is fine because in the same file, but a different loop, this query works:
$rows = mysql_query("SELECT * FROM news WHERE title = '$get_title'");

: Am I getting something wrong with the syntax of the "UPDATE" query? I've looked on various sites about this and found nothing. Thanks for the help, baby.
:


DarQ
Jou my no rap dy lekkere dikke tsjap

Report
Re: Problem with mySQL "update" query. Posted by Neak on 9 Sept 2004 at 7:46 PM
: make sure there are NO ' characters in $content or $title etc. i don't see any syntax error either. doesnt mysql give you an error message?
:
My god! You're right! The only entry to the database that I've tested it with has the title field as "Attack of the X's" -_- How can I fix it so that there can be 's in the title field? I know there's a function for unescaping things, but is there a function to escape all apostrophes in a string?
Report
Re: Problem with mySQL "update" query. Posted by DarQ on 10 Sept 2004 at 5:00 AM
http://www.php.net/addslashes
http://www.php.net/stripslashes

but in some cases it can be very, very tricky when you have single and double qoutes.


: : make sure there are NO ' characters in $content or $title etc. i don't see any syntax error either. doesnt mysql give you an error message?
: :
: My god! You're right! The only entry to the database that I've tested it with has the title field as "Attack of the X's" -_- How can I fix it so that there can be 's in the title field? I know there's a function for unescaping things, but is there a function to escape all apostrophes in a string?
:

DarQ
Jou my no rap dy lekkere dikke tsjap

Report
Re: Problem with mySQL "update" query. Posted by Neak on 10 Sept 2004 at 6:18 PM
: http://www.php.net/addslashes
: http://www.php.net/stripslashes

Thanks...

: but in some cases it can be very, very tricky when you have single and double qoutes.

Man. I don't like tricky. ;_;



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.