Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2004, 12:50 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default trying to view this file

i am trying to view this file http://www.dcobbinah.co.uk/datadatabasebase/viewdb.php but its not happening at all. here is the code for that file. please can someone tell me what the problem is!!

Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
//$db = mysql_connect_db("localhost","","");
//$db=mysql_connect('localhost','root');
$user="dcobbina";
$host="localhost";
$password="aDoGoovAc";
$database="danny";
$connection=mysql_connect($host,$user,$password) or die ("could not connect to server");
$db=mysql_select_db($database,$connection);
//mysql_select_db("danny",$db);
$result = mysql_query("select * from personell",$connection);
echo "<table border=0 cellpadding=2 cellspacing=2 >";
echo "<tr><td><b>first name</b></td><td><b>last name</b></td><td><b>nick name</b></td><td><b>email</b></td><td><b>salary</b></td></tr>";
while ($myrow = mysql_fetch_array($result))
{
echo "<tr><td>";
echo $myrow["firstname"];
echo "<td>";
echo $myrow["lastname"];
echo "<td>";
echo $myrow["nickname"];
echo "<td>";
echo $myrow["email"];
echo "<td>";
echo $myrow["salary"];
}
echo "</table>";
?>
</body>
</html>
 
Old March 5th, 2004, 12:52 PM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is what i get on the viewdb.php page

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/dcobbina/datadatabasebase/viewdb.php on line 21

first name last name nick name email salary

 
Old March 5th, 2004, 05:32 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

You need to get more info on your error.

Try this:

//previous line
$result = mysql_query($result = mysql_query("select * from personell",$connection) or die(mysql_error());
//next line

This will give you a more detailed description of the error.

HTH,

----------
---Snib---
----------
 
Old March 12th, 2004, 04:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I notice that you don't check to make sure that mysql_select_db() failed...

Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to view a video with flv file rahulcbr PHP How-To 1 September 25th, 2008 01:21 AM
View txt File as DOS Format suresh.cgmohan VB How-To 2 September 27th, 2006 07:40 AM
Using an ear file to view source code amerwaip J2EE 1 July 21st, 2005 11:05 AM
Opening a .doc file for view Shoedat Beginning VB 6 2 June 14th, 2003 02:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.