I have a form to fill in the data by the user which displays the article and information about it. It looks like this:

<form action='admin_panel.php' method='post' enctype='multipart/form-data'> <label> Название статьи:<br> <input type='text' name='article_title1' size='60' value='$article_title' required/><br> </label> <label> Изображние к статье:<br> <input type='file' name='article_image1' size='60' /><br> </label> <label> Введите текст статьи:<br> <textarea class='txtar' name='article_text1' required>$article_text</textarea><br> </label> <a href='news.php'>Вернуться назад</a><br><br> <label> <input type='submit' name='insertarticle1' value='Ввести данные'/> </label> </form> 

The code to change the data in the database looks like this:

 If(isset($_POST['insertarticle'])){ $link = mysqli_connect("localhost", "root", "", "blshk") ; //getting the text data from the fields $art_edit = mysqli_real_escape_string($link, $_POST['art_edit']); $article_title1 = $_POST['article_title1']; $article_text1 = $_POST['article_text1']; $article_image1 = $_FILES['article_image1']['name']; $article_image_tmp1 = $_FILES['article_image1']['tmp_name']; move_uploaded_file($article_image_tmp1,"images/$article_image1"); $insertarticle = mysql_query("UPDATE article SET article_title='$article_title1', article_text='$article_text1', article_image='$article_image1' WHERE article_id='$art_edit',",$link); if($insertarticle=='TRUE'){ echo "<script>alert('article inserted')</script>"; echo "<script>window.open('admin_panel.php','_self')</script>"; } } 

However, it does not work. Thank you for your help

  • And mysqli_connect() will not work with mysql_query() . These are different libraries - ArchDemon

1 answer 1

mysqli_connect() This is one library and if you use mysqli, then you must write mysqli in all places, and you have to

 $insertarticle = mysql_query("UPDATE article SET article_title='$article_title1', article_text='$article_text1', article_image='$article_image1' WHERE article_id='$art_edit',",$link); 

written mysql instead of msqli . The mysqli library is a new and improved mysql view.