0

i am new to php and really need help on the below.

echo "Running Database Script...";
flush();
$dbms_schema = "../../sql/schema.sql";

$sql_query = @fread(@fopen($dbms_schema, 'r'), @filesize($dbms_schema)) or die('Cannot find SQL schema file. ');

$sql_query = remove_remarks($sql_query);
$sql_query = remove_comments($sql_query);
$sql_query = split_sql_file($sql_query, ';');

$con = mysqli_connect($servername,'root',$rootpass) or die('error connection');

$i=1;
foreach($sql_query as $sql){
  //echo $i++;
  //echo "  ";
  //echo $sql;
  //echo "<br>";
  mysqli_query($con,$sql) or die('error in query');
}
//mysqli_close($con);
echo "Success!<br>";
flush();

getting the below result with the mysqli_query($con,$sql) part...

Running Database Script...error in query
SaschaM78
  • 4,104
  • 3
  • 31
  • 38

1 Answers1

0

Try to display the error you get using mysqli_error():

if (!mysqli_query($con,$sql)) {
    printf("Errormessage: %s\n", mysqli_error($con));
}
SaschaM78
  • 4,104
  • 3
  • 31
  • 38