PDA

View Full Version : Stuck on part 7


Grazy81
06-02-2008, 04:07 PM
Hi guy's i have been following these viedo tutorials in php and have found them to be very clear and well explained. as i am pretty new to this your software set up tutorials were particularly usefull. However i have run into a few problems when running connection.php i am getting error on line 12

<?php


////////////////////
$database * "grazy";
$username * "grazy";
$password * "admin";
//////////////////////


$link * @mysql_connect("localhost", $username, $password);
$db * mysql_select_db($database, $link);


?>
This is the error code i get

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\web root\test\connections\connection.php on line 12

I was hoping you would be able to shed some light onto this as i am suspecting it is something silly i have messed up or a problem with connecting to the database i have created.

i would appreciate If you could help me with this as it has been driving me nuts for days now lol

davidj
06-02-2008, 08:38 PM
please tell me why you have * instead of = when defining your connection variables

Grazy81
06-02-2008, 09:01 PM
Ahhh that will be because i need to go to specsavers by the looks of it, i have changed it and it appears to be ok, now i will crack on with the rest of them, thanks for the help

Grazy81
06-02-2008, 09:15 PM
I am having problems on the next part too now i am getting error

Warning: require_once(Connections/connection.php) [function.require-once (http://localhost/web%20root/test/connections/function.require-once)]: failed to open stream: No such file or directory in C:\wamp\www\web root\test\connections\query.php on line 5

Fatal error: require_once() [function.require (http://localhost/web%20root/test/connections/function.require)]: Failed opening required 'Connections/connection.php' (include_path='.;C:\php5\pear') in C:\wamp\www\web root\test\connections\query.php on line 5

This is the code i have entered


<?php
require_once ("connections/connection.php");

$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array ($result);


echo $row['field3'];

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>


However if i skip the connections/connections and just put in the info from the connections.php file it works and gives me the correct output so i'm suspecting there is a problem with accessing that file and i have made sure they are both in the same directory
C:\wamp\www\web root\test\connections\

davidj
06-02-2008, 09:27 PM
where are your files located

im guessing you have somehow saved the file with your code into the connections directory

your main page is in your connections dir yet you are still calling in the connections file from a place in your require once which doesnt exist

please read the errors your getting as they are very useful and provide you with information needed

Grazy81
06-02-2008, 09:36 PM
Yeah i got it now, origionally i had both files in the same folder but now i see where i was going wrong and was trying to call the connections folder from within the connections folder so now i have created the main page from the test directory and is working ok

Thanks again for your help

davidj
06-02-2008, 09:39 PM
the errors in php are really good. Gve you lots of info which help