Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    185
    Thanks
    17
    Thanked 0 Times in 0 Posts

    PHP script wont get contents of MYSQL DB

    Hi

    Does anyone see anything wrong with the below? What it tries to do is get an email address stored in a field called value and then print it out but for some reason the value it returns is empty. The strange thing is that it works when i use anything other then email like if value is firstname it works great and returns the first name and so on with other values like company, last name etc...


    PS The WHERE email=\"$email\" portion of the script is a controller and not the email i am trying to get.


    Thanks

    PHP Code:

        $getcontolcount
    =count($controller);
        
    $controlcount=1;
        
        while(
    $controlcount<=$getcontolcount)
        {
            
    $query "SELECT value FROM imports WHERE email=\"$email\" AND controller=1 AND field=\"$emailfield\" ORDER BY controller";
            
            
    $result mysql_query($query) or die(mysql_error());

              
              while(
    $row mysql_fetch_array($resultMYSQL_ASSOC))
            {
                echo(
    $row['value']);
            }
            
    $controlcount++;
        
         } 
    Last edited by thekevin07; 03-12-2007 at 11:04 AM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Well, since the query works in other situations, then you've got to think it's either the data isn't there, or the query isn't doing what you think it should be doing for the data that is there.

    To troubleshoot, I would stick a "die($query)" statement in right after you build the query text. This will simply echo to the browser the exact query you are running. Then copy/paste that query into an ad-hoc query tool such as PhpMyAdmin, and see what results you get. If the results are just as you expected, then the problem is the PHP code. If not, then the problem is with the query.
    Last edited by Fumigator; 03-12-2007 at 04:18 PM.


  •  

    Posting Permissions

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