SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: PHP SQL result problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP SQL result problem

    i have the following code:

    PHP Code:
    $getunitid = @mysql_query("SELECT unitid FROM units WHERE name = '$newingname'"); 

                            if(!
    $getunitid
                            { 

                                    echo
    '<p>fail ' mysql_error() . '</p>'

                            } 

                            while (
    $row mysql_fetch_array($getunitid)) 
                            { 

                                    
    $unitid $row['unitid']; 

                                    echo
    "test ok!"
                                    echo
    "$unitid";  
                            
                            } 
    what this code should do is run a select statement and then pass the output to a variable and display it.
    The query runs fine as fail is not outputted. however the next part is the problem. test ok is not out put. therefore i think there must be something wrong with my statement but i dont know what. can anyone heklp?
    thanks[/php]

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    14,358
    Mentioned
    64 Post(s)
    Tagged
    1 Thread(s)

    error suppression

    Try running the query without the error suppression, the "@"
    It may be that $getunitid is something, just not what you think it should be.

  3. #3
    SitePoint Wizard wheeler's Avatar
    Join Date
    Mar 2006
    Location
    Gold Coast, Australia
    Posts
    1,369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it returning 0 rows?
    Studiotime - Time Management for Web Developers
    to-do's, messages, invoicing, reporting - 30 day free trial!
    Thomas Multimedia Web Development

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
  •