Jump to content

Can anyone help with this save to mySQL database problem?


Recommended Posts

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 by jordan443
Link to comment
Share on other sites

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."'>" 

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 by remenissions
Link to comment
Share on other sites

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 by jordan443
Link to comment
Share on other sites

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)
Edited by jordan443
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 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.