2

I have a code like this, this is the line 16:

$query=mysql_query("select harga from pakaian where 'kodeb'=$kode") or die($query. "<br/><br/>".mysql_error());

$harga=mysql_fetch_row($query);

and when i run it, it showed:

Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\project\orderphp.php on line 16

What's wrong with it? I don't understand

Jessica Andreas
  • 21
  • 1
  • 1
  • 2
  • Also, you have a potential SQL injection vulnerability here, unless you know of course that the $kode variable will always be safe. – Wander Nauta Apr 27 '13 at 10:18

3 Answers3

2
$query=mysql_query("SELECT harga FROM pakaian WHERE kodeb = '$kode'") or die($query. "<br/><br/>".mysql_error());
Amir
  • 4,089
  • 4
  • 16
  • 28
0
$query = mysql_query("select harga from pakaian where kodeb='" . $kode . "'") or die ... 
Freeman Lambda
  • 3,567
  • 1
  • 25
  • 33
0

mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\project\orderphp.php on line 16 -- means that it's returning false, so your query is failing. Amir has the right answer, but just did not explain what was wrong with your code.

half-fast
  • 302
  • 1
  • 7