Как вставить файл xslx в базу данных mysql?
Я скачал PHPExcel и набрал базовый код, который не дает мне ничего, кроме пустой страницы, когда я его запускаю. Какие-нибудь советы?
Что я уже пробовал:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> </head> <body> <?php $conn = MySQLi( 'localhost', 'omri', '1234', 'omri' ); if( $conn === false ) { echo "Could not connect.\n"; die( print_r( sqlsrv_errors(), true)); } include "Classes/PHPExcel.php"; include "Classes/PHPExcel/IOFactory.php"; //load excel file using PHPExcel's IOfactory $excel = PHPExcel_IOFactory::load('omri.xlsx'); //set active sheet to first sheet $excel->setActiveSheetIndex(0); echo "<table>"; echo " <tr> <th>Name</th> <th>ID</th> <th>Citizenship</th> <th>Expires</th> </tr> "; //first row of data series $i = 1 ; //loop until the end of data series(cell contains empty string) while($excel->getActiveSheet()->getcell('A'.$i)->getValue() != ""){ //get cells value $name = $excel->getactiveSheet()->getCell('A'.$i)->getValue(); $id = $excel->getactiveSheet()->getCell('B'.$i)->getValue(); $citizenship = $excel->getactiveSheet()->getCell('C'.$i)->getValue(); $expires = $excel->getactiveSheet()->getCell('D'.$i)->getValue(); $q = "INSERT INTO omri (name,id,citizenship,expires) VALUES ('$name','$id','$citizenship','$expires')"; $d = sqlsrv_query($conn,$q); //echo echo " <tr> <td>".$name."</td> <td>".$id."</td> <td>".$citizenship."</td> <td>".$expires."</td> </tr> "; //and DON'T FORGET to increment the row pointer ($i) $i++; } echo "</table>"; //echo error if( $d === false ) { if( ($errors = sqlsrv_errors() ) != null) { foreach( $errors as $error ) { echo "</br>SQLSTATE: ".$error[ 'SQLSTATE']."<br />"; echo "code: ".$error[ 'code']."<br />"; echo "message: ".$error[ 'message']."<br />"; } } } ?> </body> </html>