Database INSERT does not take place

Posted by reggie on Stack Overflow See other posts from Stack Overflow or by reggie
Published on 2010-04-23T13:34:01Z Indexed on 2010/04/23 15:43 UTC
Read the original article Hit count: 404

Filed under:
|
|
|

My code is as follows:

<?php
include("config.php");

$ip=$_SERVER['REMOTE_ADDR']; 

if($_POST['id'])
{
    $id=$_POST['id'];
    $id = mysql_escape_String($id);

    $ip_sql=mysql_query("select ip_add from Voting_IP where mes_id_fk='$id' and ip_add='$ip'");
    $count=mysql_num_rows($ip_sql);

    if($count==0)
    {
        $sql = "update Messages set up=up+1  where mes_id='$id'";
        mysql_query($sql);

        $sql_in = "insert into Voting_IP (mes_id_fk,ip_add) values ('$id','$ip')";
        mysql_query($sql_in) or die(mysql_error());
        echo "<script>alert('Thanks for the vote');</script>";


    }
    else
    {
        echo "<script>alert('You have already voted');</script>";
    }

    $result=mysql_query("select up from Messages where mes_id='$id'");
    $row=mysql_fetch_array($result);
    $up_value=$row['up'];
    echo "<img src='button.png' width='110' height='90'>";
    echo $up_value;

}
?>

My problem is that the insert process does not take place at all. The script tags echos an alert box. Even the img tag is echoed to the web page. But the insert process does not take place. The config file is fine. Note: This code works on my local machine which has PHP 5.3 but it does not work on the server which has PHP 5.2. Any advice?

© Stack Overflow or respective owner

Related posts about php

Related posts about php5