D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] PHP Scripts Continued



Thanks Neil

As soon as I renamed it php instead of php3 it worked!

And so I built my first script to access a database called "allusers"
with a table called "names" and having the fields "firstname",
"lastname", "streetaddr", "distaddr", "city", "county", "postcode",
"country".

Here is the script:-
<html>
<body>

<?php
$db=mysql_connect("localhost","root");
mysql_select_db("allusers",$db);
$result=mysql_query("SELECT*FROM names",$db);
printf("firstname:%<br>\n",mysql_results($result,0,"firstname"));
printf("lastname:%<br>\n",mysql_results($result,0,"lastname"));
printf("streetaddr:%<br>\n",mysql_results($result,0,"streetaddr"));
printf("distaddr:%<br>\n",mysql_results($result,0,"distaddr"));
printf("city:%<br>\n",mysql_results($result,0,"city"));
printf("county:%<br>\n",mysql_results($result,0,"county"));
printf("postcode:%<br>\n",mysql_results($result,0,"postcode"));
printf("country:%<br>\n",mysql_results($result,0,"country"));
?>

</body>
</html>

It doesn't do what I want it to do. i.e. Display all the records! Here
is the output from Mozilla.

Warning: Access denied for user: 'root@xxxxxxxxx' (Using password: NO)
in /var/www/html/test.php on line 5

Warning: MySQL Connection Failed: Access denied for user:
'root@xxxxxxxxx' (Using password: NO) in /var/www/html/test.php on line
5

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link
resource in /var/www/html/test.php on line 6

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /var/www/html/test.php on line 7

Fatal error: Call to undefined function: mysql_results() in
/var/www/html/test.php on line 8

Can anybody help and is there a way of storing the password value so
that it is available to users without giving it out?

Thanks

Rich



--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly