No results from database
Posted by: bbcreative (---.cable.ubr06.azte.blueyonder.co.uk)
Date: December 05, 2006 01:03PM

Hi,

I am sat here scratching my head on this one.

I've installed the latest WAMP 1.6.6 and everything seems fine. I've created a database which I can connect to through comand line and results show up on queries. PHP files work fine too.

I have created a simple script to access mysql (here's where things go wrong)...

I get no errors and I am connected to the database, I just get no results displayed. Strangely, when I access a remote db with the same database table etc and upload the same script to my host everything works fine.

I've tried this on a win2k machine and a winxp machine with the same result.

Is there some setting in config that needs to be done to correct this?

Thanks for any help in advance.


Options: ReplyQuote
Re: No results from database
Posted by: johny12 (---.in2cable.com)
Date: December 05, 2006 01:12PM

have u used <?php ?> tags properlly???
only "<?" will not work untill u set ur default "short tags =off" in php.ini
so use "<?php" for "<?" and then giv a try
cheers smiling smiley

" who the hell on this side !!! "

Options: ReplyQuote
Re: No results from database
Posted by: bbcreative (---.cable.ubr06.azte.blueyonder.co.uk)
Date: December 05, 2006 01:24PM

Hi,

Thanks for your quick reply,

Yes, I am using <?php my code is below. It's the fact that the script works on a remote server/database but not locally that's confusing me.


<?php

$server = "localhost";
$username = "******";
$password = "******";

$link = mysql_connect ($server, $username, $password)
or die ("Could not connect"winking smiley;

echo "connected to database"; // I'm using this to make sure I'm connected to DB

if (!@mysql_select_db("ipic", $link)) {

echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
echo "Please Contant Your Systems Administrator with the details";

}

$result = mysql_query("SELECT * FROM agenda", $link);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>"winking smiley;
exit();
}

$num=mysql_numrows($result);

$d=0;
while ($d < $num) {
$day=mysql_result($result,$d,"day"winking smiley;
$date=mysql_result($result,$d,"date"winking smiley;
$description=mysql_result($result,$d,"description"winking smiley;

?>

<table>
<tr>
<td bgcolor="#eeeeee"><? echo "$day"; ?></td>
<td bgcolor="#eeeeee"><? echo "$date"; ?></td>
<td align="center" bgcolor="#eeeeee"><? echo "$description"; ?></td>
</tr>
</table>

<?php
++$d;
}

mysql_close($link);

?>

Cheers


Options: ReplyQuote
Re: No results from database
Posted by: bbcreative (---.cable.ubr06.azte.blueyonder.co.uk)
Date: December 05, 2006 02:04PM

johny12,

You were right... I've just noticed the all important lines <? echo "$day"; ?> when they should have been <?php echo "$day"; ?>

.... Sometimes the more you look the less you see....

Thanks for your help.

Options: ReplyQuote
Re: No results from database
Posted by: yfastud (72.236.169.---)
Date: December 05, 2006 02:23PM

that's why cyber and I always suggest that you guys should have habit to use full tag instead enable short_tag so your codes can be compatible w/ any server

Options: ReplyQuote


Sorry, only registered users may post in this forum.