Hi I have look for this and just cant figure it out (Newbie).
I am using this code to query my MYSQL DB, the query string works, but how do I get the results into a variable? or echo them out to the screen?
I know this is probly really simple but its driving me nuts
[code=php]
$theRef = $_GET[‘ref’];
$DBhost = “100.100.100.101”;
$DBuser = “user”;
$DBpass = “pass”;
$DBName = “DB_Name”;
$table = “table_name”;
$field1 = “field1”;
$field2 = “field2”;
//Connecting to DB
mysql_connect($DBhost,$DBuser,$DBpass) or die(“Unable to connect to database”);
//Selecting Databse
@mysql_select_db(“$DBName”) or die(“Unable to select database $DBName”);
//Create the MySQL Query String
$stmt = “SELECT $field1 FROM $table where $field2 =’$theRef'”;
//Run Query
$results = mysql_query($stmt) or die(mysql_error());
$row = mysql_fetch_assoc($results);
echo(“Row: $row <br>”);
//Close DB Connection
mysql_close();
This is not working for me I get the value: Row: array