Jump to content

Can anyone help with this save to mySQL database problem?


jordan443

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

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.

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"]."',
 
)");

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.

Archived

This topic is now archived and is closed to further replies.

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