- Автор темы
- #1
Помагите изменить этот код на PDO
Код:
<?php
//connect to the database
$hostname_site = "localhost";
$database_site = "drop";
$username_site = "root";
$password_site = "";
$site = mysql_connect($hostname_site, $username_site, $password_site) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_site, $site);
mysql_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
//general recordset function
if ($_POST[title]) {
mysql_query("INSERT INTO item (title, description) VALUES
(
'".addslashes(strip_tags($_POST['title']))."',
'".addslashes(strip_tags($_POST['description']))."'
)
");
$mid = mysql_insert_id(); //get id of entry that was just added
//associate the images that were just uploaded to the entry that was added
mysql_query("UPDATE files SET item_id = '".$mid."' WHERE image_code = '".addslashes($_POST[eid])."'");
//redirect to entry that was just added
header('Location: index.php?id='.$mid); die;
}
?>