[Chugalug] another LAMP problem

William Wade willm.wade at gmail.com
Fri Mar 15 02:03:47 UTC 2013


Try running it at the command line. See what happens. It should still print
out the stuff. This way you can take Apache out of the loop and test just
PHP and code.

$ php filename.php

Wil


On Thu, Mar 14, 2013 at 9:28 PM, Garrett Gaston <garrett85 at hotmail.com>wrote:

> 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
>
> _______________________________________________
> 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/edcdf1e9/attachment-0001.html>


More information about the Chugalug mailing list