i been trying to update an entity, but the matter of fact i gotta update them all at update page, else it throws error: here's my code
// to verify if user is an admin
<?php include "include/uni_header.php"?>
<?php
if (isset($_GET['update'])){
if ($_GET['update'] == null){
header("Location: error/error.php");
}else{
$hlp = $_GET['update'];
}
}else{
header("Location: error/error.php");
}
?>
<!-- mail -->
<div class="latest-albums">
<div class="container">
<h3 class="agileits_w3layouts_head"> <span>Update existing</span></h3>
<div class="wthree_latest_albums_grids gallery">
<div class="col-md-9 agile_mail_grid_left">
// here i am trying to fetch all value & putting them on the field
<?php
$sql = "select * from music where id=$hlp";
$getter = mysqli_query($connection, $sql);
while ($row=mysqli_fetch_assoc($getter)) {
$id = $row['id'];
$title = $row['title'];
$singer = $row['singer'];
$description = $row['description'];
$length = $row['length'];
$relese_date = $row['relese_date'];
$lyrics = $row['lyrics'];
$genere = $row['genere'];
$songs = $row['songs'];
$thumbnail = $row['thumbnail'];
$language = $row['language'];
$album_tag = $row['album_tag'];
$youtube_id = $row['youtube_id'];
$feature_tag = $row['feature_tag'];
}
?>
// trying to update
<?php
if (isset($_POST['submits'])){
$title = $_POST['name'];
$singer = $_POST['singer'];
$description = $_POST['description'];
$length = $_POST['length'];
$date = $_POST['release_date'];
$lyrics = $_POST['lyrics'];
$category = $_POST['cat'];
$language = $_POST['cat1'];
$youtube = substr($_POST['youtube'], 17);
$album = $_POST['album'];
//thumbnail
$p_image = $_FILES['images']['name'];
$post_image_temp = $_FILES['images']['tmp_name'];
move_uploaded_file($post_image_temp, "thumbnail/$p_image");
//songs
$upload_file = $_FILES['files']['name'];
$temps = $_FILES['files']['tmp_name'];
move_uploaded_file($temps, "songs/$upload_file");
//query
$query = "update music set title='{$title}', singer='{$singer}', description='{$description}', length='{$length}', relese_date='{$date}', lyrics='{$lyrics}', genere={$category}, songs='{$upload_file}', thumbnail='{$upload_file}', language={$language}, album_tag='{$album}', youtube_id='{$youtube}' where id={$hlp}";
$sender = mysqli_query($connection, $query);
echo "error".mysqli_error($connection);
}
?>
// pushing previously pulled value as user can see old values, it helps to update.
<form action="" method="post" enctype="multipart/form-data">
<label for="name">Enter Song Title</label>
<input type="text" name="name" placeholder="Name" value="<?php echo $title; ?>"><br>
<label for="email">Singer</label>
<input type="text" name="singer" placeholder="Singer" value="<?php echo $singer; ?>"><br>
<label for="description">Description</label>
<input type="text" name="description" placeholder="Description" value="<?php echo $description; ?>"><br>
<label for="length">Run Time</label>
<input type="text" name="length" placeholder="Run Time" value="<?php echo $length; ?>"><br>
<label for="images">Upload the song</label>
<input type="file" name="files" class="btn btn-default">
<label for="album">Album name</label>
<input type="text" name="album" placeholder="Album name" value="<?php echo $album_tag; ?>"><br>
<label for="youtube">Paste the Short URL only</label>
<input type="text" name="youtube" placeholder="ex: https://youtu.be/xxxxx" value="<?php echo $youtube_id; ?>"><br>
*This field only accepts SHORT URL <b>(open the song vid->share->copy link)</b>
<br><br>
<label for="country1">Choose Language</label>
<div class="btn-group">
<select id="country1" class="dropdown" name="cat1">
<?php
$sql1 = "select * from language where id=$language";
$getter1 = mysqli_query($connection,$sql1);
while ($r=mysqli_fetch_assoc($getter1)){
$language=$r['language'];
}
?>
<option class="dropdown-header" value=""><?php echo $language; ?></option>
<?php
$querys = "select * from language";
$sends = mysqli_query($connection, $querys);
while ($row = mysqli_fetch_assoc($sends)) {
$id = $row['id'];
$language = $row['language'];
echo "<option class='dropdown-item' value='{$id}'>{$language}</option>";
}
?>
</select>
</div>
<br><br>
<label for="release_date">Release Date</label>
<input type="date" autocomplete="off" name="release_date" id="date" placeholder="Relese Date" value="<?php echo $relese_date; ?>"><br>
<br>
<label>Upload A Thumbnail Picture</label>
<input type="file" name="images" class="btn btn-default">
<br>
<label>Post the lyrics</label>
<textarea name="lyrics" placeholder="Description of the book" id = "body"></textarea>
<br>
<label for="Genre">Choose Genre</label>
<div class="btn-group">
<select id="country" class="dropdown" name="cat">
<option class="dropdown-header" value=""><?php echo $genere; ?></option>
<?php
$querys = "select * from category";
$sends = mysqli_query($connection, $querys);
while ($row = mysqli_fetch_assoc($sends)) {
$id = $row['id'];
$category = $row['title'];
echo "<option class='dropdown-item' value='{$id}'>{$category}</option>";
}
?>
</select>
</div>
<br><br>
<input type="submit" value="Post Your Song Now" name="submits">
</form>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
<!-- //mail -->
<?php include "include/about_footer.php"?>
as i am clicking submits it's throwing me an error like bellow: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' album_tag='fefef222', youtube_id='' where id=19' at line 1
please tell me where's my fault, i been trying to figure it out for a long.. please help....!
Aucun commentaire:
Enregistrer un commentaire