[Chugalug] another LAMP problem

Garrett Gaston garrett85 at hotmail.com
Fri Mar 15 01:28:53 UTC 2013


Thanks guys, I'll try some of this out. People from several different forums have replied back that my code worked fine on their system so I'M thinking that this isn't a syntax problem.

Date: Thu, 14 Mar 2013 23:12:27 +0000
From: cluon at geeklabs.com
To: chugalug at chugalug.org
Subject: Re: [Chugalug] another LAMP problem

<?php
$con=mysqli_connect("localhost","dbuser","dbpasswd","dbname");
if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error() ; } ;
$result = mysqli_query($con, "SELECT uniq,name FROM customers") ;
if(!$result) {
   echo "MySQL Error: " . mysqli_error($con) . "\n";
} else {
   while ( $row = mysqli_fetch_array($result,MYSQLI_ASSOC) ) {
     print $row['uniq'] . ' ' . $row['name'] . " <br>\n" ;
   } ;
}
?>
 
The slight variation above just worked on my system,
 
I demand the brackets be in the format as above. Not on their own lines,
but that's a personal religion thing. I can affirm that my beliefs work 
well for me when applied consistently.
 
 
 
============================================================
Mike Harrison   bogon at geeklabs.com  cell: 423.605.6943
 
On Thu, 14 Mar 2013, Garrett Gaston wrote:
 
> Having overcome my last LAMP problem I've hit another problem almost immediately. My apache server seems to be working just fine as does php, I'm able to execute phpinfo()
> without a problem. I wrote a little php to query a few lines in a VERY simple MySQL database. When the page loads it's a blank web page, no errors and no results. There are two
> entries in the table that I'M trying to query so I would expect to see two lines outputted as html. The code is below. Any ideas? Note that fname & lname are just variable I
> retrieved from an html form via $_POST.
> 
> // Create connection
> $con=mysqli_connect("localhost","lrngsql","xyz","bank");
> 
> // Check connection
> if (mysqli_connect_errno($con))
>   {
>   echo "Failed to connect to MySQL: " . mysqli_connect_error();
>   }
> 
> $result = mysqli_query($con, "SELECT fname, lname FROM person");
> 
> if(!$result)
> {
>     echo "MySQL Error: " . mysqli_error($con) . "\n";
> }
> 
> else
> {
>     while($row = mysqli_fetch_array($result))
>     {
>         echo $row['fname'] . " " . $row['lname'];
>         echo "<br />";
>     }
> }
> 
>

_______________________________________________
Chugalug mailing list
Chugalug at chugalug.org
http://chugalug.org/cgi-bin/mailman/listinfo/chugalug 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20130314/dfc685c0/attachment.html>


More information about the Chugalug mailing list