SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    SQL Server Query

    Hi all,
    Why doesn't the below print out any value for $num_results? Using SQL Server Database.
    Connection is ok.
    PHP Code:
     // perform query
     
    $query "SELECT * ".
                       
    "FROM training_notes";
     
    $result mssql_query($query);
     
     
    $num_results mssql_num_rows($result);
     echo 
    '<br />RESULTS: '.$num_results.'<br />'
    Thanks.

    Kevin.

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Ireland
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what version of sql server are you using?

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SQL Server 2000

  4. #4
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,878
    Mentioned
    46 Post(s)
    Tagged
    0 Thread(s)
    Hey

    I dnt really know php, but try putting the querystring on one line and without the dot in the middle.

    Just my opinion. Dnt no how php works



  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    kev, there is nothing wrong with the syntax of your query

    SELECT * FROM training_notes

    therefore this isn't a database issue, it's a scripting language issue

    moving thread to php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any ideas why it displays the below error?
    PHP Code:
     // perform query
     
    $query "SELECT * ".
                  
    "FROM training_notes";
     
    $result mssql_query($query) or die('Error performing query'); 

  7. #7
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    training_notes is a new table but the code doesn't seem to see it.

    Why is this? Using Enterprise Manager. Other tables are ok.

    Thanks.

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    try running the query in Query Analyzer
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Member
    Join Date
    Jun 2004
    Location
    kingston
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i would say, check the name of your table against what it is called in the db making sure its the same capitalisation and ensure its an underscore not a hyphen. its time like this that copy and paste are your friend


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
  •