PDA

View Full Version : Frist time connecting to mysql database: PHP error



Snot
06-12-2008, 08:49 PM
This is my first time working with php and databases and I would like some advice trying to connect them.

This is my database table fields

http://www.tarantuladatabase.com/tf.jpg

This is my field values

http://www.tarantuladatabase.com/fv.jpg

I am using two php files one of them is called connect.php and it only has the information to connect to my database. The other files is called echo.php. The form is at

http://www.tarantuladatabase.com/assets/pages/search.html

When I try and connect I am getting this error message


Warning: include(includes/connect.php) [function.include]: failed to open stream: No such file or directory in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 38

Warning: include() [function.include]: Failed opening 'includes/connect.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 38

Warning: mysql_query() [function.mysql-query]: Access denied for user 'e0120590'@'localhost' (using password: NO) in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 40

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 40

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 43

Warning: mysql_close(): no MySQL-Link resource supplied in /home/e0120590/public_html/tarantuladatabase.com/assets/php/echo.php on line 48

I am kinda stuck right here so any advice would be greatly appreciated.

Here are the files I'm working with http://www.tarantuladatabase.com/3_Files.zip

thetestingsite
06-12-2008, 10:44 PM
In this snippet of echo.php:



<?
include("includes/connect.php");
// now you are connected and can query the database
$request = mysql_query("select field1,field2 from table");

// loop through the results with mysql_fetch_array()
while($row = mysql_fetch_array($result)){
echo $row[0]." / ".$row[1]."<br>\n";
}

// don't forget to close the mysql connection
mysql_close();
?>


Change to:



<?
include('connect.php');
// now you are connected and can query the database
$request = mysql_query("select field1,field2 from table");

// loop through the results with mysql_fetch_array()
while($row = mysql_fetch_array($request)){
echo $row[0]." / ".$row[1]."<br>\n";
}

// don't forget to close the mysql connection
mysql_close();
?>


Hope this helps.

Snot
06-13-2008, 03:06 AM
* 1 / Arboreal
2 / Terrestrial
3 / Fossorial
4 /

I made this happn lol but not sure what it means


and here is my new code


<?
include("connect.php");
// now you are connected and can query the database
$query = "SELECT * FROM `common_traits` `habitat``humidity``speed``size``location``aggression`";
$request = mysql_query($query);
if($request == false)
{
user_error(mysql_error() . "<br />\n$query");
}

// loop through the results with mysql_fetch_array()
while($row = mysql_fetch_array($request)){
echo $row[0]." / ".$row[1]."<br>\n";
}

// don't forget to close the mysql connection
mysql_close();
?>

I am reading stuff and making some progress but it's just not added up. Nothing I have read tells me how to make my from do work.

I copyed the code off of a page I was reading that tells me how to code php i'm kinda picking stuff up bit by bit so i'm really thankful for any help you can give me. I think I learn code better when I can see an example of what should be happening.

Snot
06-13-2008, 05:27 AM
I think it got it?

http://www.tarantuladatabase.com/assets/pages/search.html