Jump to content

Can't update my table


alexcmm

Recommended Posts

Can someone tell me what's wrong with this code... I always have so much trouble with the updating of tables. I wish I knew what I was doing wrong. by the time I ever get it to work I can't remember which of the 1000 things I did that worked. Here it is, thanks!

*******************************************

<?php
session_start();

$ud_id=$_SESSION['ud_id'];
$ud_status=$_POST['ud_status'];
$ud_attending=$_POST['ud_attending'];
$ud_prefix=$_POST['ud_prefix'];
$ud_firstname=$_POST['ud_firstname'];
$ud_initial=$_POST['ud_initial'];
$ud_lastname=$_POST['ud_lastname'];
$ud_suffix=$_POST['ud_suffix'];
$ud_jobtitle=$_POST['ud_jobtitle'];
$ud_specialty=$_POST['ud_specialty'];
$ud_namebadge=$_POST['ud_namebadge'];
$ud_designation=$_POST['ud_designation'];
$ud_billstatus=$_POST['ud_billstatus'];
$ud_function=$_POST['ud_function'];
$ud_paidby=$_POST['ud_paidby'];
$ud_marketcountry=$_POST['ud_marketcountry'];
$ud_email=$_POST['ud_email'];
$ud_phone=$_POST['ud_phone'];
$ud_fax=$_POST['ud_fax'];
$ud_address1=$_POST['ud_address1'];
$ud_address2=$_POST['ud_address2'];
$ud_city=$_POST['ud_city'];
$ud_state=$_POST['ud_state'];
$ud_zip=$_POST['ud_zip'];
$ud_country=$_POST['ud_country'];
$ud_emergencyname=$_POST['ud_emergencyname'];
$ud_emergencynumber=$_POST['ud_emergencynumber'];
$ud_guest=$_POST['ud_guest'];
$ud_gueststatus=$_POST['ud_gueststatus'];
$ud_guestpaid=$_POST['ud_guestpaid'];
$ud_hotel=$_POST['ud_hotel'];
$ud_roompref=$_POST['ud_roompref'];
$ud_checkin=$_POST['ud_checkin'];
$ud_checkout=$_POST['ud_checkout'];
$ud_dietary=$_POST['ud_dietary'];
$ud_other=$_POST['ud_other'];
$ud_handicap=$_POST['ud_handicap'];
$ud_arrivalmethod=$_POST['ud_arrivalmethod'];
$ud_arrivaldate=$_POST['ud_arrivaldate'];
$ud_arrivalhour=$_POST['ud_arrivalhour'];
$ud_arrivalmin=$_POST['ud_arrivalmin'];
$ud_arrivalairline=$_POST['ud_arrivalairline'];
$ud_arrivalairport=$_POST['ud_arrivalairport'];
$ud_arrivalflnumber=$_POST['ud_arrivalflnumber'];
$ud_departmethod=$_POST['ud_departmethod'];
$ud_departdate=$_POST['ud_departdate'];
$ud_departhour=$_POST['ud_departhour'];
$ud_departmin=$_POST['ud_departmin'];
$ud_departairline=$_POST['ud_departairline'];
$ud_departairport=$_POST['ud_departairport'];
$ud_departflnumber=$_POST['ud_departflnumber'];
$ud_saturday=$_POST['ud_saturday'];
$ud_guestsaturday=$_POST['ud_guestsaturday'];
$ud_cctype=$_POST['ud_cctype'];
$ud_ccnumber=$_POST['ud_ccnumber'];
$ud_ccname=$_POST['ud_ccname'];
$ud_ccexp=$_POST['ud_ccexp'];
$ud_ccaddress=$_POST['ud_ccaddress'];
$ud_cczip=$_POST['ud_cczip'];
$ud_datemod = (date ("l dS of F Y h:i:s A"));

mysql_connect(localhost,username,password);
@mysql_select_db( "database") or die( "Unable to select database");

$query="UPDATE table SET status='$ud_status', attending='$ud_attending', prefix='$ud_prefix', firstname='$ud_ud_firstname', initial='$ud_initial', lastname='$ud_lastname', suffix='$ud_suffix', jobtitle='$ud_jobtitle', specialty='$ud_specialty', namebadge='$ud_namebadge', designation='$ud_designation', billstatus='$ud_billstatus', function='$ud_function', paidby='$ud_paidby', marketcountry='$ud_marketcountry', email='$ud_email', phone='$ud_phone', fax='$ud_fax', address1='$ud_address1', address2='$ud_address2', city='$ud_city', state='$ud_state', zip='$ud_zip', country='$ud_country', emergencyname='$ud_emergencyname', emergencynumber='$ud_emergencynumber', guest='$ud_guest', gueststatus='$ud_gueststatus', guestpaid='$ud_guestpaid', hotel='$ud_hotel', roompref='$ud_roompref', checkin='$ud_checkin', checkout='$ud_checkout', dietary='$ud_dietary', other='ud_$other', handicap='$ud_handicap', arrivalmethod='$ud_arrivalmethod', arrivaldate='$ud_arrivaldate', arrivalhour='$ud_arrivalhour', arrivalmin='$ud_arrivalmin', arrivalairline='$ud_arrivalairline', arrivalairport='$ud_arrivalairport', arrivalflnumber='$ud_arrivalflnumber', departmethod='$ud_departmethod', departdate='$ud_departdate', departhour='$ud_departhour', departmin='$ud_departmin', departairline='$ud_departairline', departairport='$ud_departairport', departflnumber='$ud_departflnumber', saturday='$ud_guestsaturday', guestsaturday='$ud_guestsaturday', cctype='$ud_cctype', ccnumber='$ud_ccnumber', ccname='$ud_ccname', ccexp='$ud_ccexp', ccaddress='$ud_ccaddress', cczip='$ud_cczip', datemod='$ud_datemod' WHERE id='$ud_id'";

mysql_query($query);
echo "<b>Record Updated</b>";
mysql_close();
?>
Link to comment
https://forums.phpfreaks.com/topic/27536-cant-update-my-table/
Share on other sites

Like this??

*******************************
UPDATE table SET status='', attending='', prefix='', firstname='Alex', initial='', lastname='Henley', suffix='BA', jobtitle='', specialty='', namebadge='', designation='Delegate', billstatus='', function='', paidby='', marketcountry='USA', email='[email protected]', phone='512.555.5555', fax='512.555.5555, address1='', address2='', city='', state='', zip='', country='', emergencyname='', emergencynumber='', guest='', gueststatus='', guestpaid='', hotel='', roompref='', checkin='', checkout='', dietary='', other='ud_', handicap='', arrivalmethod='', arrivaldate='', arrivalhour='', arrivalmin='', arrivalairline='', arrivalairport='', arrivalflnumber='', departmethod='', departdate='', departhour='', departmin='', departairline='', departairport='', departflnumber='', saturday='', guestsaturday='', cctype='', ccnumber='', ccname='', ccexp='', ccaddress='', cczip='', datemod='Thursday 16th of November 2006 09:46:35 PM' WHERE id=''Record Updated
Link to comment
https://forums.phpfreaks.com/topic/27536-cant-update-my-table/#findComment-125951
Share on other sites

[quote author=roopurt18 link=topic=115281.msg469381#msg469381 date=1163733299]
Just a side note,

datemod='Thursday 16th of November 2006 09:46:35 PM'

You shouldn't be storing dates in that format if you can help it.
[/quote]

This is what I'm using... what do you suggest?
$ud_datemod = (date ("l dS of F Y h:i:s A"));

Is it better to use something else so you can retrieve info by date? (i.e. sort by date, etc)

Thanks!
Link to comment
https://forums.phpfreaks.com/topic/27536-cant-update-my-table/#findComment-125984
Share on other sites

Create a DATETIME column in your table.  Store the date as 'YYYY-MM-DD HH:MM:SS' format.  If you are storing the current date and time you can use the MySQL [b]NOW()[/b] function.

When you pull the date out, it will be in 'YYYY-MM-DD HH:MM:SS' format, which may not be what you want to store it in.  You can instead use the MySQL function [b]DATE_FORMAT[/b] to format the date to something else for display purposes.
Link to comment
https://forums.phpfreaks.com/topic/27536-cant-update-my-table/#findComment-126277
Share on other sites

[quote author=roopurt18 link=topic=115281.msg469701#msg469701 date=1163789828]
Create a DATETIME column in your table.  Store the date as 'YYYY-MM-DD HH:MM:SS' format.  If you are storing the current date and time you can use the MySQL [b]NOW()[/b] function.

When you pull the date out, it will be in 'YYYY-MM-DD HH:MM:SS' format, which may not be what you want to store it in.  You can instead use the MySQL function [b]DATE_FORMAT[/b] to format the date to something else for display purposes.
[/quote]

ok, two questions regarding this. (keep in mind the n00bie classification on the left)

When I send the db the date what should it look like? This is what I have now:
[b]$ud_datemod = (date ("l dS of F Y h:i:s A"));[/b]

And, how do I "pull out the date"? Is that when I'm pulling info from the db? right now what I have is:
[b]$datemod=mysql_result($result,$i,"datemod");[/b]

does this need to be different? sorry I'm asking you to be so literal.
Link to comment
https://forums.phpfreaks.com/topic/27536-cant-update-my-table/#findComment-126308
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.