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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm getting a Parse Error that I just can't figure out

    I get the following error when I try to run this page:

    Parse error: syntax error, unexpected T_VARIABLE in /home/the8c53c/public_html/v2/awardedit.php on line 12

    Here is the actual PHP code:

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><head><title>17th Airborne Duty Roster Edit</title></head>
    <body bgcolor="#000000" text="#FFFFFF" BODY LINK="#FFFFFF" VLINK="#FFFFFF" ALINK="#FFFFFF">

    <?php

    // Connect to the database
    $dbh=mysql_connect ("localhost""xxxxxxxx_xxxxxx""xxxxxxxxxx") or die ('I cannot connect to the database because: ' mysql_error());
    mysql_select_db ("xxxxxxxx_xxxxxx")

    // Select the Users
    $temp mysql_query("SELECT COUNT(*) FROM nuke_users");
    $temp mysql_fetch_row("nuke_users");
    $numusers $temp[0];

    // Set the values passed into variables
    $pagestep $_POST['pagestep'];
    $usernum $_POST['usernum'];
    $submitpage $_POST['submitbutton'];

    // Award Variables
    $moh $_POST['moh'];
    $dsc $_POST['dsc'];
    $ddsm $_POST['ddsm'];
    $ss $_POST['ss'];
    $dssm $_POST['dssm'];
    $lom $_POST['lom'];
    $solmed $_POST['solmed'];
    $bs $_POST['bs'];
    $ph $_POST['ph'];
    $dmsm $_POST['dmsm'];
    $msm $_POST['msm'];
    $jscm $_POST['jscm'];
    $acm $_POST['acm'];
    $jsam $_POST['jsam'];
    $aam $_POST['aam'];
    $agcm $_POST['agcm'];
    $adm $_POST['adm'];
    $afem $_POST['afem'];
    $gwotex $_POST['gwotex'];
    $gwotser $_POST['gwotser'];
    $afsm $_POST['afsm'];
    $tfhcm $_POST['tfhcm'];
    $hsm $_POST['hsm'];
    $ovsm $_POST['ovsm'];
    $ncopdr $_POST['ncopdr'];
    $asr $_POST['asr'];
    There is obviously more to the code, but it's very long. Line 12 is:

    PHP Code:
    $temp mysql_query("SELECT COUNT(*) FROM nuke_users"); 
    I just can't figure out what is causing my error, and I would appreciate any help.

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Always check the code before the error as well - missing semi-colon:
    mysql_select_db ("xxxxxxxx_xxxxxx");

  • #3
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    mysql_fetch_row() requires a Resource ID, not the table name.

  • #4
    Regular Coder
    Join Date
    May 2008
    Location
    Ohio
    Posts
    231
    Thanks
    3
    Thanked 21 Times in 21 Posts
    What Brandoe said - you missed a semicolon on the line above. It assumed that line 12 was part of line 11 since there was no semicolon. Hence, the unexpected T_VARIABLE

  • #5
    New to the CF scene
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow, thanks, you are absolutely right. I can't believe I missed that. But PappaJohn is also correct, when I fix my parse error I get a

    "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/the8c53c/public_html/v2/awardedit.php on line 13"

    just like he said I would. I honestly don't know how to fix that. I'm not sure what resource ID to use, since I need the entire nuke_users table.

  • #6
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    mysql_query returns a resource, look at the example on mysql_fetch_row as well:
    http://us2.php.net/mysql_query
    http://us3.php.net/mysql_fetch_row

  • #7
    Regular Coder
    Join Date
    Dec 2007
    Location
    Nebraska
    Posts
    113
    Thanks
    0
    Thanked 2 Times in 2 Posts
    All the MySQL functions return a value that evaluates to false if something goes wrong. You will have far fewer errors if you use that fact to control the flow of your application. Otherwise, you have the potential to select a database for a connection that was never made, run a query on a database that was never selected, or attempt to retrieve data from a recordset that was never retrieved. It's a lot more code to do that, but you simply can't count on the database code working every time.
    Deliver yesterday, code today, think tomorrow.

  • #8
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by hammer65 View Post
    All the MySQL functions return a value that evaluates to false if something goes wrong.
    Though quite common, it's not true in all cases. One (the only?) example: http://us3.php.net/manual/en/functio...ected-rows.php


  •  

    Posting Permissions

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