Jump to content

Lewisdow

New Members
  • Posts

    5
  • Joined

  • Last visited

Lewisdow's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you soooo much Sen, that sorted the issue and I am now getting database row results back!!
  2. Sorry to be pain, but as a beginner would you mind please providing what that code would look like? thanks
  3. If I echo in the // get the error from the query I do get a echo back but no error message so perhaps it is being supressed... Can you please tell me how I can show the error? I can not locate the .ini file, perhaps you can provide one? many thanks
  4. Hi, thank you Nothing was returned from try error, unless I have a setting or something that is hiding the error message? Script below... <?php $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "databasename"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "SELECT id, column FROM databasetable"; $result = mysqli_query($conn, $sql); $result = mysqli_query($conn, $sql); // error check query. mysqli_query returned false on error if($result) { // process query results if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo $sql; echo "id: " . $row["id"]."<br>"; } } else { echo "0 results"; } } else { // get the error from the query trigger_error('Query returned an error: ' . mysqli_error($conn)); } mysqli_close($conn); ?>
  5. hi I have a basic script that connects to the mysql database server successfully. There are no connection errors however when I query the table the script then reports that 0 rows were returned. I know that there is data available as I can query the table in the mysql server tool. Please could someone point out what may be the problem. Below is the script I am using. thanks, <?php $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "databasename"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } $sql = "SELECT id, column FROM databasetable"; $result = mysqli_query($conn, $sql); echo "id: " . $row["id"]. "<br>"; if (mysqli_num_rows($result) > 0) { echo $row; // output data of each row while($row = mysqli_fetch_assoc($result)) { echo $sql; echo "id: " . $row["id"]."<br>"; } } else { echo "0 results"; } mysqli_close($conn); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.