Jump to content

Recommended Posts

59- $insert = "INSERT INTO Users (character_image)
60- VALUES ('".$_POST['class']'.jpg'."')";

 

This code is designed to insert data about a users character image into my database. It inserts the variable part of it alright, so you can probably ignore that bit, it doesn't like the .jpg part of it however.

 

In tests I've done I've tried different variations of using " and '

I got closest without any, as it returned the right value, only missing the .

I'm not sure if there's a specific way to make it read the last part that I am not aware of, if there is, could you please tell me?

 

Thanks in advance

 

~Glenugie~

 

MySQL:

Server Version 5.0.45

Client Version 5.0.27

 

Link to comment
https://forums.phpfreaks.com/topic/139301-problem-with-inserting-a-mysql-value/
Share on other sites

$insert = "INSERT INTO Users (character_image)

VALUES ('{$_POST['class']}.jpg')";

 

 

You were sticking them together incorrectly.  It could be done other ways, but that's the easiest way to do it.  By the way, you shouldn't trust user input (the GET, POST, COOKIE, REQUEST so on arrays).  You should always escape data like that, or atleast check it for sanity before putting it in a database.  I guess you could be doing that else where though.

I've looked into it in a little more detail, but I'm not sure I entirely understand the method for escaping data, I have to do it for every query, inserting data and extracting data, right?

 

For inserting I have to escape all the values going in, and for extracting I have to escape all values coming out?  ???

 

Thanks for telling me anyway.

 

~Glenugie~

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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