View Full Version : not inserting anything

03-07-2010, 01:22 AM
this piece of code is killing me:

I'm inserting marks for school in MySQL table.
When I want to insert new record, nothing happens,
there is no new record.
When I want to update record, same thing. Nothing.
Deleting records is fine.

I'm giving you the full code because I don't know what to cut off.
Please help, it's quite urgent. In fact very urgent.

change attachment from txt in php.
Kind regards

03-07-2010, 02:16 AM
Hmm. You have two lines that perform either an UPDATE or an INSERT statement, and they both look like this:


You should add some additional troubleshooting in there (temporarily) that throws an error message and optionally gives you the SQL statement, e.g.

mysql_query($sql) OR die("Query error:<br>{$sql}<br>" .mysql_error());

At the very least you should make certain the $sql variable contains a valid SQL statement.

Likewise, this query statement:

$result = mysql_query("SELECT * FROM 6oceni WHERE redbr=".$red_br);

Should do the same. Make certain the value $red_br is an INTEGER type, and that it has a value.

Additionally, all of your $_REQUEST references should be $_POST. It's too easy to use a GET string value and throw off your code or invite an attack of some sort. Make sure you look into SQL injection (http://www.google.com/search?q=SQL+injection) and either parameterize your queries or at least validate and escape them using mysql_real_escape_string().

03-07-2010, 08:52 AM
Can you help me to separate insert and update? Don't have to be piece of art, just to do the job. I am novice and this is little confusing. Thanks.

03-07-2010, 01:43 PM
I wasn't able to find an insert or update query in that file.

03-08-2010, 03:20 AM
Here is complete code in zip. I can't insert new record.
I can't understand. It's a bit urgent and I need some
beautification and make up to make. Please help!

03-22-2010, 03:00 AM
anyone? help?! have somebody look at the code?

03-22-2010, 04:03 AM
That can take weeks to go through. Also why is index named index8?