How to print php result from mysql date ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
kdao
Forum Newbie
Posts: 9
Joined: Fri Jun 13, 2008 11:58 am

How to print php result from mysql date ?

Post by kdao »

<?php


$user='kdao';
$pass='khaidao';
$host='localhost';
$db='kdao';
$table='guessbook';

$conn = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db,$conn);

$query_1 = "select concat('There are ',to_days('2008-10-15') - to_days(current_date()),' left to the special holiday .');
$result_1 = mysql_query($query_1);

// ??How to print this result_1?
print $result_1; // did not work?
// what is the missing here?
// Thanks.

print "Hello world";

mysql_close($conn);
?>
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: How to print php result from mysql date ?

Post by jaoudestudios »

You only sent the query you did not fetch any results yet.

Use

Code: Select all

$r = mysql_fetch_assoc($query_1);
Also, are you sure that sql query is valid?
Post Reply