I'm not sure what is causing my error here but the problem is that when i pass in a hidden value from a form into my php page, the php is not getting the values ... here's the code
update.html
-------
update.php
------
update_confirm.php
-------
update_results.php
------
then when i run it all it goes through update.html, update.php, update_confirm.php just fine. when it gets to update_results.php here's the error that i get...
no clue why it's not reading in the table name (the network $network) or the name $name .. but it is reading in the fields that i want to update ..
thanks for any suggestions you may have
If programming were as fun as cycling, then we'd need more bike mechanics.
update.html
-------
Code:
<form action="update.php" method="post" name="update">
<select name="network" >
<option value="AK">Alaska</option>
<option value="CA">California</option>
</select>
<input type="Submit" name="submit" value="Enter Station ">
</form>
update.php
------
Code:
<?php
$db = mysql_connect("###","###","###");
//error statement if database cannot be conencted to
if (!$db) { echo 'Error: Could not connect to the database. Please try again later.'; exit; }
//select the database that we are working withi
mysql_select_db("###",$db);
//create a var name for network to search by submitted by user in delete.html
$network=$_POST['network'];
//display all the records in that table so the user can select which one to delete
$query = "SELECT * FROM $network";
//this line is for troubleshooting - it prints out the query that you submitted to the screen
//print "<br>" . $query . "<br>";
//put the query into a result form and tell it which database to look in
$result = mysql_query($query,$db);
if (!$result) {
echo mysql_error();
}
else {
//put data in a table for formatting reasons
echo "<p><b>Results for the ";
if ($network == 'AK') {echo "Alaska Network:</b></p>";}
elseif ($network == 'CA') {echo "California Network:</b></p>";}
echo "<table><font size=2>";
echo "<tr><td>Name</td><td>###</td><td>###</td><td>###</td><td>asfd</td>f<td>###c</td><td>###</td><td>###</td><td>###</td><td>###</td><td>###</td><td>Network</td></font></tr>\n";
//loop through the table and print all of the information
while ($myrow = mysql_fetch_array($result)){
echo " <font size=2><tr>
<td>$myrow[0]</td>
<td>$myrow[1]</td>
<td>$myrow[2]</td>
<td>$myrow[3]</td>
<td>$myrow[4]</td>
<td>$myrow[5]</td>
<td>$myrow[6]</td>
<td>$myrow[7]</td>
<td>$myrow[8]</td>
<td>$myrow[9]</td>
<td>$myrow[10]</td>
<td>$myrow[11]</td>
<td>
<form action=\"update_confirm.php\" method=\"post\">
<input type=\"hidden\" name=\"name\" value=\"$myrow[0]\">
<input type=\"hidden\" name=\"network\" value=\"$myrow[11]\">
<input type=\"submit\" value=\"Update\">
</form>
<br>
</td>
</tr>
</font>";
}
}
?>
update_confirm.php
-------
Code:
<?php
//connection stuff goes here
//get posted variables from update.php
$name=$_POST['name'];
//other fields here
$network=$_POST['network'];
?>
<form action="update_results.php" method="post" name="insert">
Name: <font color="#0000CC"><?php echo $name; ?></font><br>
Network: <font color="#0000CC"><?php echo $network; ?></font><br>
//THIS IS WHERE IT SEEMS NOT TO BE SUBMITTING VALUES
<input type="hidden" name="name" value="<?php $name; ?>">
<input type="hidden" name="network" value="<?php $network; ?>">
<input type="submit" value="Update Station">
</form>
update_results.php
------
Code:
<?php
//database connetion stuff here
$name=$_POST['name'];
$stuff=$_POST['stuff'];
$network=$_POST['network'];
//put the query into a result form and tell it which database to look in
$query = "UPDATE $network SET stuff='$stuff' WHERE name='$name'";
echo $query, "<br>";
$result = mysql_query($query,$db);
if (!$result) {
echo mysql_error();
}
then when i run it all it goes through update.html, update.php, update_confirm.php just fine. when it gets to update_results.php here's the error that i get...
Code:
UPDATE SET stuff='123' WHERE name=''
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET stuff='123''
thanks for any suggestions you may have
If programming were as fun as cycling, then we'd need more bike mechanics.