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
adamb10
Forum Commoner
Posts: 91 Joined: Sat Jun 24, 2006 7:44 pm
Post
by adamb10 » Wed Jul 26, 2006 2:50 pm
Code: Select all
mysql_query ("UPDATE settings SET 'title'='".$title."', 'username'='".$name."', 'email'='". $email."', 'tablewidth'='".$width."', 'menubar'='".$menubar."', 'postorder'='".postorder."', 'posting'='".$posting."', 'kwikpost'='".$kwikpost."', 'maxshow'='".$maxshow."', 'im'='".$im."', 'links'='".$links."', 'logo'='".$logo."', 'menubarlocation'='".$menubarlocation."', 'kwikpostlocation'='".$kwikpostlocation."'");
That query doesnt do anything, I dunno whats wrong with it.
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 2:51 pm
Code: Select all
$q = $mysql_query($sql) or print(mysql_error());
do error checking and read the manual
kbrown3074
Forum Contributor
Posts: 119 Joined: Thu Jul 20, 2006 1:36 pm
Post
by kbrown3074 » Wed Jul 26, 2006 2:57 pm
I see you have single quotes around your field names..not necessary. Also try putting just single quotes around your vars....see below Also..kinda disturbing..you will set every record to these values since you dont have a where clause. Also you missed a $ on the posting var
Code: Select all
mysql_query ("UPDATE settings SET title='$title', username='$name', email='$email', tablewidth='$width', menubar='$menubar', postorder='$postorder', posting='$posting', kwikpost='$kwikpost', maxshow='$maxshow', im='$im', links='$links', logo='$logo',menubarlocation='$menubarlocation', kwikpostlocation='$kwikpostlocation'");[/url]
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 3:02 pm
single quotes are fine for fields that are strings and integers
adamb10
Forum Commoner
Posts: 91 Joined: Sat Jun 24, 2006 7:44 pm
Post
by adamb10 » Wed Jul 26, 2006 3:06 pm
I did try errors on and MySQL printed...
Code: Select all
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 ''title'='Testbook', 'username'='adam', 'email'='debailey@wi.rr.com', 'tablewidth' at line 1
I fixed the variable where no $ was btw.
jamiel
Forum Contributor
Posts: 276 Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom
Post
by jamiel » Wed Jul 26, 2006 3:09 pm
Your field names need to have backticks (`) around them not quotes (')
adamb10
Forum Commoner
Posts: 91 Joined: Sat Jun 24, 2006 7:44 pm
Post
by adamb10 » Wed Jul 26, 2006 3:14 pm
Backticks didnt work either. :p I hate being a n00b at mysql.
jamiel
Forum Contributor
Posts: 276 Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom
Post
by jamiel » Wed Jul 26, 2006 3:18 pm
Put all that sql into a variable called $sql .. then print_r($sql) just before the query.
Show us the output of that aswell as the new mysql_error() you are most likely getting.
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 3:31 pm
sorry kbrown and jamiel, didnt notice that he was single quoting field names and didn't mean to go against what you two said.
adamb10
Forum Commoner
Posts: 91 Joined: Sat Jun 24, 2006 7:44 pm
Post
by adamb10 » Wed Jul 26, 2006 3:32 pm
Code: Select all
print_r($sql)
$sql = "mysql_query ("UPDATE settings WHERE `title`='".$title."', `username`='".$name."', `email`='". $email."', `tablewidth`='".$width."', `menubar`='".$menubar."', `postorder`='".$postorder."', `posting`='".$posting."', `kwikpost`='".$kwikpost."', `maxshow`='".$maxshow."', `im`='".$im."', `links`='".$links."', `logo`='".$logo."', `menubarlocation`='".$menubarlocation."', `kwikpostlocation`='".$kwikpostlocation."'") or print(mysql_error())";
The variable has a parse error in it. I usually dont apply variables to big queries like this.
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 3:33 pm
you have to end every line with a semi colon
;/b]
Code: Select all
print("<pre>");
print_r($sql);
print("</pre>");
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 3:35 pm
adamb10 wrote: Code: Select all
$sql = "UPDATE settings WHERE `title`='".$title."', `username`='".$name."', `email`='". $email."', `tablewidth`='".$width."', `menubar`='".$menubar."', `postorder`='".$postorder."', `posting`='".$posting."', `kwikpost`='".$kwikpost."', `maxshow`='".$maxshow."', `im`='".$im."', `links`='".$links."', `logo`='".$logo."', `menubarlocation`='".$menubarlocation."', `kwikpostlocation`='".$kwikpostlocation."'";
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed Jul 26, 2006 3:41 pm
He needs to escape the vars. The '@' might be giving him problems.
adamb10
Forum Commoner
Posts: 91 Joined: Sat Jun 24, 2006 7:44 pm
Post
by adamb10 » Wed Jul 26, 2006 3:41 pm
MySQL didnt return an error that time but the query is still dead in the water..
daedalus__
DevNet Resident
Posts: 1925 Joined: Thu Feb 09, 2006 4:52 pm
Post
by daedalus__ » Wed Jul 26, 2006 3:52 pm
What do you mean "dead in the water"?
Code: Select all
$r = mysql_query($sql);
print mysql_affected_rows($r);