PHP: How to put a session into a mysql statment?!
Quote:
$Radio = addslashes($_SESIION['radio']);
$result = "INSERT INTO $Radio (passwd, firstname, lastname, login) VALUES
('".md5($_POST['password'])."', '".$fname."', '".$lname."', '".$login."')";
mysql_query($result) or die(mysql_error());
Quote:
mysql_query("INSERT INTO ".$_SESSION['radio']."request
(Song, name) VALUES('$sname', '$name') ")
or die(mysql_error());
Error's
Quote:
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 '(passwd, firstname, lastname, login) VALUES ('e10adc3949ba59abbe56e057f20f883e',' at line 1
Quote:
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 '(Song, name) VALUES('dfasd', 'sad')' at line 1
Re: PHP: How to put a session into a mysql statment?!
It's $_SESSION and not $_SESIION.
For the second one, echo out the query before running it.
Oh and by the way, I hope for you $_SESSION['radio'] doesn't come from an input.
Re: PHP: How to put a session into a mysql statment?!
Quote:
Originally Posted by
LifeTaker
It's $_SESSION and not $_SESIION.
For the second one, echo out the query before running it.
Oh and by the way, I hope for you $_SESSION['radio'] doesn't come from an input.
no sir it does not
And i /fail with typoes lol
---------- Post added at 11:40 PM ---------- Previous post was at 11:23 PM ----------
So i fixed it i had many typoes as above and i had forget to put in the session_start()
FAIL
Re: PHP: How to put a session into a mysql statment?!
Well get your head out of your ass and look more clearly at your code.. Print out stuff that's not behaving as expected and pay attention to what you're doing when you're doing it.
Everyone experiences typos (some days worse than others), but most the time your testing should point out when they come up.. (otherwise you're not testing enough before posting)
Re: PHP: How to put a session into a mysql statment?!
Quote:
Originally Posted by
s-p-n
Well get your head out of your ass and look more clearly at your code.. Print out stuff that's not behaving as expected and pay attention to what you're doing when you're doing it.
Everyone experiences typos (some days worse than others), but most the time your testing should point out when they come up.. (otherwise you're not testing enough before posting)
true but when theres typoes i usualy look for a t variable error. The mysql database error through me off.