JakeSilver Posted July 2, 2008 Share Posted July 2, 2008 I am having trouble getting the info from a automatically created textbox... Basically the text boz is gererated with the name set to its ID.. code is as follows: <?$sectionquery=mysql_query("SELECT * FROM `section` ORDER BY 'id' ASC"); while($data=mysql_fetch_object($sectionquery)){ echo "<p>$data->name<input type='text' value='' name='$data->id' size='4'></p> "; I am retrieving the info int the same way... shown below $numsec=mysql_query("SELECT * FROM `section` ORDER BY 'id' ASC")or die (mysql_error()); while($secdata=mysql_fetch_object($numsec)){ $secid=$secdata->id; $navvalue= $_GET['$secid->id']; mysql_query("UPDATE `thinkweb_advanced`.`section` SET `nav` = '$navvalue' WHERE `section`.`id` =$secid LIMIT 1")or die (mysql_error()); echo "Updated"; However, The info in the textbox is not being added into my database?? any idea? Thanks, Jake Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/ Share on other sites More sharing options...
ag3nt42 Posted July 2, 2008 Share Posted July 2, 2008 i could be wrong but I'm not sure this is written with correct syntax yours: mysql_query("UPDATE `thinkweb_advanced`.`section` SET `nav` = '$navvalue' WHERE `section`.`id` =$secid LIMIT 1")or die (mysql_error()); mine: mysql_query("UPDATE [thinkweb_advanced.section] SET nav=".$navvalue."' WHERE section.id='".$secid."'LIMIT 1")or die (mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-579958 Share on other sites More sharing options...
mbeals Posted July 2, 2008 Share Posted July 2, 2008 his syntax should work. First step in debugging mysql is to echo the query back to STDOUT to make sure it is what you think it is. For this reason, I consider it good practice to structure queries in the form: $query = "My mysql query"; $result = mysql_query($query); So add this to the second file's while loop and verify the final string is correct. echo "UPDATE `thinkweb_advanced`.`section` SET `nav` = '$navvalue' WHERE `section`.`id` =$secid LIMIT 1<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-579963 Share on other sites More sharing options...
ag3nt42 Posted July 2, 2008 Share Posted July 2, 2008 this is off subject but, where is everyone getting such different versions of php syntax... I learned of w3 and php.net you'd think php.net would have alternate syntax written up somewhere. Seems like I'm the only one in this forum that uses that same syntax Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-579981 Share on other sites More sharing options...
JakeSilver Posted July 2, 2008 Author Share Posted July 2, 2008 Mbeals - I have just echoed the query and your right $navvalue has no value which would explain a great deal.. However, I do not know how i am able to retireve the info that is in the textbox any ideas? ag3nt42 - Im sorry if my syntax is lame i taught myself from reading scripts... poorly structured perhaps Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-579992 Share on other sites More sharing options...
ag3nt42 Posted July 2, 2008 Share Posted July 2, 2008 ag3nt42 - Im sorry if my syntax is lame i taught myself from reading scripts... poorly structured perhaps same here I taught myself as well.. no college here I'm not saying its lame I'm just asking where everyone is finding this alternate syntax's Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-580001 Share on other sites More sharing options...
mbeals Posted July 2, 2008 Share Posted July 2, 2008 i learned through practice too. mostly w3 Your issue is $navvalue= $_GET['$secid->id']; php interprets single quotes as string literals, so it is physically looking for the $_GET key named $secid->id and not the dereferenced value. try: $id = secid->id; $navvalue= $_GET[$id]; or $navvalue= $_GET[$secid->id]; and see what happens. Might also be worth adding an echo secid->id; to make sure it is what you think it is. Quote Link to comment https://forums.phpfreaks.com/topic/112908-getting-info-from-textbox/#findComment-580043 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.