PDA

View Full Version : PHP Debugging help needed...



MarkB
06-06-2004, 10:50 AM
I'm using a PHP script to call data from a mysql database, and in turn format it using mysql-driven templates. Now, this was working fine before I moved servers, so my guess is my php syntax isn't compatible with the newer server's php/sql or whatever.

However, a near-identical page works without any problems...

Anyway; here's my code. Can someone help me pinpoint what's wrong?


[code removed]

Used when going to http://www.guitar-shopper.com/cat/23/ (I've left error reporting turned on, however those errors shown also show for the script that works, so I don't think that's the problem...)

As far as I can tell, the second SQL request (asking for product info) is just not giving any results, even though using a request through phpmyadmin DOES gives results, and the category name is being parsed (as shown when I echo it).

Any thoughts? This is driving me bonkers, man!

r2d2
06-07-2004, 04:23 AM
You second 'from' isnt in capitals, not sure if it matters, but I would put it right.

Its also worth printing out your $sql strings to make sure they are coming out as you would expect.

chromate
06-07-2004, 07:50 AM
Most likely something to do with variable scope. Don't really have time at the moment to look at it in detail though, but that may give you a starting point.

MarkB
06-07-2004, 10:25 AM
What's a variable scope? :)

chromate
06-07-2004, 12:34 PM
It has to do with where a variable can be written and read from. For example a variable within a function only has scope within that function ie, it can't be accessed directly external to that function. It's said to be a "local variable" and only has "local scope" within the function. Similarly, you can't access variables external to the function from within the function, unless they're set as a global variable or are accessed using $GLOBALS[<variable name here>];

PHP has tightened up on variable scope in the latest releases, which may be why you suddenly experienced problems when you switched the code to a different server.

MarkB
06-08-2004, 01:00 PM
Got it sorted by using a different variable :) Thanks dudes