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 Edited by ignace
Removed db credentials, though you should still change your password
Link to comment
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.