...

View Full Version : I'm getting a Parse Error that I just can't figure out



eww7633
05-15-2008, 03:28 PM
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:



<!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:


$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.

Brandoe85
05-15-2008, 03:31 PM
Always check the code before the error as well - missing semi-colon:
mysql_select_db ("xxxxxxxx_xxxxxx");

PappaJohn
05-15-2008, 03:32 PM
mysql_fetch_row() requires a Resource ID, not the table name.

derzok
05-15-2008, 03:37 PM
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

eww7633
05-15-2008, 04:14 PM
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.

Brandoe85
05-15-2008, 04:17 PM
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

hammer65
05-15-2008, 04:32 PM
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.

tomws
05-15-2008, 06:23 PM
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/function.mysql-affected-rows.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum