gBase Posted October 2, 2006 Share Posted October 2, 2006 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]<?phpforeach($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! Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/ Share on other sites More sharing options...
printf Posted October 2, 2006 Share Posted October 2, 2006 Check your php.ini file.register_long_arrays = OffIf 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! Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/#findComment-102762 Share on other sites More sharing options...
gBase Posted October 3, 2006 Author Share Posted October 3, 2006 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! ;DEDIT: Nevermind, figured it out (was problem on form that submitted to this one.) Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/#findComment-102784 Share on other sites More sharing options...
gBase Posted October 3, 2006 Author Share Posted October 3, 2006 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]<?phpforeach($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! Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/#findComment-102789 Share on other sites More sharing options...
cornelombaard Posted May 3, 2011 Share Posted May 3, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/#findComment-1209997 Share on other sites More sharing options...
Maq Posted May 3, 2011 Share Posted May 3, 2011 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 tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/22809-syntax-error-unexpected-t_as/#findComment-1210003 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.