Re: [PHP] update mysql from php web page
Daniel Clark [EMAIL PROTECTED] wrote on 04/06/2004 03:27:34 PM: I think you need a WHERE clause for the UPDATE, otherwise it will update ALL the records. e.g. WHERE OwnerName='$result' Then perhaps a redirect to another page. Thanks for the reminder. I set that, and found the problem that caused the page to not load at all - no closing double-quote on the update statement. Now the page loads properly but when I press the submit button nothing happens, it's a dead button. -- if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') where OwnerName = $OwnerName; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? ... lots of code ... pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address', OwnerCity='$city',OwnerState='$state',OwnerZip='$zip', OwnerCountry='$country',DateInstalled='$DateInstalled', DealerName='$Dealer',DealerStreet='$DealerAddress', DealerCity='$DealerCity',DealerState='$DealerState', DealerZip='$DealerZip',DealerCountry='$DealerCountry', Model='$Parts',SN='$PartsSN',VesselType='$vesseltype', VesselLength='$length',InstalledOn='$construction', VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
For the submit button to work it has to be in a form. FORM ACTION=blah_blah.php METHOD=post INPUT TYPE=submit /FORM Hope this helps. Daniel Clark pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Daniel Clark [EMAIL PROTECTED] wrote on 04/07/2004 10:17:36 AM: For the submit button to work it has to be in a form. FORM ACTION=blah_blah.php METHOD=post INPUT TYPE=submit /FORM Hope this helps. Daniel Clark Of course, I didn't notice I left that line out of my code, although I did remember to put in the closing form tag. But, unfortumately, the update is not executed. The form button works, and it appears to do what it should, but the data is not changed. I changed the form method to get so I could see what is being passed and everything there is fine, but at the end of the url I see this- url...stuff...submit=Update+Data Is this correct? What else can I do to see what was passed to the database (if anything)? -- Chip pcenterinput type=submit name=submit value=Update Data/center/p ... more code ... /table ? endif; ? /body /html - I don't see any reason for the submit button to not work at all. What should I look for now? Thanks for the help, Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Something I like to do during troubleshooting is to have the page display the SQL statement I'm processing. Something like: print sql_query ; That was I can verify all the parameters are correct. Do you have autocommit ON? Or need to pass a commit statement? Daniel Clark Of course, I didn't notice I left that line out of my code, although I did remember to put in the closing form tag. But, unfortumately, the update is not executed. The form button works, and it appears to do what it should, but the data is not changed. I changed the form method to get so I could see what is being passed and everything there is fine, but at the end of the url I see this- url...stuff...submit=Update+Data Is this correct? What else can I do to see what was passed to the database (if anything)? -- Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] update mysql from php web page
I have an existing web page that pulls some data and displays it in form input fields. I would like to add the ability to edit those fields and submit the changes to the server, but have been unsuccessful. What bit of code do I need to add to the existing code? This is the existing code to display the info -- $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? What am I doing wrong? Thanks, -- Chip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
I think you need a WHERE clause for the UPDATE, otherwise it will update ALL the records. e.g. WHERE OwnerName='$result' Then perhaps a redirect to another page. I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] update mysql from php web page
Chip Wiegand wrote: I have an existing web page that pulls some data and displays it in form input fields. I would like to add the ability to edit those fields and submit the changes to the server, but have been unsuccessful. What bit of code do I need to add to the existing code? This is the existing code to display the info -- $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); I probably need to use if(isset($submit)): and an update statement, but my attempt just causes the web page to display completely blank. This is what I tried - if(isset($submit)): $query1 = update warranty set VesselName='$vessel',OwnerName='$owner',OwnerStreet='$address',OwnerCity='$city',OwnerState='$state',OwnerZip='$zip',OwnerCountry='$country',DateInstalled='$DateInstalled',DealerName='$Dealer',DealerStreet='$DealerAddress',DealerCity='$DealerCity',DealerState='$DealerState',DealerZip='$DealerZip',DealerCountry='$DealerCountry',Model='$Parts',SN='$PartsSN',VesselType='$vesseltype',VesselLength='$length',InstalledOn='$construction',VesselTypeOther='$vesseltypeother') ; $result1 = mysql_query($query1); mysql_query($query1); else: $query = select * from warranty WHERE OwnerName='$result'; $results = mysql_query($query); $row = mysql_fetch_array($results); ? What am I doing wrong? Thanks, -- Chip register_globals is probably off echo out the query to see if your variables are populated. -- By-Tor.com It's all about the Rush http://www.by-tor.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php