--- In [email protected], Tedit kap <[EMAIL PROTECTED]> wrote:
>
> I copied this from somewhere as I want to connect to mysql using
php for the first time but when I execute the program below there is
only blank screen (I already inserted a test row to my table.)
>
> 1-In the program below what does $yourfield refer to?
>
> 2-Isn't this supposed to display the contents of my table? It is
not displaying anything.
>
> Can someone help? Thanks
>
> <?php
> //Connect To Database
> $hostname='. ......... ....';
> $username='. ......... ....';
> $password='. ......... .......';
> $dbname='... ........' ;
> $usertable=' ......... ....';
> $yourfield = '........... ..';
> mysql_connect( $hostname, $username, $password) OR DIE ('Unable to
connect to database! Please try again later.');
> mysql_select_ db($dbname) ;
> $query = 'SELECT * FROM $usertable';
> $result = mysql_query( $query);
> if($result) {
> while($row = mysql_fetch_ array($result) ){
> $name = $row['$yourfield' ];
> echo 'Name: '.$name;
> }
> }
> ?>
>
> __________________________________________________

1. Remove the single quete at $name = $row['$yourfield' ];
to be just : $name = $row[$yourfield];

2. $yourfield  is the field you want to output to the user
3. Most reasons for white pages is a hidden error at the page,
try to show all type of errors by changing this from php.ini

Reply via email to