Php data does not go to databde

https://musicspark.epizy.com/music/

Unless im being stupid i’ve tripled checked everything and its all correct. No error codes but I get no data to my table named ‘musictable’

processing.php

<?php
  require '../includes/config.php';
    // encoded language
      mysqli_set_charset($con,'utf8');
      $musicname = mysqli_real_escape_string($con, $_POST['musicname']);
      $musicartits = mysqli_real_escape_string($con, $_POST['artistname']);

      if($_FILES['musicicon']['name']){
      move_uploaded_file($_FILES['musicicon']['tmp_name'], "../musicicons/".$_FILES['musicicon']['name']);
      $music="musicicons/".$_FILES['musicicon']['name'];
      }

      if($_FILES['musicfile']['name']){
        move_uploaded_file($_FILES['musicfile']['tmp_name'], "../musicfile/".$_FILES['musicfile']['name']);
      $musicfile ="musicfile/".$_FILES['musicfile']['name'];
      }

      $i="insert into musictable(musictitle, musicartist, musicicon, musicfile,   musicuploadedtime)values('$musicname','$musicartits','$music','$musicfile', NOW())";

      $set  = mysqli_query($con, $i);
      if($set){
         $successfullyIn = " SUCCESSFULLY INSERTED!";
      }else{
         echo "FAILED";
      }
  ?>

How are you trying to send the data to the table?

1 Like

“insert into musictable(musictitle, musicartist, musicicon, musicfile, musicuploadedtime)values(‘$musicname’,‘$musicartits’,‘$music’,‘$musicfile’, NOW())”

paste ur query in phpmyadmin and see if it works,
and u can turn on mysql errors, and php errors to get detailed report

in php page =

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);

in my practice , i had unique contraint, but it was not throwing error, i had to enable “throw error on contraints” other wise query will return success.

hope it helps!

1 Like

Perhaps like this?

<?php 
require '../includes/config.php'; 

// encoded language 
mysqli_set_charset($con,'utf8'); 
$musicname = mysqli_real_escape_string($con, $_POST['musicname']); 
$musicartists = mysqli_real_escape_string($con, $_POST['artistname']); 
$music = "";
$musicfile = "";
if($_FILES['musicicon']['name']){ 
  move_uploaded_file($_FILES['musicicon']['tmp_name'], "../musicicons/".$_FILES['musicicon']['name']); 
  $music = "musicicons/".$_FILES['musicicon']['name']; 
} 
if($_FILES['musicfile']['name']){ 
  move_uploaded_file($_FILES['musicfile']['tmp_name'], "../musicfile/".$_FILES['musicfile']['name']); 
  $musicfile = "musicfile/".$_FILES['musicfile']['name']; 
} 
//assuming that NOW() returns a string
$i = "insert into musictable(musictitle, musicartist, musicicon, musicfile, musicuploadedtime)values('".$musicname."','".$musicartists."','".$music."','".$musicfile."','".NOW()."')"; 
$set = mysqli_query($con, $i); 
if($set){ 
  $successfullyIn = "SUCCESSFULLY INSERTED!"; 
} else { 
  echo("FAILED"); 
} 
?>
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.