[CS-FSLUG] another sql qustions

David McGlone d.mcglone at att.net
Sat Dec 27 14:53:12 CST 2008


On Friday 26 December 2008 6:13:54 pm Frank Bax wrote:
<snip>

Check this out, $var_dump is echoing back the changes that were made to the 
form after the submit button is pressed, it seems everything is working except 
it is not getting inserted into the database. Here's the new code and at the 
bottom is what $var_dump dumps to the page. note: pageID is just a field that 
has what page number the row appears on, and subheaderTextID is the 
auto_incremented identifier, which I should have left it as plain ol' id.

<?php
echo var_dump($_POST);


$query = "UPDATE workshop subheaderText SET NULL,
        subheaderText='".$_POST['subheaderText']."',
        headerText='".$_POST['headerText']."',
	page='".$_POST['pageID']."'
        WHERE subheaderTextID='".$_POST['subheaderTextID']."'";

$query2= "SELECT * FROM subheaderText WHERE subheaderTextid=1";
$result2= @mysql_query($query2);
echo "<form name='subheader' action='$_SERVER[PHP_SELF]' method='POST'>";
while ($row=mysql_fetch_array($result2)){

echo "<input type=text name='subheaderTextID' size='30' value='".
$row['subheaderTextID']."'>ID<br>";
echo "<input type=text name='page' size='10' value='".
$row['page']."'>page<br>";
echo "<input type=text name='subheaderText' size='30' value='".
$row['subheaderText']."'>subheader<br>";
echo "text <textarea name='headerText' cols='50' rows='15' />'".
$row['headerText']."'</textarea><br>";


}
echo '<input type="submit" name="submit" value="update" /><br>';
echo '</form><br>';

Output of var_dump:

array(5) { ["subheaderTextID"]=> string(1) "1" ["page"]=> string(1) "2" 
["subheaderText"]=> string(17) " using MySQL" ["headerText"]=> string(629) 
"Not practicing how to use MySQL.\'" ["submit"]=> string(6) "update" }

It got all the form fields correct, just didn't put the changes into the db. I 
also added NULL to the update query for the id field that is auto_incremented.

-- 
David M.
http://www.dmcentral.net




More information about the Christiansource mailing list