Jump to content

Syntax error with updating a database


Pyro4816

Recommended Posts

[code] <?php
require_once('../includes/dbconnector.php');
$connector = new dbconnector();
if ($HTTP_GET_VARS['action'] == 'edit'){
$connector->query("UPDATE admin SET about,advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponsors,tutorials,header,footer ='
".$HTTP_POST_VARS['about']."','
".$HTTP_POST_VARS['advertise']."','
".$HTTP_POST_VARS['announcements']."','
".$HTTP_POST_VARS['articles']."','
".$HTTP_POST_VARS['contact']."','
".$HTTP_POST_VARS['faq']."','
".$HTTP_POST_VARS['downloads']."','
".$HTTP_POST_VARS['index']."','
".$HTTP_POST_VARS['members']."','
".$HTTP_POST_VARS['news']."','
".$HTTP_POST_VARS['sponsors']."','
".$HTTP_POST_VARS['tutorials']."','
".$HTTP_POST_VARS['header']."','
".$HTTP_POST_VARS['footer']."' WHERE ID='0'");
echo '<center><b>Updated</b></center><br>',mysql_error();
}else{
echo '<center>Sorry, there was a problem!</center>',mysql_error();
}
?>[/code]

Well there are 2 errors with the script, one of them is i set my error up wrong, but thats not really a problem, the other is the syntax for inserting it, i am not sure what it is, but when i use it on only one it works fine, but when i use this setup (multiple inputs) it says that the query is empty. Any ideas o what i am doing wrong?

it gives me this error if that helps?[quote]ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponso' at line 1[/quote]
Link to comment
https://forums.phpfreaks.com/topic/29272-syntax-error-with-updating-a-database/
Share on other sites

Do not use $HTTP_GET_VARS and HTTP_POST_VARS, use $_GET and $_POST instead. But that's not your problem.

You have:
[code]<?php
$connector->query("UPDATE admin SET about,advertise,announcements,articles,contact,FAQ,downloads,index,members,news,sponsors,tutorials,header,footer ='
".$HTTP_POST_VARS['about']."','
".$HTTP_POST_VARS['advertise']."','
".$HTTP_POST_VARS['announcements']."','
".$HTTP_POST_VARS['articles']."','
".$HTTP_POST_VARS['contact']."','
".$HTTP_POST_VARS['faq']."','
".$HTTP_POST_VARS['downloads']."','
".$HTTP_POST_VARS['index']."','
".$HTTP_POST_VARS['members']."','
".$HTTP_POST_VARS['news']."','
".$HTTP_POST_VARS['sponsors']."','
".$HTTP_POST_VARS['tutorials']."','
".$HTTP_POST_VARS['header']."','
".$HTTP_POST_VARS['footer']."' WHERE ID='0'");
?>[/code]

But then say:
[code]<?php
$connector->query($insertQuery)
?>[/code]
Where is the variable $insertQuery being set?

Ken
the syntax was completely wrong, here is a copy of the fixed code. [code] <?php
require_once('../includes/dbconnector.php');
$connector = new dbconnector();
if ($HTTP_GET_VARS['action'] == 'edit'){
$connector->query("UPDATE admin SET about='"
.$_POST['about']."',advertise='"
.$_POST['advertise']."' ,announcements='"
.$_POST['announcements']."' ,articles='"
.$_POST['articles']."' ,contact='"
.$_POST['contact']."' ,downloads='"
.$_POST['downloads']."' ,FAQ='"
.$_POST['faq']."' ,indecs='"
.$_POST['indecs']."' ,members='"
.$_POST['members']."' ,news='"
.$_POST['news']."' ,sponsors='"
.$_POST['sponsors']."' ,tutorials='"
.$_POST['tutorials']."' ,header='"
.$_POST['header']."' ,footer='"
.$_POST['footer']."'
WHERE ID=0");
echo '<center><b>Updated</b></center><br>';
}else{
echo '<center>Sorry, there was a problem, contact Joey ASAP!</center>';
}
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.