-2

When I run my webpage No matter which code i use i always get this error

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/33/10729533/html/website/panel.php on line 67

Here is my code

<?php
$connect = mysql_connect("N/A","N/A","N/A");
mysql_select_db("cdkeys");
$query = mysql_query("SELECT * FROM cdkeys WHERE = 'cdkeys'");
WHILE($rows = mysql_fetch_array($query)):

    $cdkeys = $rows['cdkeys'];

    echo "$cdkeys";

    endwhile;
?>
  • 1
    use `$query = mysql_query("SELECT * FROM cdkeys WHERE = 'cdkeys'") or die(mysq_error())`; to get the error – Suhel Meman Apr 15 '13 at 10:41
  • [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**red box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – tereško Apr 15 '13 at 21:48

3 Answers3

0

there is a mistake in your SELECT sintax

$query = mysql_query("SELECT * FROM cdkeys WHERE = 'cdkeys'");

as you see you missed in sintax to include what field is equal to cdkeys.
please change to

$query = mysql_query("SELECT * FROM `cdkeys` WHERE `FIELD` = 'cdkeys'");

NOTE: change FIELD with actual field of your table

REFERENCE here

Fabio
  • 22,442
  • 12
  • 51
  • 63
0

Your query is wrong column name is missing in where clause

Change

$query = mysql_query("SELECT * FROM cdkeys WHERE = 'cdkeys'");

to

$query = mysql_query("SELECT * FROM cdkeys WHERE columname = 'cdkeys'");
chandresh_cool
  • 11,600
  • 3
  • 27
  • 44
0

Change

$query = mysql_query("SELECT * FROM cdkeys WHERE = 'cdkeys'");

to

 $query = mysql_query("SELECT * FROM cdkeys WHERE  columnname = 'cdkeys'");
Bhavin Rana
  • 1,530
  • 4
  • 18
  • 38