Results 1 to 6 of 6

Thread: PHP Debugging help needed...

  1. #1
    Web Monkey MarkB's Avatar
    Join Date
    Nov 2003
    Location
    London, UK
    Posts
    1,783

    PHP Debugging help needed...

    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!
    Last edited by MarkB; 06-08-2004 at 12:54 PM.
    Stepping On Wires - the new blog

  2. #2
    Future AstonMartin driver r2d2's Avatar
    Join Date
    Dec 2003
    Location
    UK
    Posts
    1,608
    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.

  3. #3
    Senior Member chromate's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    2,348
    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.
    Last edited by chromate; 06-07-2004 at 08:01 AM.

  4. #4
    Web Monkey MarkB's Avatar
    Join Date
    Nov 2003
    Location
    London, UK
    Posts
    1,783
    What's a variable scope?
    Stepping On Wires - the new blog

  5. #5
    Senior Member chromate's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    2,348
    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.

  6. #6
    Web Monkey MarkB's Avatar
    Join Date
    Nov 2003
    Location
    London, UK
    Posts
    1,783
    Got it sorted by using a different variable Thanks dudes
    Stepping On Wires - the new blog

Similar Threads

  1. Review: Professional PHP Programming
    By Chris in forum Books
    Replies: 6
    Last Post: 07-17-2013, 05:26 AM
  2. Learning how to create PHP database driven sites online...
    By incka in forum Website Programming & Databases
    Replies: 15
    Last Post: 01-23-2004, 03:18 PM
  3. Google Ads In PHP
    By incka in forum Search Engine Optimization
    Replies: 16
    Last Post: 12-24-2003, 07:52 AM
  4. PHP making my page views smaller
    By incka in forum General Chat
    Replies: 8
    Last Post: 12-22-2003, 05:34 AM
  5. PHP, ODBC, and Unicode compatibilities...
    By Stevens in forum Website Programming & Databases
    Replies: 4
    Last Post: 10-14-2003, 09:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •