Jump to content

Why Can I not connect to my database?


Jenksuy

Recommended Posts

I don't understand why my database will not connect to my server...

 

Can anyone see anything that I cant?

<?php
    // Grab our POSTed form values
    // Note that whatever is enclosed by $_POST[""] matches the form input elements
    $reference = $_POST["reference"];
    $category = $_POST["category"];
    $title = $_POST["title"];
    $location = $_POST["location"];
    $salary = $_POST["salary"];
    $type = $_POST["type"];

    // Connect to our DB with mysql_connect(<server>, <username>, <password>)
    $sql_connection = mysql_connect("xxxx", "xxxx", "xxxxx");
    
    if (!$sql_connection)
        {
          echo "Please try later.";
        }
        else
        {
         mysql_select_db("frcrecru_beta", $sql_connection);
        }
   

    // Probably should check to make sure the connection was successful
    // But I'm too lazy...
    $sql = "INSERT INTO face-recruiter (
                reference,
                category,
                title,
                location,
                salary,
                type
            )
            VALUES (
                '$reference',
                '$category',
                '$title',
                '$location',
                '$salary',
                '$type',
                NOW()
            )";

    mysql_query($sql, $sql_connection);

    mysql_close($sql_connection);
?>
Thanks
Link to comment
https://forums.phpfreaks.com/topic/279233-why-can-i-not-connect-to-my-database/
Share on other sites

Are you in fact getting the error message "please try later"??  Cause if you are not, then how do you know you didn't?  Plus you should add MySQL_error() to that echo statement to help you out.

 

BTW - your insert has more values than field names.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.