what is missing of this code? how to get result_1 print?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

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

what is missing of this code? how to get result_1 print?

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);
print $result_1 ; // should it work?

print "Hello world";

mysql_close($conn);
?>
sureshmaharana
Forum Commoner
Posts: 30
Joined: Thu Jul 03, 2008 4:20 am
Contact:

Re: what is missing of this code? how to get result_1 print?

Post by sureshmaharana »

Try this one:
<?
$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 .') as result";
$result_1 = mysql_query($query_1);
$row = mysql_fetch_array($result_1);
print $row['result'];

mysql_close($conn);
?>
kdao
Forum Newbie
Posts: 9
Joined: Fri Jun 13, 2008 11:58 am

Re: what is missing of this code? how to get result_1 print?

Post by kdao »

Thanks everyone.
It works !

:)
Post Reply