Мне было интересно, может ли кто-нибудь указать мне в правильном направлении, чтобы сменить мой скрипт на mysqli? Я построил скрипт ниже с mysql, и он отлично работает , но с тех пор мне сказали, что mysql_ обесценивается, и теперь мне нужно использовать mysqli. (до того, как mysql_ исчезнет, и у меня остался сайт с сообщением об ошибке).Простое преобразование из mysql в mysqli
сценарий:
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename($_FILES['photo']['name']);
//This gets all the other information from the form
$name= (isset($_POST['image_author']));
$description= ($_POST['image_description']);
$pic=($_FILES['photo']['name']);
// Connects to your Database
mysql_connect("localhost", "root", "root") or die(mysql_error()) ;
mysql_select_db("image_gallery") or die(mysql_error()) ;
//Writes the information to the database
mysql_query("INSERT INTO images (image_author, image_description, image_pathname)
VALUES ('$name', '$description', '$pic'");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file has been uploaded, and your information has been added to the directory <p> <a href='upload.php'> Go back</a>";
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
Смотрите там на праве, где он говорит " Связанный"? Есть около полутора десятков вопросов об одном и том же. Читали ли вы их? – j08691
Да. В противном случае я не стал бы спрашивать. –
Начните читать эту страницу о том, как избежать SQL-инъекции в PHP. http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php –