Jump to content

mysqli


stevenlmeyer
Go to solution Solved by stevenlmeyer,

Recommended Posts

Downloaded XAMPP and created MySQL database and table using phpMyAdmin. Inserted rows into table from input form in browser using mysqli. Confirmed data was inserted using browse function in phpMyAdmin.

 

All good.

 

Trouble comes when I try to retrieve data using mysqli and SELECT statement:

 

Here is my code:

 

*********************************************************************************

 

<?php
$con = new MySQLi("localhost", "xxx", "xxx", "xxx");
 
if ($con === false) {
die("ERROR no connexion " . mysqli_connect_error());
}
else {
echo "<p> Connect was a success </p>";
};
 
$sql = "SELECT lastName, firstName, email, gender from tab1";
 
echo "<p>" . $sql ."</p>";
 
$result = $con -> query($sql);
 
$x = var_export($result, TRUE);
 
echo "<br /><pre>" . $x . "</pre><br />";
 
echo "hi" . "<br />";
 
echo "<p>Try to see error" . $con -> error . "</p>";
 
 
 
$con -> close();
 
?>
 
******************************************************************************************************
 
And here is what I see in the browser
 
***********************************************************************************************************
 

Connect was a success  [so it connected]

SELECT lastName, firstName, email, gender from tab1  [the $sql statement]


mysqli_result::__set_state(array(
'current_field' => NULL,
'field_count' => NULL,
'lengths' => NULL,
'num_rows' => NULL,
'type' => NULL,
))
hi

Try to see error  [No error apparently]

 
************************************************************************************************************
 
Nothing in result
 
Works fine with INSERT
 
Fails with SELECT
 
All tips, suggestions welcome.
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.