Can’t insert data into mysql database using PHP [closed]

Edited:

Try just adding this code:

<?php
$message = mysql_real_escape_string(bbcode_to_html($message));

$sqlquery1 = 'insert into topics (id_parent, id, id_user, title, message, id_author, timestamp, timestamp_user) select "' . $dn1['id_parent'] . '", "' . $id . '", max(id_user)+1, "", "' . $message . '", "' . $_SESSION['userid'] . '", "' . time() . '", "' . time() . '" from topics where id="' . $id . '"';

$sqlquery2 = 'update topics set timestamp_user="' . time() . '" where id="' . $id . '" and id_user=1';

$result1 = mysql_query($sqlquery1) or die(mysql_error() . ": Full Query was: " . $sqlquery1);

$result2 = mysql_query($sqlquery2) or die(mysql_error() . ": Full Query was: " . $sqlquery2);

if ( $result1 and $result2){
    ?><header class="major">
    Komen sukses! Kembali ke <a href="https://stackoverflow.com/questions/31281199/read_topic.php?id=<?php echo $id; ?>">Topik!</a>
</header>
<?php
}else{
    echo 'Terjadi kesalahan saat mengirim komen!';
}
?>

This will now also show you the query you tried to execute. This will help if you want further questions answered well.

Leave a Comment