i tried looking for an answer on google and here for this but couldnt find any and this is making me go nuts
my prob is:
i have a php page that retrieves data from a form using extract($_POST);
and then correctly adds the data to a database using the usual mysql insert command
problem is:
whenever i insert an item, the data is inserted correctly but there's an additional empty entry inserted out of nowhere,
i have no clue why or from where
the moment i insert the data into the database, i refresh the phpmyadmin page almost directly and i see my new entry alone , but like another second later, i refresh, and the empty entry is inserted out of nowhere
I guess that you are running the mysql query and then error checking the query to see if it inserted. Can you post a block of your PHP around your INSERT statement for us to look at?
what am doing is having the database open in phpmyadmin ("broswe"), and i refresh to c if the entry was added, but on my 2nd refresh,i see a blank ghost entry out of nowhere
You may have an unlucky combination of characters in one of the variables, which could lead to MySQL believing that you are trying to do a multiple insert.
ok,
this is it:
insert into dogs values('','test name', '22/10/1995', 'lebanon', 'liban', 'l.o.s.h', 'ped.jpg','photo.jpg', 'comment, english', 'comment, french', '0')
there was no blank entry afterwrds this time though
it's weird,
i just tried many entries after each other now, and i dont seem to get any blank ones for some reason
ah ok, after some testing again
apparently the blank entry is only appearing when i am not inputting anything in certain fields as in here:
insert into dogs values('','test name1', '22/10/1995', 'lebanon', 'liban', 'l.o.s.h', '','', 'comment, english...', 'comment, french.', '1')
what's the solution to this prob?
and what exactly is causing this to happen?
because they are so-called "unescaped" commas in your values. You will have to use addslashes() on each variable that is likely to contained "unauthorized" characters before inserting in the database - probably best to do it on all character variables.
In the above code, MySQL thinks you're trying to insert not 11 but 13 fields...
It's hard for me to tell from afar. I just know that most inserts don't end up making "ghost entries". I can practically rule out MySQL as the culprit.
That leaves your code or the content of the variables you are trying to insert, which brings us back to your code, unfortunately.
What I do I know is that your SQL looks like this:
NightShift58,
a) commas don't need to be escaped (or can you provide me a link to where this is stated otherwise);
b) addslashes() only places backslashes before a single quote ('), double quote ("), backslash (\) and NUL (the NULL byte) characters, not a comma anyway;
c) you probably should use mysql_real_escape_string() rather than addslashes() for MySQL queries.
karxix would you mind posting your whole code then aswell as the database structure
also as a side question, if u use this:
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
how do i know where the new image is stored, or how can i move it to where i want, rename it...i couldnt easily find that in the manual, thought u can point me out to what to look for (ps: all variables are set right )
Bookmarks