Jump to content

mysql insert not working


brianlange

Recommended Posts

I have a mysql insert statement generated with php that is not populating the table.

I've echoed the statement and if I copy and paste into phpmyadmin it works fine.

The result of the mysql_query function is true.

I've emptied the table so there are no primary key conflicts.

I've put the statement in a try catch and it does not display a exception.

What else can I try?

 

Here's the statement

INSERT INTO `wp_term_relationships` (object_id, term_taxonomy_id, term_order) VALUES (1597,83,0)

 

Works absolute fine if I copy and paste into phpmyadmin. Does not populated the table if run through mysql_query

 

Link to comment
Share on other sites

Are you getting any error messages from your PHP page? The query looks correct and you confirmed it by running it in phpMyAdmin. This sounds like a problem with your PHP, paste it here in

 tags and remove your password from mysql_connect().

Link to comment
Share on other sites

He means to paste it inside [ code ] tags. 

 

Also, are you sure you're in the right database on the right server?  Your PHPMyAdmin instance is probably running on the local MySQl server, the PHP script could be connecting to another server entirely.

 

-Dan

Link to comment
Share on other sites

echo $insert_term_relationship . '<br /><br />';
    	   $result = mysql_query($insert_term_relationship) or die(mysql_error());
    	   echo $result;

 

The result of my echo statement is what I am copy and pasting into phpmyadmin.

$result is always equal to 1.

Link to comment
Share on other sites

I am on the right server. I am running multiple queries. The first query doesn't enter anything despite returning true from

mysql query. The second one inserts correctly. The table has zero rows before running the script so I'm sure what has been entered.

Losing my mind here  :wtf:

INSERT INTO `wp_term_relationships` (object_id, term_taxonomy_id, term_order) VALUES (1597,83,0)

INSERT INTO `wp_term_relationships` (object_id, term_taxonomy_id, term_order) VALUES (1597,77,0)

 

 

 

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.