Jump to content

syntax error, unexpected T_AS


gBase

Recommended Posts

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:
[code]Parse error: syntax error, unexpected T_AS in /sysdocupdate.php on line 1[/code]

Here's my code:

[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);
?>
[/code]

Is it the foreach loop that's the problem?

I'm using this website for my code:

[url=http://www.netadmintools.com/art332.html]http://www.netadmintools.com/art332.html[/url]

Thanks for any help!
Link to comment
https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/
Share on other sites

Check your php.ini file.

register_long_arrays = Off


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


me!
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.)
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:

[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);
?>
[/code]

and here's my error:

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

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!
  • 4 years later...

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.