errors

I am getting an error message of ‘cannot use learnphp’ learn php is the name of the database I am trying to post to.
here is the code.
[php]

<?php if($_POST['formSubmit'] == "Submit") { if(empty($_POST['formName'])) { $errorMessage .= "
  • You forgot to enter your formName.
  • "; } if(empty($_POST['address'])) { $errorMessage .= "
  • You forgot to enter your address.
  • "; } if(empty($_POST['city'])) { $errorMessage .= "
  • You forgot to enter your city.
  • "; } if(empty($_POST['state'])) { $errorMessage .= "
  • You forgot to enter your state.
  • "; } if(empty($_POST['zip'])) { $errorMessage .= "
  • You forgot to enter your zip code.
  • "; } if(empty($_POST['phone'])) { $errorMessage .= "
  • You forgot to enter your phone number.
  • "; } if(empty($_POST['email'])) { $errorMessage .= "
  • You forgot to enter your email.
  • "; } } $varMovie = $_POST['formName']; $varMovie = $_POST['address']; $varMovie = $_POST['city']; $varMovie = $_POST['state']; $varMovie = $_POST['zip']; $varMovie = $_POST['phone']; $varMovie = $_POST['email']; //generated by fatcow $link = mysql_connect('hankkaminsky.fatcowmysql.com', 'hankkaminsky', 'password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(learnphp); if (!$db_selected) { die ('Can\'t use learnphp : ' . mysql_error()); //end generated code /*I am not dealing with the problems of the code that is commented out. } if(!empty($errorMessage)) { echo("

    There was an error with your form:

    \n"); echo("
      " . $errorMessage . "
    \n"); } } $sql = "INSERT INTO membership (memberName, address, city, state, zip, phone, email) VALUES (". PrepSQL($varmemberName) . ", " . PrepSQL($varAddress) . ", " . PrepSQL($varCity) . ")"; PrepSQL($varState) . ")"; PrepSQL($varZip) . ")"; PrepSQL($varPhone) . ")"; PrepSQL($varEmail) . ")"; mysql_query($sql); //header("Location: thankyou.html"); exit(); } // function: PrepSQL() // use stripslashes and mysql_real_escape_string PHP functions // to sanitize a string for use in an SQL query // // also puts single quotes around the string // function PrepSQL($value) { // Stripslashes if(get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote $value = "'" . mysql_real_escape_string($value) . "'"; return($value); } */ ?> membership test <?php if(!empty($errorMessage)) { echo("

    There was an error with your form:

    \n"); echo("
      " . $errorMessage . "
    \n"); } ?> Name: Address: City: State: Zip: Phone: Email: [/php]

    Hi there,

    I think you need to put some speech marks around learnphp where you are doing the mysql_select_db.

    Plus, I think you need to put "$db_selected = " (without speech marks) in front of the mysql_select_db function.

    Let me know if this helps.

    Thanks for the help but it didn’t do anything. The code I am using was generated by my webhost. I checked with them and they said it was not a problem with their code. it is connecting with the server but won’t select. It seems like it should be simple. but this is my first php project.

    Sponsor our Newsletter | Privacy Policy | Terms of Service