# Php code check

**URL:** <https://forum.kirupa.com/t/php-code-check/98224>\
**Category:** Uncategorized\
**Created:** [January 4, 2004, 9:24pm UTC](https://forum.kirupa.com/t/php-code-check/98224 "2004-01-04T21:24:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kill\_robot\_kill](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kill_robot_kill/32/359_2.png) [@kill\_robot\_kill](https://forum.kirupa.com/u/kill_robot_kill)\
**Post date:** [January 4, 2004, 9:24pm UTC](https://forum.kirupa.com/t/php-code-check/98224/1 "2004-01-04T21:24:24Z")

</div>

Can’t seem to figure out what is causing an error here.

```php
<?php
$user = " ****";
$pass = " ****";
$db = "***";

$link = mysql_connect("localhost", "$user", "$pass");
if (! $link) 
	die ("couldn't connect to MySQL");
mysql_select_db($db, $link) or die ("couldn't open $db: ".mysql_error());

$result = mysql_query("SELECT * FROM myDB WHERE id=1");
$a_row = mysql_fetch_array($result);
$num_rows =mysql_num_rows($result); 

print "$num_rows Rows 
 "; //prints 1 Rows
print $a_row; // prints Array

//each of these below cause an error

foreach($a_row as $key => $value) {
	print $key $value;
	}
	
while ($a_row)) { 
 print("yes"); 
}

?>

```
