# Simple Database Query mySQL

**URL:** https://forum.kirupa.com/t/simple-database-query-mysql/255136
**Category:** programming
**Created:** [March 19, 2008, 1:06pm UTC](https://forum.kirupa.com/t/simple-database-query-mysql/255136 "2008-03-19T13:06:28Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![DangerousDan](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@DangerousDan](https://forum.kirupa.com/u/DangerousDan)
#### Post date: [March 19, 2008, 1:06pm UTC](https://forum.kirupa.com/t/simple-database-query-mysql/255136/1 "2008-03-19T13:06:28Z")

</div>

Running a local database using apache server for PHP and I can’t get this to work, once the script hits any mySQL code it just stops. phpinfo() works.

```php

<?php
echo "SAY"; //this works
mysql_connect("localhost", "root", "somepass") or die(mysql_error());
mysql_select_db("responses") or die(mysql_error());
$query = "SELECT * FROM survey";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
echo "There are ".$rows." rows"; //this won't
?>

```

Am I missing something?  
I’m sure the info for the connect is right because I’m able to use them to connect to my database for a editting tool. :shifty:
