Re: whats wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Fri, Mar 30, 2012 at 11:45 PM, saeed ahmed <mycomputerbooks@xxxxxxxxx> wrote:
> i have made a php script with a tutorial help....i dont know where is a
> error.please have a look
>

Your code below assumes that everything is perfect in your world.  IE:
 no network connectivity issue, all firewall related are properly
configured, the user account actually exists and have the right
permissions, the database exists and so are the table(s), etc....  I
suggest you revisit the official PHP manual and read about each
function you're using.

>
> <?php
> //connect and select a database
> mysql_connect("localhost","root"," " );

for starters,

http://php.net/function.mysql-connect

Noticed the result returned.  You didn't bother to check whether if
it's successful or not.  If not why not?  Since the DB is on the same
box, is the firewall, if any, configured properly?  If there's no
firewall or if it's configured properly, is the account valid and have
the right permissions?  Is the MySQL server running on the default
port 3306?

If you don't know how to configure each of the above mentioned, allow
me to introduce you a new friend, Google ;)  Both of those topics are
beyond the scope of this list.

HTH,
Tommy

> mysql_select_db("addressbook");
> //Run a query
> $result=mysql_query("select("SELECT*FROM COLLEAGUE");
> ?>
> <!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>
> <title>Address Book</title>
> <meta http-equiv="content-type" content="text/html;charset=utf-8"
> </head>
> <body>
> <h1>Address Book<h1>
> <table Border="1" cellpadding="2"cellspacing="3"
> summary="table holda colleague contacts information">
> <tr>
> <th> ID</th>
> <th>First Name</th>
> <th>Last Name</th>
> <th>Telephone</th>
> <th>Email Address</th>
> </tr>
> <?php
> //LOOP through all table rows
> while ($row=mysql_fetch_array($result)) {
> echo"<tr>";
> echo"<td>".$row['id'] . "</td>;
> echo "<td>" . $row['firstName'] . "</td>";
> echo "<td>" . $row['lastName'] . "</td>";
> echo "<td>" . $row['telephone'] . "</td>";
> echo "<td>" . Srow['email'] . "</td";
> echo"</tr>";
> }
> //free result memory and close database connection
> mysql_free_result($result);
> mysql_close();
> ?>
> </table>
> </body>
> </html>
> thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [Find Someone]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux