[Solved] php + Highcharts.js + convert from mysql to mysqli causes error [duplicate]

If you are going to convert your code to mysqli_*, then it should be in a prepared statement manner. Lets re-establish your MySQL connection in db.inc.php: <?php $conn = new mysqli(“localhost”, “Datenbank-Username”, “Datenbank-Passwort”, “Datenbank-Name”); /* CHECK CONNECTION */ if (mysqli_connect_errno()) { printf(“Connect failed: %s\n”, mysqli_connect_error()); exit(); } /* CHANGE CHARACTER SET TO utf8 */ if … Read more

[Solved] How to show all DB result with PDO

The answer is as follows: <?php $sql = “SELECT * FROM database WHERE id BETWEEN 1 AND 5″; $stmt = $conn->query($sql); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_OBJ)){ ?> <tr> <td><b><?php echo $row->hours ?></b></td> <td><a href=”#”></a></td> <td id=”dayhour-1″> <input type=”text” class=”form-control” id=”1″ value=”<?php echo $row->username ?>”> </td> </tr> <?php } ?> This code will do it’s work. Its … Read more

[Solved] How to cancel action when detect same line in MySQL [closed]

from my understanding of your question – in your php code you can do something like this <?php $con=mysqli_connect(“localhost”,”my_user”,”my_password”,”my_db”); $sqlSearch = “select everything from <table_name> where <column_name> = <value>;”; $result = mysqli_query($con,$sqlSearch ); if (mysqli_num_rows($result) > 0){ // do nothing } else{ $sqlInsert = “insert into <table_name> (column1,column2…) VALUES(value1,value2…);”; $result = mysqli_query($con,$sqlInsert); } ?> basically, … Read more

[Solved] delete the last items of an array [closed]

Could use array_shift / array_unshift, but since the logic seems upside down, you could use something like <?php $apparentDB = array(“1” => “Jason” , “2” => “Jimmy” , “3” => “Christopher” , “4” => “Bruce” , “5” => “james” , “6” => “Mike” , “7” => “Brad” ); /* You can add it one by … Read more

[Solved] ORDER_BY date LIMIT 1 [duplicate]

First of all, you should use prepared statements like this: $note = “SELECT * FROM notify WHERE seeker=:seeker AND donor=:donor ORDER BY `date` DESC LIMIT 1”; $st = $conn->prepare($note); $st->execute(array( ‘:seeker’ => $_SESSION[’email’], ‘:donor’ => $email, ); Without the place holders you’re still open to SQL injection. Second, you can’t compare a string with an … Read more

[Solved] Get the second last record from table

If I understand correct, your table doesn’t have an id or indexed column. In that case there’s not much to do, but to fetch all and get the second last row. However, even if you do that, there is no guarantee that you would get the same result each time. 4 solved Get the second … Read more

[Solved] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”2′ at line 1 [closed]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”2′ at line 1 [closed] solved You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use … Read more

[Solved] How can I create an array with all rows from database

Instead of checking the value of Popular on PHP side, you can filter directly your rows like this, and return the list of ID directly SELECT ID FROM Products WHERE Popular = 1; Then, you can use mysqli_fetch_array to get the results as an array directly while ($row = mysqli_fetch_array($result)) { $Popular[] = $row; } … Read more

[Solved] How do i display images from MySQL database in a JavaScript image slider?

Here is a very basic Slideshow-from-PHP application. It can easily be modified or built upon. Image names (file_name) are pulled from the database, then pushed into a JavaScript array of image src values. Make sure you also specify the images directory (where the images are actually stored) to match your own. A simple image preloader … Read more

[Solved] Run SQL query based on drop down value [closed]

<?php include(“dbconfig.php”); if(isset($_POST[‘submit’])) { if(isset($_POST[‘type’])) { if($_POST[‘type’] == “enquiry”) { Query } elseif($_POST[‘type’] == “enroll”) { Query } else { echo “Please select enquiry or enrollment”; } } else { echo “Please select an option”; } } ?> <form action=”dropd.php” method=”POST”> <select name=”type”> <option value=””>Please select:</option> <option value=”enquiry”>Student enquiry</option> <option value=”enroll”>Student enrollment</option> <input type=”submit” name=”submit” … Read more