PHP: How to put a session into a mysql statment?!

Results 1 to 5 of 5
  1. #1
    Vous Pas Reel HotelUnderSeige is offline
    MemberRank
    Nov 2007 Join Date
    ColoradoSpringsLocation
    1,290Posts

    PHP: How to put a session into a mysql statment?!

    $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());
    mysql_query("INSERT INTO ".$_SESSION['radio']."request
    (Song, name) VALUES('$sname', '$name') ")
    or die(mysql_error());
    Error's
    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
    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


  2. #2
    Member LifeTaker is offline
    MemberRank
    Nov 2009 Join Date
    No.Location
    59Posts

    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.

  3. #3
    Vous Pas Reel HotelUnderSeige is offline
    MemberRank
    Nov 2007 Join Date
    ColoradoSpringsLocation
    1,290Posts

    Re: PHP: How to put a session into a mysql statment?!

    Quote Originally Posted by LifeTaker View Post
    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

  4. #4
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,098Posts

    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)

  5. #5
    Vous Pas Reel HotelUnderSeige is offline
    MemberRank
    Nov 2007 Join Date
    ColoradoSpringsLocation
    1,290Posts

    Re: PHP: How to put a session into a mysql statment?!

    Quote Originally Posted by s-p-n View Post
    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.



Advertisement