Why am i getting an internal server error?

Discussion in 'PHP' started by paul_so40, Jan 14, 2013.

  1. #1
    Hey all,

    Im getting an internal server error with the following basic script, the page has permissions of 777

    <?php
    
    
    
    //// database login info taken out
    
    
    mysql_connect($db_host, $db_username, $db_password) or die("Connection Failed");
    mysql_select_db($db_name)or die("Connection Failed");
    
    $user = 'Paul'; 
    
    $tittle = 'testspaw';
    
    $subtittle ='testspaw';
    
    $qis = 'testspaw';
    
    $condition = 'testc';
    
    $pound = 'testspaw';
    
    $spaw = 'testspaw';
    
    $query = "INSERT INTO products(user,tittle,subtittle,quantity,condition,priceq,descripton)VALUES('$user','$tittle','$subtittle','$qis','$condition','$pound','$spaw')";
    
    
    if(mysql_query($query)){
    echo "inserted";}
    else{
    echo "fail";}
    
    ?>
    PHP:


    Any help is much appreciated

    Thanks

    Paul
     
    Solved! View solution.
    paul_so40, Jan 14, 2013 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    mysql_select_db($db_name)or die("Connection Failed");

    must be

    mysql_select_db($db_name) or die("Connection Failed");

    and please rewrite this

    if(mysql_query($query)){
    echo "inserted";}
    else{
    echo "fail";}

    to something like this

    if ($statement) {
    // do this
    } else {
    // do this
    }

    :)
     
    EricBruggema, Jan 14, 2013 IP
  3. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply,


    I have made the suggested changes but i still get Internal Server Error
     
    paul_so40, Jan 14, 2013 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    Check your server logs and see what the actual error is that's being produced.
     
    jestep, Jan 14, 2013 IP
  5. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ive updated a line of text to

    mysql_query("INSERT INTO products (user,tittle,subtittle,quantity,condition,priceq,descripton) VALUES('$user','$tittle','$subtittle','$qis','$condition','$pound','$spaw')") or die(mysql_error());  
    
    
    PHP:
    And i am getting the error,

    Can anyone spot the problem?

    Thanks for your help guys
     
    paul_so40, Jan 14, 2013 IP
  6. #6
    Delimit field names with `user`,`title` ...
    Also use phpmyadmin to try your queries. Have your script echo that sql string and run that in phpmyadmin.
    mysql_query($sql="INSERT ...
    echo $sql;
     
    VideoWhisper.com, Jan 14, 2013 IP
    paul_so40 likes this.
  7. paul_so40

    paul_so40 Peon

    Messages:
    119
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks, Its working now :)
     
    paul_so40, Jan 14, 2013 IP