nueamin Posted November 22, 2009 Share Posted November 22, 2009 Thank You in Advance. I am rather frustrated at this juncture. Ive spent hours trying to work this one out. I also apologize completely for any of my poor coding standards. I would say i am self taught but I am actually learning off of forums like these. I have checked and rechecked the user name and password and it has all permissions. The echo $query produces a line which runs in the MySQL query window flawlessly. Is there something I am doing wrong or something I should look into. Thank You everyone for your time and help. Oh yea. What is wrong? The data that was input via form is not being input into the database, although the query echo shows the data in the string. $db_username="nottelling"; $db_password="reallynottelling"; $database="realmof2_profiles"; $cfirst_name=$_POST['ud_first_name']; $cmiddle_init=$_POST['ud_middle_init']; $clast_name=$_POST['ud_last_name']; $ce_mail=$_POST['ud_e_mail']; $cphone=$_POST['ud_phone']; $cstreet_ad=$_POST['ud_street_ad']; $ccity=$_POST['ud_city']; $cstate=$_POST['ud_state']; $czipcode=$_POST['ud_zipcode']; mysql_connect(localhost,$db_username,$db_password); $query = sprintf("UPDATE contactinfo SET first_name='$cfirst_name', middle_init='$cmiddle_init', last_name='$clast_name', e_mail='$ce_mail',phone='$cphone', street_ad='$cstreet_ad', city='$ccity', state='$cstate', zipcode='$czipcode' WHERE user_id='$userid'"); echo $query; mysql_query($query); mysql_close(); echo ' </div>'; Link to comment https://forums.phpfreaks.com/topic/182460-debugging-assistance/ Share on other sites More sharing options...
dbillings Posted November 22, 2009 Share Posted November 22, 2009 Try adding the mysql_error() function like I've written below. It will print a database error in your web browser when you try to run the code. $db_username="nottelling"; $db_password="reallynottelling"; $database="realmof2_profiles"; $cfirst_name=$_POST['ud_first_name']; $cmiddle_init=$_POST['ud_middle_init']; $clast_name=$_POST['ud_last_name']; $ce_mail=$_POST['ud_e_mail']; $cphone=$_POST['ud_phone']; $cstreet_ad=$_POST['ud_street_ad']; $ccity=$_POST['ud_city']; $cstate=$_POST['ud_state']; $czipcode=$_POST['ud_zipcode']; $link = mysql_connect(localhost,$db_username,$db_password); $query = sprintf("UPDATE contactinfo SET first_name='$cfirst_name', middle_init='$cmiddle_init', last_name='$clast_name', e_mail='$ce_mail',phone='$cphone', street_ad='$cstreet_ad', city='$ccity', state='$cstate', zipcode='$czipcode' WHERE user_id='$userid'"); echo $query; mysql_query($query) or die mysql_error($link); mysql_close(); echo ' </div>'; Link to comment https://forums.phpfreaks.com/topic/182460-debugging-assistance/#findComment-962925 Share on other sites More sharing options...
Errant_Shadow Posted November 22, 2009 Share Posted November 22, 2009 What are you actually trying to do here? And what is it doing instead? (Are you trying to insert a new field or update an existing field?) Try this after running the query, but before you close the connection: echo $mysql_error(); Link to comment https://forums.phpfreaks.com/topic/182460-debugging-assistance/#findComment-962927 Share on other sites More sharing options...
nueamin Posted November 22, 2009 Author Share Posted November 22, 2009 No database selected - returned as my error. aha seem to be getting somewhere. (I am trying to update an existing field Errant_Shadow) Link to comment https://forums.phpfreaks.com/topic/182460-debugging-assistance/#findComment-962934 Share on other sites More sharing options...
nueamin Posted November 22, 2009 Author Share Posted November 22, 2009 Thank you very much. Your speedy probes helped me mighty quickly. All I needed was to select the database. Thank You. I appreciate it. Link to comment https://forums.phpfreaks.com/topic/182460-debugging-assistance/#findComment-962937 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.