ianhaney50 Posted June 30, 2015 Share Posted June 30, 2015 Hi I have now made the project site I am working on much simpler than before and now got all the fields in one form and added to one dbtable I have got the profile.php page working so it displays all the data from the users table and renewal table for the dates to display to display Now I am trying to make a edit-profile.php page which I have made and put all the coding and put the markup at the bottom and the php above it but for some reason the current data is not displaying within the form fields I have done a var_dump on the query and outputs the following string(346) "SELECT u.id , name , email , address1 , address2 , town , county , postcode , telnumber , mobnumber , model , numplate , DATE_FORMAT(renewal_date, '%e %M %Y') as datedue FROM users u INNER JOIN renewal USING (id) INNER JOIN item USING (item_id) WHERE id='23'" so then did a var_dump on just on the one variable var_dump($name); and that outputted the following string(9) "Ian Haney" so seems to connecting to the db and retrieving the data so not sure why is not displaying the current data within the form, all the fields are the same as the db etc. the link to the pastebin coding is below http://pastebin.com/UUSp0wgZ Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/ Share on other sites More sharing options...
scootstah Posted June 30, 2015 Share Posted June 30, 2015 If I fudge some data in, your script works for me. Did you try looking at the page source to see if you have some weird HTML? Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515312 Share on other sites More sharing options...
ianhaney50 Posted June 30, 2015 Author Share Posted June 30, 2015 Hmm weird I looked at the page source and did not see any weird HTML or anything? Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515314 Share on other sites More sharing options...
ianhaney50 Posted June 30, 2015 Author Share Posted June 30, 2015 done it with the following coding in the pastebin link http://pastebin.com/td96Gey0 I just got to test it now to make sure it updates Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515315 Share on other sites More sharing options...
mac_gyver Posted June 30, 2015 Share Posted June 30, 2015 your form code is not using the variables that you assigned values to in the loop. in fact, why are you looping to retrieve one row. if you eliminate the loop, just fetch the row from the database, and forget about all the assignment statements, your code will work, because the form code is using the $row[...] variables that the fetch statement would populate. if you are not getting any php errors, i seem to recall that php changed at some point so that accessing an associative array index on a null/false value doesn't throw undefined index error messages. Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515316 Share on other sites More sharing options...
ianhaney50 Posted June 30, 2015 Author Share Posted June 30, 2015 I have noticed one issue as well, it's the dates are being outputted the same, the coding is in the following pastebin link http://pastebin.com/8iTenNmM I took the loop out, well think I have Is it ok to check the coding? Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515319 Share on other sites More sharing options...
mac_gyver Posted June 30, 2015 Share Posted June 30, 2015 if you mean the three dates near the end of your form, that you are using the same variable to populate, because there's only one date field being selected in your query? i would say the problem is because you are not selecting three different dates in your query. Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515326 Share on other sites More sharing options...
ianhaney50 Posted July 1, 2015 Author Share Posted July 1, 2015 (edited) I now changed it to the following <label>Car Tax Renewal Date :</label> <input type="text" id="datepicker" name="tax" required="required" placeholder="Please Enter your Car Tax Renewal Date" value="<?php echo $row['tax'];?>" /> <br /><br /> <label>MOT Renewal Date :</label> <input type="text" id="datepicker2" name="mot" required="required" placeholder="Please Enter your Car MOT Renewal Date" value="<?php echo $row['mot'];?>" /> <br /><br /> <label>Insurance Renewal Date :</label> <input type="text" id="datepicker3" name="insurance" required="required" placeholder="Please Enter your Car Insurance Renewal Date" value="<?php echo $row['insurance'];?>" /> that gives me the following errorNotice: Undefined index: tax in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 128I got the following in, if I change datedue on them lines to the individual ones so insurance, tax, mot, I get more errors $insurance = $row['datedue']; $tax = $row['datedue']; $mot = $row['datedue']; so it becomes $insurance = $row['insurance']; $tax = $row['tax']; $mot = $row['mot']; the errors I get then are belowNotice: Undefined index: insurance in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 85 Notice: Undefined index: tax in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 86 Notice: Undefined index: mot in /home/sites/broadwaymediadesigns.co.uk/public_html/sites/the-tax-elephants/edit-profile.php on line 87 Edited July 1, 2015 by ianhaney50 Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515343 Share on other sites More sharing options...
scootstah Posted July 1, 2015 Share Posted July 1, 2015 Look at your query. You are not selecting any columns with the names "insurance", "tax", or "mot". Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515359 Share on other sites More sharing options...
mac_gyver Posted July 1, 2015 Share Posted July 1, 2015 and as someone already mentioned, your code isn't using, nor does it need, the $variable = $row[index_name]; ...assignment statements. the time you spent putting those in, and now in changing them, isn't accomplishing anything, because your code isn't using those assigned variables and the only way you wouldn't know this is if you aren't looking at what you are doing. at this point, i don't think you are even looking at your code, just throwing random things against the wall to see if any of it sticks, and then dumping it on help forum(s) to get someone to put the code together the correct way for you. that's not you doing or learning programming. that's randomly trying things and almost never results in code that works. 1 Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515371 Share on other sites More sharing options...
scootstah Posted July 1, 2015 Share Posted July 1, 2015 at this point, i don't think you are even looking at your code, just throwing random things against the wall to see if any of it sticks, and then dumping it on help forum(s) to get someone to put the code together the correct way for you. that's not you doing or learning programming. that's randomly trying things and almost never results in code that works. I have to agree. It seems like you're in a bit over your head. You need to actually understand the things you are typing into your editor, and not just copy/pasting things that people told you should work. Quote Link to comment https://forums.phpfreaks.com/topic/297124-edit-profile-php/#findComment-1515373 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.