include command
Posted by: magic8ball (---.range81-129.btcentralplus.com)
Date: May 24, 2007 03:50PM

i am having a nightmare with this, cannot seem to get it to work with the command include "mysql.php"

I have written a basic php script to lookup the database:

<?php
session_start();
include "mysql.php";
$games = "SELECT game, played, venue FROM games";
$game = mysql_query($games, $c);
while($row = mysql_fetch_assoc($game))
{
echo "Game: {$row['game']}".
"Played: {$row['played']}".
"Venue: {$row['venue']}";
}
?>

I get the following error


Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\wamp\www\indexmd.php on line 17

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\wamp\www\indexmd.php on line 19

However if i take out include "mysql.php" and put the code from that file in its place it works fine.

Any ideas?


Options: ReplyQuote
Re: include command
Posted by: dval (---.chrcitadelle.be)
Date: May 24, 2007 04:16PM

>However if i take out include "mysql.php" and put the code from that file in its place it >works fine.

try to change the name of the file mysql.php to test1.php (for example) because "mysql" is a reserved word ?

also check that there are not only one space or character before the code in the file included ?



Post Edited (05-24-07 16:59)

Dval
(depuis la Belgique, enfin encore pour l'instant... pfff. quel pays :-)

Options: ReplyQuote
Re: include command
Posted by: CyberSpatium (71.237.217.---)
Date: May 25, 2007 01:27AM

post your mysql.php code


CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!

Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.

Web Development for Newbie's Blog

Options: ReplyQuote
Re: include command
Posted by: magic8ball (---.range81-129.btcentralplus.com)
Date: May 25, 2007 11:37AM

<?php

$c = mysql_connect('localhost','root','password') or die(mysql_error());
mysql_select_db('cricket',$c);

?>

Options: ReplyQuote
Re: include command
Posted by: CyberSpatium (71.237.217.---)
Date: May 25, 2007 04:59PM

change:
include "mysql.php";

to
require "mysql.php";

include() and require() are exactly the same except for one detail, how they handle errors. if you use require() to include a file and the file cannot be found, it returns a fetal error and stops the script. if you use include() and the included file cannot be found, php just produces a notice, but does not stop execution of the script.. the default error reporting seting for php is to only show serious errrors like parse errors and warnings, not notices.

so, after you change include() to require() you will now get file not found error. this is because you have not pointed to the correct path of your mysql.php file.


CyberSpatium
----------------------
WAMP English Forum Admin

Need help? Check out my WAMP User Manual/Guide here!

Check out my new blog. It is for web developers, and especially tailored for the web development newbie. If you are not fluent in “geek speak”, then this incredible resource is just you. And even if you are a web development pro, this is a great resource to check out some of the latest web development tips, news, tutorials, codes and more.

Web Development for Newbie's Blog

Options: ReplyQuote


Sorry, only registered users may post in this forum.