jordan443 Posted April 3, 2013 Share Posted April 3, 2013 (edited) I have a website where a user can create an account and log in to it (Made it off of a template). This part works fine but I want to add a new section to the mySQL table. I want this section to store a link submitted in an input box. I created a new section called 'background'(The purpose is for users to set their own background). All of the linking to the database is done. The form that I made to post the link is on line 370. The place I would like to echo background is around line 278 How would I apply this to my current code? index-4.php You can see it live at: jordan.comze.com Edited April 3, 2013 by jordan443 Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/ Share on other sites More sharing options...
remenissions Posted April 3, 2013 Share Posted April 3, 2013 (edited) Your issue is line 283, you can't do " '$background' ". You could try " '{$background}' ". Or to make it simpler abandon the whole switching html to php. Keep it in php echo "<img src='".$background."'>" or echo "<img src='{$background}' />" That is assuming you have the background link in your $_SESSION already, I'm not sure if you're asking how to save it to the database or not but if so something like mysql_query("INSERT INTO Account (Background) Values ('{$Background}')"); Then you can access it later, is that what you are asking? Also I noticed you are saving your passwords with md5, if you're expecting other users besides a few close friends. You should look into a different password hashing and use salts. Edited April 3, 2013 by remenissions Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422573 Share on other sites More sharing options...
jordan443 Posted April 3, 2013 Author Share Posted April 3, 2013 (edited) All of the background related lines in the code I posted are for temporarily setting the background using POST. I haven't done anything between the background and mySQL (I haven't linked 'background' to the mySQL database) Edited April 3, 2013 by jordan443 Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422733 Share on other sites More sharing options...
jordan443 Posted April 3, 2013 Author Share Posted April 3, 2013 (edited) I added in what you suggested on line 113 and changed the name of the input box to 'background'. It doesn't seem to be working. Right now I just want to get the url of the image saved to the database. Heres what I did to line 113: mysql_query(" INSERT INTO tz_members(usr,pass,email,regIP,dt,background) VALUES( '".$_POST['username']."', '".md5($pass)."', '".$_POST['email']."', '".$_SERVER['REMOTE_ADDR']."', NOW(), '".$_POST["background"]."', )"); Edited April 3, 2013 by jordan443 Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422741 Share on other sites More sharing options...
PaulRyan Posted April 3, 2013 Share Posted April 3, 2013 Firstly, you should turn on error reporting, you might be surprised what you find. Error Reporting Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422746 Share on other sites More sharing options...
jordan443 Posted April 3, 2013 Author Share Posted April 3, 2013 I tried that but none of it helped. Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422749 Share on other sites More sharing options...
PaulRyan Posted April 3, 2013 Share Posted April 3, 2013 I tried that but none of it helped. Are you sure? I can spot quite a few things that will output some errors for you to see. If the error reporting really did nothing, then you need to next debug your code, to see what is going wrong and where. I would display all the $_POST data on form submission, to make sure it is what you expect. Then I would debug your query, to make sure it is what you expect and also check for query errors too. Quote Link to comment https://forums.phpfreaks.com/topic/276456-can-anyone-help-with-this-save-to-mysql-database-problem/#findComment-1422751 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.