0

is there something wrong with this syntax?

 SELECT * FROM tblcustomer WHERE uName LIKE '%%' AND tMonth = '3' ORDER BY uName ASC

i got this error.. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given..

EDIT

include 'settings.php';

$con = connectDB();
$mo = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
for($mm=1;$mm<13;$mm++) {
    if(strtolower($mo[$mm-1])==strtolower(trim($_GET['uMonth']))) {
        $xyz = $mm;
        break;
    } else {
        $xyz = date("n");
    }
}
$q = "SELECT * FROM tblcustomer WHERE uName LIKE '%" . $_GET['uName'] . "%' AND tMonth = '" . $xyz . "' ORDER BY uName ASC";
//echo $q;
//exit;
$r = mysql_query($q,$con);

while($row=mysql_fetch_array($r)) {
   echo $row['uName'];
 }
1
  • 1
    Could the query be failing for some reason? Bad connection, missing table, etc. That could cause mysql_query to return FALSE instead of a handle to the results. Commented Oct 29, 2010 at 16:45

2 Answers 2

1

The problem is not with the sql, it's with the way you call mysql_fetch_array(). Try posting your php code too.

Sign up to request clarification or add additional context in comments.

1 Comment

@vrynxzent You should not pass your connection variable $r to the mysql_query call, according to the documentation: php.net/manual/en/function.mysql-query.php
0

There's something wrong with your call to mysql_fetch_array(), not your query.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.