Hey Everyone,
First post to the forum so go easy on me...
So here's the deal... I am writing the php/mysql for a page that updates my database with the values of a member who's membership details have been edited.
I am having problems getting the values to update into the database. I am not getting any errors so I am kinda stuck at this point....
Let me see if I can give you all the details anyone may need to help on the first try:
Connect to the database (no problems):
//Now we can connect to the Database
$hostname = "localhost"; // Our DB server.
$username = "*******"; // The username for the database.
$password = "*******"; // The password for the username above.
$table = "jos_membership"; // The name of the table we are working with.
$dbname = "cvarcher_members"; // This name of the database the table belongs to.
//MYSQL_CONNECT($hostname, $username, $password) OR DIE("DB connection unavailable");
//@mysql_select_db( "$dbName") or die( "Unable to select database");
$link = mysql_connect($hostname, $username, $password) or die("Could not connect: " . mysql_error());
print ("Connected to $hostname successfully.......");
$select = mysql_select_db($dbname) or die("Could not connect to database: " . mysql_error());
print ("Connected to '$dbname' successfully.......");
Then I define my SQL statement:
//Define the sql udpate query
$update = "UPDATE '".$table."' SET application_date='".$_POST['application_date']."' , applicant_fname='".$_POST['applicant_fname']."' , applicant_lname='".$_POST['applicant_lname']."' , membership_type='".$_POST['membership_type']."' , street1='".$_POST['street1']."' , street2='".$_POST['street2']."' , city='".$_POST['city']."' , state='".$_POST['state']."' , zipcode='".$_POST['zipcode']."' , phone='".$_POST['phone']."' , email='".$_POST['email']."' , econtact_fname='".$_POST['econtact_fname']."' , econtact_lname='".$_POST['econtact_lname']."' , econtact_relationship='".$_POST['econtact_relationship']."' , econtact_phone='".$_POST['econtact_phone']."' , family_fname1='".$_POST['family_fname1']."' , family_lname1='".$_POST['family_lname1']."' , family_age1='".$_POST['family_age1']."' , family_fname2='".$_POST['family_fname2']."' , family_lname2='".$_POST['family_lname2']."' , family_age2='".$_POST['family_age2']."' , family_fname3='".$_POST['family_fname3']."' , family_lname3='".$_POST['family_lname3']."' , family_age3='".$_POST['family_age3']."' , family_fname4='".$_POST['family_fname4']."' , family_lname4='".$_POST['family_lname4']."' , family_age4='".$_POST['family_age4']."' , family_fname5='".$_POST['family_fname5']."' , family_lname5='".$_POST['family_lname5']."' , family_age5='".$_POST['family_age5']."' , family_fname6='".$_POST['family_fname6']."' , family_lname6='".$_POST['family_lname6']."' , family_age6='".$_POST['family_age6']."' , member_bal_prev='".$_POST['member_bal_prev']."' , member_cur_dues='".$_POST['member_cur_dues']."' , member_amt_billed='".$_POST['member_amt_billed']."' , member_amt_paid='".$_POST['member_amt_paid']."' , member_bal_due='".$_POST['member_bal_due']."' , member_status='".$_POST['member_status']."' , member_title='".$_POST['member_title']."' , member_notes='".$_POST['member_notes']."' WHERE ID ='".$_POST['ID']."' LIMIT 1";
You will notice my statement is populated with _POST variables from my form and I know that someone may ask to see what this looks like once it is completed so here is the statement once I have run it through php "echo" with dummy form variables.
$update = " UPDATE 'jos_membership' SET application_date='2008-03-22' , applicant_fname='XXXX' , applicant_lname='XXXX' , membership_type='Family' , street1='2839 Anystreet St.' , street2='' , city='Any City' , state='CA' , zipcode='90210' , phone='80555551212' , email='me@hotmail.com' , econtact_fname='Mary' , econtact_lname='Jane' , econtact_relationship='Wife' , econtact_phone='8055551313' , family_fname1='Alyssa' , family_lname1='Milano' , family_age1='37' , family_fname2='Adam' , family_lname2='Munster' , family_age2='15' , family_fname3='Andrew' , family_lname3='Munster' , family_age3='13' , family_fname4='Test' , family_lname4='Test' , family_age4='12' , family_fname5='Test' , family_lname5='Test' , family_age5='18' , family_fname6='Test' , family_lname6='Test' , family_age6='15' , member_bal_prev='0' , member_cur_dues='160' , member_amt_billed='160' , member_amt_paid='160' , member_bal_due='0' , member_status='Active' , member_title='President' , member_notes='This is a test to see if the update to the database worked and changed the original text that was stored in the database.' WHERE ID ='148' LIMIT 1 ");"
Then lastly, I execute the query
//Execute the query with the udpate
$result = mysql_query($update);
So.... I don't have any errors to show you or tell you about. I think I have my syntax correct, but I am not sure. The only reason I know that I have a problem is that the data isn't updating in the DB when I go and browse the table with phpMyAdmin
Any help anyone could provide would be greatly appreciated.
Thanks,
Rick