[SQL]insert into table error

Results 1 to 6 of 6
  1. #1
    Sorcerer Supreme Hidden is offline
    Member +Rank
    Apr 2008 Join Date
    .Location
    367Posts

    [SQL]insert into table error

    PHP Code:
    <?php include("includes/header.php");?>
    <?php 
    if(isset($_REQUEST['submit'])){
    $query=mysql_query("INSERT INTO `a4794514_guru`.`news` ('user', 'title',' page_body') VALUES ('$user', '$title', '$page_body')") or die("error");
    $title=$_REQUEST['title'];
    $user=$_REQUEST['user'];
    $page_body=$_REQUEST['page_body'];

    }

    ?>

                   
    <br />
    <form name="submit" action="">    
    <input type="text" name="title" value="" />
    <br /><input type="text" name="user" value="" />
    <br /><input type="text" name="page_body" value="" />
    <br />
                            <input type="submit" name="submit" value="Submit Query" />&nbsp;<input type="reset" value="Reset" />
    </form>
    <?php include("includes/footer.php");?>
    No matter what i do i always get a error =/


  2. #2
    Grand Master john_d is offline
    Grand MasterRank
    Feb 2004 Join Date
    PhilippinesLocation
    2,868Posts

    Re: [SQL]insert into table error

    ur asking for a sql injection..

    anyway don't use `

  3. #3
    Sorcerer Supreme Hidden is offline
    Member +Rank
    Apr 2008 Join Date
    .Location
    367Posts

    Re: [SQL]insert into table error

    Quote Originally Posted by john_d View Post
    ur asking for a sql injection..

    anyway don't use `
    Thanks that solved the problem :D

  4. #4
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [SQL]insert into table error

    Quote Originally Posted by FragFrog View Post
    ...backticks are good. Keep the backticks. :icon6:...
    The backticks should be able to stay w/o errors.
    Maybe put the variables above the $query?

  5. #5
    Fuck you, I'm a dragon Pieman is offline
    Grand MasterRank
    Apr 2005 Join Date
    The NetherlandsLocation
    7,412Posts

    Re: [SQL]insert into table error

    PHP Code:
    $query=mysql_query("INSERT INTO `a4794514_guru`,`news` ('user', 'title',' page_body') VALUES ('$user', '$title', '$page_body')") or die("error");
    $title=$_REQUEST['title']; 
    After `a4794514_guru` you had a period (.) instead of a comma.

  6. #6
    The Gamma..? EliteGM is offline
    Grand MasterRank
    Jul 2006 Join Date
    NandolandLocation
    4,077Posts

    Re: [SQL]insert into table error

    I think the period was correctly placed, I believe it's like: `database`.`table` or something.



Advertisement