updating a row using the session variables
Posted: Mon Jun 30, 2003 4:29 pm
--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.
<?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.