--MySQL questions---
<?php
session_start();
$user=$_SESSION['user'];
$pass=$_SESSION['pass'];
$query="UPDATE users SET name=". $_SESSION['user'] .", password=". $_SESSION['pass'] .", strength=". $_SESSION['strength'] .", defense=". $_SESSION['defense'] .", powerlevel=". $_SESSION['powerlevel'] .", int=". $_SESSION['int'] .", hp=". $_SESSION['hp'] .", job=". $_SESSION['job'] .", gold=". $_SESSION['gold'] ." WHERE name=$user AND password=$pass";
$result=mysql_query($query) or die("Error in query:".mysql_error());
?>
I don't understand why this isnt working. It's giving me this---
Error in query:You have an error in your SQL syntax near 'int=1, hp=10, job=none, gold=40 WHERE name=Gohan AND password=e5e65fce9273c4762a' at line 1
can anyone please tell me what I typed wrong here? I've been sitting here forever to find out what I did wrong.
updating a row using the session variables
Moderator: General Moderators
-
Red Midnight
- Forum Newbie
- Posts: 2
- Joined: Mon Jun 30, 2003 4:29 pm
What are all the variables getting set to in your UPDATE statement? Is it possible that one of them contains a comma and is throwing things off? I generally put single quotes around all my variables when I do this. For example:
Code: Select all
$query="UPDATE users SET name='$_SESSION[user]', password='$_SESSION[pass]', strength='$_SESSION[strength]', defense='$_SESSION[defense]', powerlevel='$_SESSION[powerlevel]', int='$_SESSION[int]', hp='$_SESSION[hp]', job='$_SESSION[job]', gold='$_SESSION[gold]' WHERE name='$user' AND password='$pass'";-
Red Midnight
- Forum Newbie
- Posts: 2
- Joined: Mon Jun 30, 2003 4:29 pm
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
This is a handy bookmark to use when designing tables (can prevent many headaches):
http://www.mysql.com/doc/en/Reserved_words.html
Mac
http://www.mysql.com/doc/en/Reserved_words.html
Mac
-
bionicdonkey
- Forum Contributor
- Posts: 132
- Joined: Fri Jan 31, 2003 2:28 am
- Location: Sydney, Australia
- Contact: