Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Error with connecting mysql

    I want to connect text form with my sql database, but there is error in it, but I do not know where or what can I change.
    Here must be an error:

    PHP Code:
    <?php
    if (isset($_REQUEST['Submit'])) {
    $sql "INSERT INTO $db_table(title,description,url,keywords) values ('".mysql_real_escape_string(stripslashes($_REQUEST['title']))."','".mysql_real_escape_string(stripslashes($_REQUEST['description']))."','".mysql_real_escape_string(stripslashes($_REQUEST['url']))."','".mysql_real_escape_string(stripslashes($_REQUEST['keywords']))."')";
    if(
    $result mysql_query($sql ,$db)) {
    echo 
    '<h1>Thank you</h1>Your information has been entered into our database<br><br>';
    } else {
    echo 
    "ERROR: ".mysql_error();
    }
    ?>

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,307
    Thanks
    4
    Thanked 205 Times in 202 Posts
    What is the error you are getting? At the very least the snippet you posted is missing a closing curly brace which will cause a PHP error. Indentation is your friend.

    PHP Code:
    if (isset($_REQUEST['Submit'])) {
        
    $sql "INSERT INTO $db_table(title,description,url,keywords) values ('".mysql_real_escape_string(stripslashes($_REQUEST['title']))."','".mysql_real_escape_string(stripslashes($_REQUEST['description']))."','".mysql_real_escape_string(stripslashes($_REQUEST['url']))."','".mysql_real_escape_string(stripslashes($_REQUEST['keywords']))."')";
        if(
    $result mysql_query($sql ,$db)) {
            echo 
    '<h1>Thank you</h1>Your information has been entered into our database<br><br>';
        } else {
            echo 
    "ERROR: ".mysql_error();
        }
    }  
    // end of if isset 
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •