Jump to content

Problem with insert query


floridaflatlander

Recommended Posts

I have worked on this for hours and can't find the problem.

 

My $r doesn't query for some reason

I've tested the database connection and variables with echo statements and they work, also there is an SELECT statement above this that checks to see if the name is in use and it works like it is suppose to. I just can't get this code to work.

I have php5, the database connection with host, user, pw and database name are correct and isn't redefined or exited. The SELECT I mentioned uses the same connection.

 

Can any one see whats wrong with this

 

$q = "INSERT INTO vendors (id_vendor, name, s_discrip, discript, phone, zip, id_loca, email, web_title, web_url, photo, date_reg)

VALUES (NULL, '$name', '$s_discrip', '$discrip', '$phone', '$zip', '$loca', '$email', '$ws_title', '$ws_url', 'photo', CURRENT_TIMESTAMP);";

 

$r = mysqli_query($dbc, $q);

 

Thanks

S

Link to comment
Share on other sites

The mysqli_connect_error() comes in in an include statement before the queries, DB_HOST etc. are defined with define statments.

 

$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySQL;'. mysqli_connect_error());

 

if (!$dbc){

trigger_error('Could not connect to Mysql: ' . mysqli_connect_error());

}

 

Also would think all is OK since I use two selects on the form that enters the info, one to check for user name the other to get location IDs

Link to comment
Share on other sites

Oh, not mysqli_connect_error(), mysqli_error(). The latter is used to report errors in query executions.

if( !$result = mysqli_query($dbc, $query) ) {
     echo "<br>Query string: $query<br>Resulted in error: " . mysqli_error($dbc) . '<br>';
}

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.