PHP CODE
<?php
$imageId = $_GET ["a"];
$likerId = $_GET ["b"];
// connection to the database
$dbhandle = mysql_connect ( "localhost", "root", "" ) or die ( "Unable to connect to MySQL" );
// select a database to work with
$selected = mysql_select_db ( "taxogram", $dbhandle ) or die ( "Could not select login" );
// execute the SQL query and return records
$result = mysql_query ( "INSERT INTO liker ( imageId , likerId ) VALUES ( '$imageId' , '$likerId' ) " );
echo mysql_error () . "<br>";
if ($result == 1) {
echo "sukses";
} else {
echo "gagal";
}
?>
ERROR
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like ( imageId , likerId ) VALUES ( '1' , '2' )' at line 1 gagal
"like" is a reserved keyword.
$result = mysql_query ( "INSERT INTO `like` ( imageId , likerId ) VALUES ( '$imageId' , '$likerId' ) " );
Also note that mysql_ functions are deprecated. Use Mysqli or PDO instead.