Im new to PHP MySQL. Im developing a songbook site.
I'm trying to pull data in a database from the ID in the URL site/publicsong.php?id=12
.
<?php
// Create connection
$conn = new mysqli($servername = "localhost";$username = "dansdlpe_dan";$password = "g+GbMr}DU4E@";$db_name = "dansdlpe_lyrics";);
// Check connection
$db_name = "dansdlpe_lyrics";
mysqli_select_db($conn,$db_name);
$id = $_GET['id'];
$id = mysqli__real_escape_string($conn,$id);
$query = "SELECT * FROM `lyrics_a` WHERE `id`='" . $id . "'";
$result = mysqli__query($conn,$query);
echo $row['id']; while($row = mysqli__fetch_array( $result )) {
echo "<br><br>";
echo $row['eng_title'];
echo $row['eng_lyrics'];
echo $row['alphabet'];
}
?>
I changed mysql_ to mysqli_ and added $conn.
And still i result is blank. Please help guys. Thanks in advance.
No need to use the id as a string,
you can use like :
id=" . $id;
So I will stick to what you already have with some fixes.
Try this: