cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Go to solution

MYSQL INSERT INTO does not work on one of my servers

So I just moved a website over to Godaddy's servers this week and have spent the whole day trying to get it to work on this one domain. The website loads and most all of the SQL queries run except for "INSERT INTO". It will not insert a single new row into the database (I can UPDATE, DELETE, SELECT with no issues).  Now I thought it might be my code so I took all of the code and copied it over to my other Godaddy server and then ran it under a different web address, and what do you know...it works perfect, inserts anything that I want to, then I took the code from that working server and copied it file-for-file to the other one that wont work and it wont run INSERT INTO queries. Now I spent the last 6 hours with tech support trying everything possible, making an exact image of the website on my other server and then copying all of those files over to this other server but...no dice. Tech support said that it is not on their end but something with my code. Yet it runs on my main server perfectly. Now the only difference between the two is that on my main server I am running it in a subdomain, but that really shouldnt make a difference. It still runs perfectly.

Cache is cleared, etc. 

Would anyone have a solution for why INSERT queries do not run on certain godaddy servers?

Its programmed in PHP, the non working server is running the same version of PHP as the working version.

Note: It uploads images to the server but won't update the database with the image location like it should. (The working server does update the database and works as it should.)

 

Thanks in advance.  Smiley Happy

6 REPLIES 6
Super User III
Super User III

Re: MYSQL INSERT INTO does not work on one of my servers

@WhatDoIKnow 

 

This may sound like an obvious question - but did you reset the database permission on the new server to allow insert to the user - I normally do a grant all, but it seems like it's a permissions issue with MySQL vs something with your code.



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: MYSQL INSERT INTO does not work on one of my servers/?isc=gdcommment

Yeah we added full permissions for my account. Essentially one is a clone of the other. The only difference originally between the 2 was that one ran a newer version of php. But we changed it so both ran the same.
Super User III
Super User III

Re: MYSQL INSERT INTO does not work on one of my servers/?isc=gdcommment

@WhatDoIKnow 

 

A couple of things / suggestions - and you may have already tried these but I'm just troubleshooting here

 

1) Can you run the insert statement via phpMyAdmin and have it work

2) Can you add some debug code to your script to see what if any mysql error might be produced

 

If you post your insert statement that would be helpful as well - It just seems strange especially if it is just a straight copy from your other server - 

 

One other question comes to mind.... are the MySQL versions the same on both servers - again shouldn't matter but just a thought



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Re: MYSQL INSERT INTO does not work on one of my servers/?isc=gdcommment

Yes the statement when run in PHPMyAdmin runs and inserts the data.

 

Now it will upload the pictures to the server, but just not add the required data to the database.

 

So here is my INSERT statement. The Godaddy team kept saying they were getting a syntax error when they ran it on their end which does not seem to be the case when I run it on my other godaddy server. Like I said before, the code for each server is identical, I just copied and pasted over all of the files. There must be one little overlooked item that prevents it from inserting a new row into the database. I can update, delete and select any existing row, just no insert commands. yet my other godaddy server inserts all the data I want using the very same exact code.

Yeah the godaddy tech changed the one version back to 5.x because that initially was the idea that the version was an issue. I had adjusted my code a while ago to use sha1 because the (password_hash) function does not work with the older version but that would not be an issue now since they both run the same code. I am thinking a full reset tonight of mysql and start over to see if that makes a difference.

 

$stmt = $conn->prepare("INSERT INTO attendants(name, picture, picture_thumb, age, body, hair, eyes, sign, license, description, parent_id) VALUES(:name, Smiley Tongueicture_name, :target_thumb_location, :age, :body, :hair, :eyes, :sign, :license, :description, :id)");
$stmt->bindParam(":name", $name);
$stmt->bindParam("Smiley Tongueicture_name", $picture_name);
$stmt->bindParam(":target_thumb_location", $target_thumb_location);
$stmt->bindParam(":age", $age);
$stmt->bindParam(":body", $bodyType);
$stmt->bindParam(":hair", $hair);
$stmt->bindParam(":eyes", $eyes);
$stmt->bindParam(":sign", $sign);
$stmt->bindParam(":license", $license);
$stmt->bindParam(":description", $description);
$stmt->bindParam(":id", $id);
$stmt->execute();

Super User III
Super User III

Re: MYSQL INSERT INTO does not work on one of my servers/?isc=gdcommment

@WhatDoIKnow 

 

The code looks fine (besides for the emojis)  so... a couple of things that come to mind that could affect this

 

1) PHP Variables - If you memory / timeout / max post size is not set high enough

2) Is there anything in the error_log

3) Can you get the insert to work if you just hard code the variables to be static vs  have it be dynamic - just to test - if it passes this, I would then start adding back the variables one by one and perhaps you'll hit where it's not working

I would also test to see if you can insert into another table....

 

One other thought / something to check - Look at the ownership of the actual mysql table files in the file system - perhaps they are owned by root and so via phpMyAdmin it works but via the web user it isn't 

 

Again as you've pointed out if the 2 servers match everything "should" just work, but in talking from personal experience, I tried moving a site between centos 6 and centos7 same PHP / MySQL on both and the centos7 server was giving me errors

 

 



I am a GoDaddy End User - Just Like You
Check out my site! | I currently manage over 300 WordPress Websites
* Please note that I offer free advice on this forum. If you would like personalized help, please contact me. Otherwise, please ask your question in the proper forum so the answer can assist EVERYONE in the community and not just you. Thanks! *

Once your issue is resolved,
please be sure to come back and click accept for the solution

Get Better Support on the Community Boards!
Etiquette When Asking for Help from the Community

Solution

Re: MYSQL INSERT INTO does not work on one of my servers/?isc=gdcommment/?isc=gdcommment

Ugh. Ok, so I very much appreciate the help. And it was a simple fix, EXTREMELY simple fix. My problem was nothing more than a NULL error in one of my table columns. So once it was set to NULL, it worked.
Such a simple fix...haha.