Click to See Complete Forum and Search --> : MySQL does not connect to database


rbailer
01-31-2006, 09:42 PM
My hosting company just upgraded my server for me, and everything works fine except for one thing. On one of my sites, i cannot connect to do the database anymore. I did not change anything after the switch, so I don't see why it wouldnt work the same. One clue that i have is that when i tried to ftp something to the file that was calling the database, it said permission denied. I wen't ahead and looked at it's permissions though and they were 644 like every other file.

Here is the error i get when i go to that page. Any help would be awesome!

SELECT * from tblitem where category = Database Error
1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

bathurst_guy
01-31-2006, 09:44 PM
Well then it is actually connecting to the database, its the query that is receiving the error. Can you show us the full actuall query.

rbailer
01-31-2006, 09:51 PM
$TotalPage=PageCount($RECORDSPERPAGE,$CATID);
$squery="SELECT * from tblitem where category = '1' ORDER BY list";
$sresult=query_select($squery,$totalrecord);
$recpos=1;
$LLimit=$RECORDSPERPAGE*($INTPAGENUM-1)+1;
$ULimit=$RECORDSPERPAGE*$INTPAGENUM;
$nav="";
$element=1;

It looks like it doesnt like the ORDER BY part of this query. I read a post that said that during the upgrade my MySQL might have been upgraded, and there is something in here that was allowed in a previous version, but not in this one.

bathurst_guy
01-31-2006, 09:54 PM
try
$squery="SELECT * from tblitem where category = 1 ORDER BY list";

rbailer
01-31-2006, 09:58 PM
Yea that doesn't work either ufortunately. That was actually an error i just made while i was trying to test an actual number instead of the variable to see if that was the issue. The string now reads the way it used to be:

$squery="SELECT * from tblitem where category = '$CATID' ORDER BY list";

bathurst_guy
01-31-2006, 10:02 PM
well what is $CATID? Is it a post or get variable? If so, global variables may now be turned off, and therefore change it to $_POST[CATID] or $_GET[CATID], and aswell, seeing as though it is in a sql, you will need to place { } around it.
eg;
$squery="SELECT * from tblitem where category = '{$_POST[CATID]}' ORDER BY list";

rbailer
01-31-2006, 10:02 PM
Also, the thing is that its not just that specific query. I have different queries running all over the site, and all the ones i have looked at don't work right now! SOOO WIERD.

bathurst_guy
01-31-2006, 10:06 PM
Well it definately sounds like Global Variables are turned off then, which is good cause its a security issue.

rbailer
01-31-2006, 10:07 PM
That global variable didnt work, but also there are a few other variables in that query that are set in some other files I think. I had this particular site created for me, so i don't know exactly where everything is happening, but i think the global variables being turned off might be correct. In that query, there are some variables that are set elsewhere, such as $totalrecord. This is the case for every query on the site I think. How do i turn global variables back on?

bathurst_guy
01-31-2006, 10:09 PM
It will only effect the post, get, session, server variables I think, so any vairables that you have set in your script, eg $foo = 'bar'; will be fine. You can ask the webserver to turn it back on, in which case they are more likely to say no, because its a security measure to have them off. Basically, if we know this is the problem, you will have to modify all your scripts.

rbailer
01-31-2006, 10:11 PM
I upgraded to a v-dedicated server though, so they shouldnt care. I can probably do it in Cpanel.

bathurst_guy
01-31-2006, 10:11 PM
Also check on the form that where catid is being set that the name is in capitals or lowercase, as PHP is case sensative.

bathurst_guy
01-31-2006, 10:12 PM
Its set in the php.ini file located in the server files that you cannot access. There may be a re-write rule though, I'll have a looksy...

rbailer
01-31-2006, 10:14 PM
I can definitely get into the php.ini file because being able to change that was why i upgraded to the v-dedicated. THey have been messing around with it to change some settings for me, so they probably changed that by accident. I just now need to figure out how to get to the php.ini file.

chazzy
02-01-2006, 06:22 AM
Well, not for nothing, but having register_globals turned on isn't a good thing, it's actually a security risk as it makes all forms work via query string and post methods - much easier to crack your site now.