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
https://forums.phpfreaks.com/topic/232805-mysql-insert-not-working/
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

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.

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)

 

 

 

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.