I have posted this yesterday, I didn't get the the answers that could solve my problem but I got some pretty good ideas anyhow. This code retrieves the associated row from the db and translates it into PHP array so I could display it as a profile info. Here's my current code:
Query:
<?php
require 'includes/constants.php';
class newMysql {
private $conn;
function __construct() {
$conn = mysql_connect(DB_SERVER_USERS, DB_USER_USERS, DB_PASSWORD_USERS, DB_NAME_USERS);
if(!$conn) die('There was a problem connecting to the database.');
}
function get_profile(mysql_escape_string($lname)) {
$query = "SELECT * FROM members WHERE lname = '".$lname."' ";
$registerquery = mysql_query($query);
if($registerquery){
if (gettype($registerquery) == "resource") {
if (mysql_num_rows($result) != 0 ) {
while ($row = mysql_fetch_assoc($registerquery)) {
$profile[] = $row;
}
return $profile;
}
}
if(gettype($registerquery) == "boolean") {
return "No array returned";
}
}
else return "Query not successful".$registerquery;
}
}
Display:
<?php
require 'classes/newMysql.php';
$mysql = new newMysql();
$profile = array();
$profile = $mysql->get_profile("lozano");
echo $profile;
Whatever I do, I get the message: "Query not successful". So the query does not return anything? It doesn't complain about db connection failure either. I tried the query directly from the CLI, it did return the expected row of data.
Any help pls...