Forum Moderators: coopster

Message Too Old, No Replies

Variables Passing but not updating

         

ukgimp

12:11 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The script runs fine on my local machine. I transfer to the remote webserver and it does not. I know the variables are being passed as I printed them out to test it.

I made sure the permissions are set to allow update as well.

I have some very simple sql going on:
mysql_query("UPDATE pages SET accepted = 'y' WHERE id = $var")

The include files collect the variables also.

I have this in one of the includes
$_SERVER['REQUEST_URI']
and I have to request the
$_HTTP_SERVER_VARS['HTTP_HOST']

What can I be missing. This is driving me mad. Works locally, knackers remotely.

ukgimp

1:29 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



do I need some sort of database prefix?

This seems odd as I can select and insert?

coopster

1:35 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Is $var a text string? Try quoting it:

mysql_query("UPDATE pages SET accepted = 'y' WHERE id = '$var'")

ukgimp

1:44 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



done that one. It is a number. The funny thing it is works locally just falls dwon on upload. On the remote other things work.

coopster

1:54 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Don't mean to be too technical, but have to ask, you do have a semicolon at the end of your mysql statement, right? If so, here's how I troubleshoot sql statements, give it a shot and see if anything looks goofy:

$sql = "UPDATE pages SET accepted = 'y' WHERE id = $var";
exit("$sql");
mysql_query($sql);

ukgimp

2:07 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nothing funny there. All looks well. It just does not do the update.

Baffled, this should not be as hard as brain surgery. :)

charlier

2:07 pm on Oct 30, 2003 (gmt 0)

10+ Year Member



Does the mysql_error() function report any errors?

coopster

2:34 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Are you sure you are getting a connection in your mysql_connect() function?

Since you are trying to connect to a different server, maybe you haven't changed your mysql_connect() statement.

Check for errors there and then try running a simple SELECT statement and print the output.

ukgimp

2:38 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry Coop

selects and inserts work fine. I have permissions to allow for UPDATE also of that user. It just appears to be updates.

Cheers

coopster

2:52 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have no clue at this point...table locked?

ukgimp

3:00 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>table locked?

How would I tell that?

ukgimp

3:45 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



solved

Setting the permissions is fine. BUT and heer it is you have to set reload mysql to get them set.

So thanks and another thing learnt

coopster

3:49 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Cool. I was just about to point you to the MySQL Manual [mysql.com]. Glad you got it!

ukgimp

3:52 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your help though. Finding out may well have save my PC's life :) There are 5 story windows nearby dont you know

coopster

3:56 pm on Oct 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



LOL. We've all been there. Sometimes you just need somebody to troubleshoot with, and that's why we come here.

...another pc spared...