| | |
passing variables threw query
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2005
Posts: 44
Reputation:
Solved Threads: 0
Hey all
What is with this query
$query = mysql_query("UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'") . mysql_error();
Its not passing the variables am getting this error message
Notice: Query error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 in /home/namit/public_html/admin/index.php on line 162
What is with this query
$query = mysql_query("UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'") . mysql_error();
Its not passing the variables am getting this error message
Notice: Query error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 SQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'postee--', `post` = 'post
--asdfsafasf' , `ip` = '83.70.242 in /home/namit/public_html/admin/index.php on line 162
•
•
Join Date: Jun 2005
Posts: 107
Reputation:
Solved Threads: 3
•
•
•
•
Originally Posted by namit
$query = mysql_query("UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'") . mysql_error();
$query = mysql_query("UPDATE namitposts SET title = '" . $topic . "', date = '" . $date . "', postee........
Web Developer
When something seems too good to be true...it usually is
When something seems too good to be true...it usually is
No... the code is fine... double quotes in PHP tell it to parse the string for variable names and replace as necessary.
Why are you concatenating the mysql_query return value with the mysql_error return value?
Try this:
[php]$sql = "UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'";
if ($query = mysql_query($sql))
{
// do stuff
}
else
{
echo '<pre>' . $sql . "\n" . mysql_error() . '</pre>';
}[/php]
If it fails, scan the SQL for any errors.
Why are you concatenating the mysql_query return value with the mysql_error return value?
Try this:
[php]$sql = "UPDATE `namitposts` SET `title` = '$topic' , `date` = '$date' ', `postee` = '$postee', `post` = '$post_text' , `ip` = '$ip' WHERE `id` = '$del'";
if ($query = mysql_query($sql))
{
// do stuff
}
else
{
echo '<pre>' . $sql . "\n" . mysql_error() . '</pre>';
}[/php]
If it fails, scan the SQL for any errors.
MySQL Syntax (Toggle Plain Text)
while(sleeping) cat_wails(); wake_up(); for(i=0;i<9;i++) shoot_cat(); rejoice(); goto(bed);
![]() |
Similar Threads
- Problem passing variables to thread (Perl)
- passing arrary threw query (Visual Basic 4 / 5 / 6)
- function passing variables (C)
- Passing Variables/Parameters - By Ref/Value? (Computer Science)
- Passing variables into form fields (PHP)
- Retreiving variables from a sql query into a form (PHP)
Other Threads in the MySQL Forum
- Previous Thread: MySql database Synchronization
- Next Thread: ERROR 2002: Can't connect to local MySQL server
| Thread Tools | Search this Thread |
agplv3 amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





