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