Jump to content

Would a change of server affect SOME MySQl queries and not others?


Go to solution Solved by vozzek,

Recommended Posts

Hi all,

 

Today I switched servers.  I got a Hostgator Basic Dedicated server, and their migration team moved everything over for my website - including the MySQL database - from their congested shared servers to my new one.

 

I went to my registrar and changed the DNS entries to point to the new private nameservers.  Accessed the CPanel, saw the files, was able to modify them and see the changes at the url level.  All looked good.

 

Now, here's what's weird: SOME of the pages of my site run the MySQL queries just fine.  Some do not.  For example, I have a page called "kids rugs" that shows a few hundred rugs pulled straight from my database.  Each shows the photo, the name, and the price.  But when you click on an individual rug, and it takes you to the detail page?  NO data of any kind is showed (no photo, no description, no price, etc...)

 

The second page is running the same type of query as the first.  It's a SELECT * FROM tbl_name WHERE category = 'rugs'.  The table is the same, the database is the same, and the connection script is the same.  But one page shows results from the inquiry where the other does not.

 

There are lots of other pages on my site that refuse to run MySQL inquires as well.  These were all inquiries that worked flawlessly on the old shared server, but don't work on the new dedicated one (both servers are Linux).

 

My question is this: Do you think this has anything to do with DNS, non-propagation, etc?  I'm tempted to say "oh, this will resolve itself in 24-48 hours", but then again, it doesn't make much sense that a MySQL query would connect and work correctly on one page, and not show any results on others.

 

Any ideas?  Thanks in advance for the help!

Edited by vozzek

if the page is being displayed at all, but the data is missing, it's something to do with the code on the page or with the GET parameters in the links you are producing.

 

what have you done to pin down at what point your code and data are doing what you expect and at what point they are not? are the links correct? are there any php detected errors when you turn php's error reporting full on? what does your error checking logic in your code tell you?

 

if you want us to help. you will need to post the relevant code needed to reproduce the problem so that someone could see what it is supposed to be doing to be able to suggest possible things to try to determine why it isn't working.

Okay, I think I've pinpointed the problem.

 

In the past, I've plucked variables from the previous page without using $_GET.  For example,

if ($RecordID) {
$sql = "SELECT * FROM inventory
		WHERE id = $RecordID";
$result = mysql_query($sql) or die(mysql_error());

Now, it only works if I first do this:

$RecordID = $_GET["RecordID"];

if ($RecordID) {
$sql = "SELECT * FROM inventory
		WHERE id = $RecordID";
$result = mysql_query($sql) or die(mysql_error());

The version of MySQL I'm on now is 5.5.32

The version of MySQL on the old server was 5.5.30-29.3

 

So perhaps the newer version requires me to $_GET all the variables I pass (with parameter passing), or $_POST all the variables I receive from a form submit?  If so I'm going to need to change a bunch of code.

 

I know my original work (plucking the variables seemingly from thin air) is bad programming.  But when I wrote the system years ago I had much less knowledge.

  • Solution

Ok, this was a php issue.  The php.ini file (of my new version) had the register_globals value set to OFF.  It needed to be ON, based on my sloppy programming (non-use of $_POST).  For now I was able to turn it on, and all my queries work on all pages.

 

Sorry for this being in the wrong spot, but I honestly thought it was a MySQL issue.  Thanks for the help!

register_globals have been removed in php5.4. so, time to start fixing your code to use the $_GET, $_POST, $_FILES, $_COOKIE, and $_SESSION superglobal arrays, that were introduced in php4.2 (in the year 2002) as replacements for what the register_globals hack did to php.

Edited by mac_gyver
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.