Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'
I am trying to build a string of code dynamically from the database so that when I update my database structure, I won't have to modify the addserver.php page. The part shown below should dynamically build the form portion of my page. Below this code is the static version of the code that I'm trying to mimic dynamically... PLEASE HELP!
PHP Code:
$dbtable="main";
mysql_select_db($dbname);
$querymain = mysql_query("select * from " . $dbtable);
$i=0;
$headers="";
$svalues="";
if (!$querymain)
{
die("All Records Query in " . $dbtable . " failed: " . mysql_error());
}
while ($i < mysql_num_fields($querymain))
{
$meta = mysql_fetch_field($querymain, $i);
if ($meta->name <> "sid")
{
if ($i <> 0)
{
$headers=$headers . ", $meta->name";
$svalues=$svalues . ", %s";
// =============================================
// The line immediately below this is the one giving me the error
// =============================================
$sqlvalues=$sqlvalues . ", GetSQLValueString($_POST['$meta->name'], \"$meta->type\")";
}
else
{
$headers="$meta->name";
$svalues="%s";
// ==============================================
// I assume the following line will do the same thing once it gets
// passed the line above.
// ==============================================
$sqlvalues="GetSQLValueString($_POST['$meta->name'], \"$meta->type\")";
}
$i++;
}
else
{
$i++;
}
}
Static version of the code...
PHP Code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO main (sid, servername, manufacturer, model, type, cpuqty, cpuspeed, phymem, totaldisk, os, sp, builtby) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['sid'], "int"),
GetSQLValueString($_POST['servername'], "text"),
GetSQLValueString($_POST['manufacturer'], "text"),
GetSQLValueString($_POST['model'], "text"),
GetSQLValueString($_POST['type'], "text"),
GetSQLValueString($_POST['cpuqty'], "int"),
GetSQLValueString($_POST['cpuspeed'], "text"),
GetSQLValueString($_POST['phymem'], "text"),
GetSQLValueString($_POST['totaldisk'], "text"),
GetSQLValueString($_POST['os'], "text"),
GetSQLValueString($_POST['sp'], "text"),
GetSQLValueString($_POST['builtby'], "text"));
|