Practice PHP code thats not working (with no error codes)

Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards. <html> <head> <title>PHP Test</title> </head> <body> <?php //SQL Part $host="localhost"; $username="root"; $password="*****"; $conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error()); mysql_select.db('sample') or exit("Database not found"); //Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers"); while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>

Hey! Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db <html> <head> <title>PHP Test</title> </head> <body> <?php //SQL Part $host="localhost"; $username="root"; $password=""; $conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error()); mysql_select_db('sample') or exit("Database not found"); //Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn); while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html> On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records. On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim <kiprotich.maritim@gmail.com
wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Ok! I just tweaked your code a little, Update the code as suits you! <?php //Define database connection $connection = mysql_connect('host', 'username', 'password'); //Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if $customers = mysql_query('select * from Customers', $connection); while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; } mysql_close($connection); On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Looks like the same problem (*'; } mysql_close($connection); ?>*) On Fri, Jul 26, 2013 at 3:31 PM, Eugene Maritim <kiprotich.maritim@gmail.com
wrote:
Ok! I just tweaked your code a little, Update the code as suits you!
<?php
//Define database connection $connection = mysql_connect('host', 'username', 'password');
//Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; }
mysql_close($connection);
On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

<?php //Define database connection $dblink = mysql_connect("localhost","root","") or die("Could not connect"); mysql_select_db("sample") or die(mysql_error()); $query = mysql_query("select * from Customers"); while($row = mysql_fetch_array($query)) { $name = $row['CustomerName']; $cname= $row['ContactName']; } echo '<div>' .$name. $cname. '</div>'; mysql_close($dblink); ?> Check your table name if C is in uppercase or lowercase. On Fri, Jul 26, 2013 at 4:01 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Looks like the same problem (*'; } mysql_close($connection); ?>*)
On Fri, Jul 26, 2013 at 3:31 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Ok! I just tweaked your code a little, Update the code as suits you!
<?php
//Define database connection $connection = mysql_connect('host', 'username', 'password');
//Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; }
mysql_close($connection);
On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards, Yegon Victor | Web Specialist/Internet Consultant |

(' .$name. $cname. ''; mysql_close($dblink); ?>) Hey thats is what I'm getting.. Still looks the same as before.. On Fri, Jul 26, 2013 at 5:13 PM, Victor Yegon <viktayeg@gmail.com> wrote:
<?php
//Define database connection
$dblink = mysql_connect("localhost","root","") or die("Could not connect"); mysql_select_db("sample") or die(mysql_error());
$query = mysql_query("select * from Customers");
while($row = mysql_fetch_array($query)) {
$name = $row['CustomerName']; $cname= $row['ContactName']; }
echo '<div>' .$name. $cname. '</div>';
mysql_close($dblink); ?>
Check your table name if C is in uppercase or lowercase.
On Fri, Jul 26, 2013 at 4:01 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Looks like the same problem (*'; } mysql_close($connection); ?>*)
On Fri, Jul 26, 2013 at 3:31 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Ok! I just tweaked your code a little, Update the code as suits you!
<?php
//Define database connection $connection = mysql_connect('host', 'username', 'password');
//Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; }
mysql_close($connection);
On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati <nduatiandrew@gmail.com
wrote:
Good Afternoon Skunks, Below is my PHP code that is meant to run an SQL Select query however it doesn't seem to be working. All I'm getting when I open it in the browser (*"; } mysql_close($con); ?> "*) Please assist. Kind regards.
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="*****";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select.db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query($conn,"SELECT * FROM Customers");
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards,
Yegon Victor | Web Specialist/Internet Consultant |
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke

Code is not executing in the first place; you'd at least expect a PHP error. Check your PHP installation; do a "Hello World"; the phpinfo()?.. make sure that your file is a .php (not php.txt....) - means you have to unhide file extensions. On Fri, Jul 26, 2013 at 6:15 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
(' .$name. $cname. ''; mysql_close($dblink); ?>) Hey thats is what I'm getting.. Still looks the same as before..
On Fri, Jul 26, 2013 at 5:13 PM, Victor Yegon <viktayeg@gmail.com> wrote:
<?php
//Define database connection
$dblink = mysql_connect("localhost","root","") or die("Could not connect"); mysql_select_db("sample") or die(mysql_error());
$query = mysql_query("select * from Customers");
while($row = mysql_fetch_array($query)) {
$name = $row['CustomerName']; $cname= $row['ContactName']; }
echo '<div>' .$name. $cname. '</div>';
mysql_close($dblink); ?>
Check your table name if C is in uppercase or lowercase.
On Fri, Jul 26, 2013 at 4:01 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Looks like the same problem (*'; } mysql_close($connection); ?>*)
On Fri, Jul 26, 2013 at 3:31 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Ok! I just tweaked your code a little, Update the code as suits you!
<?php
//Define database connection $connection = mysql_connect('host', 'username', 'password');
//Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; }
mysql_close($connection);
On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Hey!
Find edited code below: 1. Swapped the order params of mysql_select 2. Changed mysql_select.db to mysql_select_db
<html> <head> <title>PHP Test</title> </head> <body> <?php
//SQL Part $host="localhost"; $username="root"; $password="";
$conn= mysql_connect($host,$username,$password) or exit("Connection Error".mysql_error());
mysql_select_db('sample') or exit("Database not found");
//Data from the query is stored in $result $result = mysql_query("SELECT * FROM profiles", $conn);
while($row = mysql_fetch_array($result)) { echo $row['CustomerName'] . " " . $row['ContactName']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati < nduatiandrew@gmail.com> wrote:
> Good Afternoon Skunks, > Below is my PHP code that is meant to run an SQL Select > query however it doesn't seem to be working. All I'm getting when I open it > in the browser (*"; } mysql_close($con); ?> "*) > Please assist. > Kind regards. > > > > <html> > <head> > <title>PHP Test</title> > </head> > <body> > <?php > > > //SQL Part > $host="localhost"; > $username="root"; > $password="*****"; > > > $conn= mysql_connect($host,$username,$password) or exit("Connection > Error".mysql_error()); > > mysql_select.db('sample') or exit("Database not found"); > > //Data from the query is stored in $result > $result = mysql_query($conn,"SELECT * FROM Customers"); > > while($row = mysql_fetch_array($result)) > { > echo $row['CustomerName'] . " " . $row['ContactName']; > echo "<br>"; > } > mysql_close($conn); > ?> > </body> > </html> > > _______________________________________________ > skunkworks mailing list > skunkworks@lists.my.co.ke > ------------ > List info, subscribe/unsubscribe > http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks > ------------ > > Skunkworks Rules > http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 > ------------ > Other services @ http://my.co.ke >
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards,
Yegon Victor | Web Specialist/Internet Consultant |
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Samuel Waithaka http://twitter.com/samwaithaka

<?php error_reporting(E_ALL); ini_set('display_errors', 'on'); ?> /* paste the code above at the top of your script to enable error reporting and run the app from a browser. */ On 7/26/13, Samuel Waithaka <samwaithaka@gmail.com> wrote:
Code is not executing in the first place; you'd at least expect a PHP error. Check your PHP installation; do a "Hello World"; the phpinfo()?.. make sure that your file is a .php (not php.txt....) - means you have to unhide file extensions.
On Fri, Jul 26, 2013 at 6:15 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
(' .$name. $cname. ''; mysql_close($dblink); ?>) Hey thats is what I'm getting.. Still looks the same as before..
On Fri, Jul 26, 2013 at 5:13 PM, Victor Yegon <viktayeg@gmail.com> wrote:
<?php
//Define database connection
$dblink = mysql_connect("localhost","root","") or die("Could not connect"); mysql_select_db("sample") or die(mysql_error());
$query = mysql_query("select * from Customers");
while($row = mysql_fetch_array($query)) {
$name = $row['CustomerName']; $cname= $row['ContactName']; }
echo '<div>' .$name. $cname. '</div>';
mysql_close($dblink); ?>
Check your table name if C is in uppercase or lowercase.
On Fri, Jul 26, 2013 at 4:01 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Looks like the same problem (*'; } mysql_close($connection); ?>*)
On Fri, Jul 26, 2013 at 3:31 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
Ok! I just tweaked your code a little, Update the code as suits you!
<?php
//Define database connection $connection = mysql_connect('host', 'username', 'password');
//Select our database if(!mysql_select_db('sample')) { echo 'Could not connect to the database'; die(); }//if
$customers = mysql_query('select * from Customers', $connection);
while($profile = mysql_fetch_array($customers)) { echo $profile['CustomerName'] . ', ' . $profile['ContactName']; echo '<br/>'; }
mysql_close($connection);
On Fri, Jul 26, 2013 at 3:09 PM, Andrew Nduati <nduatiandrew@gmail.com>wrote:
Thanks for the response. The problem is still the same. I've just tried getting rid of the second echo but all I get is a blank screen. And I've confirmed that the DB has records.
On Fri, Jul 26, 2013 at 1:00 PM, Eugene Maritim < kiprotich.maritim@gmail.com> wrote:
> Hey! > > Find edited code below: > 1. Swapped the order params of mysql_select > 2. Changed mysql_select.db to mysql_select_db > > <html> > <head> > <title>PHP Test</title> > </head> > <body> > <?php > > > //SQL Part > $host="localhost"; > $username="root"; > $password=""; > > > > $conn= mysql_connect($host,$username,$password) or exit("Connection > Error".mysql_error()); > > mysql_select_db('sample') or exit("Database not found"); > > > //Data from the query is stored in $result > $result = mysql_query("SELECT * FROM profiles", $conn); > > > while($row = mysql_fetch_array($result)) > { > echo $row['CustomerName'] . " " . $row['ContactName']; > echo "<br>"; > } > mysql_close($conn); > ?> > </body> > </html> > > > > On Fri, Jul 26, 2013 at 2:46 PM, Andrew Nduati < > nduatiandrew@gmail.com> wrote: > >> Good Afternoon Skunks, >> Below is my PHP code that is meant to run an SQL Select >> query however it doesn't seem to be working. All I'm getting when I >> open it >> in the browser (*"; } mysql_close($con); ?> "*) >> Please assist. >> Kind regards. >> >> >> >> <html> >> <head> >> <title>PHP Test</title> >> </head> >> <body> >> <?php >> >> >> //SQL Part >> $host="localhost"; >> $username="root"; >> $password="*****"; >> >> >> $conn= mysql_connect($host,$username,$password) or exit("Connection >> Error".mysql_error()); >> >> mysql_select.db('sample') or exit("Database not found"); >> >> //Data from the query is stored in $result >> $result = mysql_query($conn,"SELECT * FROM Customers"); >> >> while($row = mysql_fetch_array($result)) >> { >> echo $row['CustomerName'] . " " . $row['ContactName']; >> echo "<br>"; >> } >> mysql_close($conn); >> ?> >> </body> >> </html> >> >> _______________________________________________ >> skunkworks mailing list >> skunkworks@lists.my.co.ke >> ------------ >> List info, subscribe/unsubscribe >> http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks >> ------------ >> >> Skunkworks Rules >> http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 >> ------------ >> Other services @ http://my.co.ke >> > > > _______________________________________________ > skunkworks mailing list > skunkworks@lists.my.co.ke > ------------ > List info, subscribe/unsubscribe > http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks > ------------ > > Skunkworks Rules > http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 > ------------ > Other services @ http://my.co.ke >
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Regards,
Yegon Victor | Web Specialist/Internet Consultant |
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
_______________________________________________ skunkworks mailing list skunkworks@lists.my.co.ke ------------ List info, subscribe/unsubscribe http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks ------------
Skunkworks Rules http://my.co.ke/phpbb/viewtopic.php?f=24&t=94 ------------ Other services @ http://my.co.ke
-- Samuel Waithaka http://twitter.com/samwaithaka
-- Regards, -- k n "Knowing is not enough; we must apply. Willing is not enough; we must do." - Bruce Lee
participants (5)
-
Andrew Nduati
-
Eugene Maritim
-
Samuel Waithaka
-
ukuta ken
-
Victor Yegon