Jump to content


Photo

syntax error, unexpected T_AS


  • Please log in to reply
5 replies to this topic

#1 gBase

gBase
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 02 October 2006 - 11:34 PM

Hi, my database application is working great...I'm now trying to implement a feature to allow the user to update the records.  But I'm getting this error:
Parse error: syntax error, unexpected T_AS in /sysdocupdate.php on line 1

Here's my code:

<?php
foreach($HTTP_POST_VARS as $varname => $value)
        $formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("sysops");
$query="SELECT * FROM systemsdoc WHERE UID = \"".$formVars["UID"]."\"";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$formVars = array();
$formVars["manu"]=$row["manu"];
$formVars["model"]=$row["model"];
$formVars["addr"]=$row["addr"];
$formVars["zip"]=$row["zip"];
$formVars["phone"]=$row["phone"];
$formVars["deploy_date"]=$row["deploy_date"];
$formVars["sernum"]=$row["sernum"];
$formVars["assetnum"]=$row["assetnum"];
$formVars["machname"]=$row["machname"];
$formVars["sysversion"]=$row["sysversion"];
$formVars["UID"]=$row["UID"];
mysql_close($db1);
?>

Is it the foreach loop that's the problem?

I'm using this website for my code:

http://www.netadmint...com/art332.html

Thanks for any help!

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 02 October 2006 - 11:55 PM

Check your php.ini file.

register_long_arrays = Off


If your php.ini file looks the same as above then you can use $HTTP_POST_VARS, because the long arrays are not filled. you can turn this On, but I recommend you don't, just where ever you have $HTTP_POST_VARS, change it to use the newer SUPER GLOBAL $_POST


me!

#3 gBase

gBase
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 03 October 2006 - 12:43 AM

Great!  That fixed that problem...
however, now the script runs but the text boxes don't have the values from the ID strings that I passed to them on the previous page...they are blank. 
In $formVars do I have to change the row to the # row that my values actually have (tried this and it didn't seem to work)?  And/or do I have to put that row # anywhere in the form values(hacked around a little with this too but didn't seem to work either)? 
Thanks again!  ;D

EDIT: Nevermind, figured it out (was problem on form that submitted to this one.)

#4 gBase

gBase
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 03 October 2006 - 01:14 AM

New problem: the script that the previous script uses to update the table is giving me an error (weird because it worked before):

Here's my code:

<?php
foreach($HTTP_POST_VARS as $varname => $value)
        $formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("sysops");
echo "Record updated<br><a href=\"sysdocupdate.html\">click here</a> to update another record<br>";
$query="UPDATE systemsdoc set ".
"manu= \"".$formVars["manu"]."\",".
"model= \"".$formVars["model"]."\",".
"addr= \"".$formVars["addr"]."\",".
"zip= \"".$formVars["zip"]."\",".
"phone= \"".$formVars["phone"]."\",".
"deploy_date= \"".$formVars["deploy_date"]."\",".
"sernum= \"".$formVars["sernum"]."\",".
"assetnum= \"".$formVars["assetnum"]."\",".
"machname= \"".$formVars["machname"]."\",".
"sysversion= \"".$formVars["sysversion"].
"\" WHERE UID = \"".$formVars["UID"]."\"";
mysql_query($query);
mysql_close($db1);
?>

and here's my error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /postdocupdate.php on line 12

EDIT: Nevermind, figured it out -- took out
echo "Record updated<br><a href=\"sysdocupdate.html\">click here</a> to update another record<br>";
and put that message into the HTML instead.  The form works perfectly.  Thanks!

#5 cornelombaard

cornelombaard
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 03 May 2011 - 06:26 PM

I also get the error and here is my code:

<html>
<head>
</head>
<body>
<?php

//Open adatabse connetcion
$connect = mysql_connect("localhost", "root");

//Select db
mysql_select_db("winestore",$connection);

$result = mysql_query ("select * from wine", $connection);

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
forech ($row as $attribute)
print "{$attribute}";
print /n;
}
?>
</body>
</html>

Please could you tell me what the T_AS means?

#6 Maq

Maq
  • Administrators
  • Advanced Member
  • 9,410 posts
  • LocationPennsylvania, USA

Posted 03 May 2011 - 06:34 PM

In case you didn't notice, this thread is from October 02, 2006.  Please don't revive old threads.  If you have your own problem, start your own thread.  Also, use [code][/code] tags around your code.
tjmothy
ini_set ("display_errors", "1");
error_reporting(E_ALL);




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users