*EDIT* I could also use PDO, but it's much harder.
How could i add these codes? It is PHP & it displays some recent uploaded images to my site.
and
How could i add these codes? It is PHP & it displays some recent uploaded images to my site.
Code:
<?php
// This is to output the upload history
$host = "SQL_HOST";
$database = "DB_NAME";
$username = "SQL_USER";
$password = "SQL_PASS";
$connect = mysql_connect($host,$username,$password) or die (mysql_error());
mysql_select_db($database, $connect);
$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
$q = mysql_query("SELECT * FROM imgupload WHERE `ip` LIKE '%$ip%'");
while ($r = mysql_fetch_array($q)) {
echo '<img src=\"'.$r['imgid'].'\" />';
}
?>
and
Code:
<?php
// This is to input the upload history
$host = "SQL_HOST";
$database = "DB_NAME";
$username = "SQL_USER";
$password = "SQL_PASS";
$connect = mysql_connect($host,$username,$password) or die (mysql_error());
mysql_select_db($database, $connect);
$ip = $_SERVER['REMOTE_ADDR'];
$imgid = $_POST['imgid'];
mysql_query("INSERT INTO `$database`.`imgupload` (`imgid` ,`ip`)VALUES ('$imgid', '$ip');", $connect);
mysql_close($connect);
?>