# Sql works in phpmyadmin but doesnt through php

**URL:** <https://forum.kirupa.com/t/sql-works-in-phpmyadmin-but-doesnt-through-php/224497>\
**Category:** Uncategorized\
**Created:** [May 2, 2007, 8:32pm UTC](https://forum.kirupa.com/t/sql-works-in-phpmyadmin-but-doesnt-through-php/224497 "2007-05-02T20:32:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![2nd\_day](https://avatars.discourse-cdn.com/v4/letter/2/a4c791/32.png) [@2nd\_day](https://forum.kirupa.com/u/2nd_day)\
**Post date:** [May 2, 2007, 8:32pm UTC](https://forum.kirupa.com/t/sql-works-in-phpmyadmin-but-doesnt-through-php/224497/1 "2007-05-02T20:32:21Z")

</div>

Hi folks,

im trying to get some records out of my database… this is the part of the php script that creates the query:

```php
$hoofd = urldecode($_GET['main']);
$sub = urldecode($_GET['sub']);
$sql = "SELECT * FROM product WHERE subcat='$sub' AND hoofdcat='$hoofd' ORDER BY naam;";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
    echo "Er zijn geen producten om weer te geven!<br />";
}

```

when I echo my $sql this is what i get:

```auto
SELECT * FROM product WHERE subcat='@#$#%' AND hoofdcat='Thomas & Thomas' ORDER BY naam;

```

when I process this SQL query with Phpmyadmin I just get back the records… when I use my php script it just say ‘Er zijn geen producten…’

Isnt that kind of strange?
