[eluser]John_Betong[/eluser]
Hi KingConnections,
Try inserting this code in your config/dbase.php file immediately after the
cache statements.
I changed the $sql statement to suit my own tables.
Code:
// TESTING
$myhost = $db['default']['hostname'];
$myuser = $db['default']['username'];
$mydbase = $db['default']['database'];
$mypass = $db['default']['password'];
$mysql = 'SELECT * FROM jokes WHERE id < 10';
echo '<br />$myhost ==> ' .$myhost;
echo '<br />$mydbase ==> ' .$mydbase;
echo '<br />$myuser ==> ' .$myuser;
echo '<br />$mypass ==> ' .$mypass;
echo '<br />$mysql ==> ' .$mysql;
$conn = mysql_connect($myhost, $myuser, $mypass);
if (!$conn) {
die('<br />Could not connect: ' . mysql_error());
}
echo '<br />Connected successfully<br /><br />';
if (!mysql_select_db($mydbase)) {
echo '<br />Unable to select ==> ' .$mydbase . mysql_error();
exit;
}
$sql = "SELECT email FROM user ";
// I CHANGED THIS STATEMENT
$result = mysql_query($mysql);
if (!$result) {
echo "<br />Could not successfully run query ($sql) from ==> " .$mydbase . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "<br />No rows found, nothing to print so am exiting";
exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you’re expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you’ll
// then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
// echo $row["email"];
echo $row['id'] .' ==> ' ;
echo $row['title'];
echo "<br />";
}
mysql_free_result($result);
mysql_close($conn);
die;
// TESTING
Results
Quote: $myhost ==> localhost
$mydbase ==> johnsjokes
$myuser ==> john_betong
$mypass ==> 0336-1462-5035
$mysql ==> SELECT * FROM jokes WHERE id<10
Connected successfully
1 ==> The weighing machine
2 ==> The elephant and the turtle
3 ==> The hinge and the teapot
4 ==> Stress management
5 ==> The song
6 ==> The gambler & taxi-driver
7 ==> The newlyweds
8 ==> Grandpa and his grand-daughter
9 ==> The Christmas present
Cheers,
John_Betong