Jump to content

Recommended Posts

mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xamp

 

 

<?php

include('config.php');

include('array.php');

$q=$_GET['q'];

 

 

$sql = "\n"

    . "select * from harta_modal where Siri Pembuat like \'$q%\'\n"

    . "union\n"

    . "select * from harta_modal_printer where Siri Pembuat like \'$q%\'\n"

    . "union\n"

    . "select * from harta_moda_notebook where Siri Pembuat like \'$q%\'\n"

. "union\n"

."select * from harta_moda_rangkaian where Siri Pembuat like \'$q%\'\ LIMIT 0, 30 ";

 

$result=mysql_query($sql);

 

 

print "<table border='1'>

<tr>

<th>Jenama</th>

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['Jenama'] . "</td>";

  echo "</tr>";

  }

echo "</table>";

 

 

 

 

?>

Link to comment
https://forums.phpfreaks.com/topic/264420-whats-wrong-with-it/
Share on other sites

If "Siri Pembuat" is actually the name of a field then

1. Shame on you for putting spaces in a field name.

2. Quote it with backticks.

 

And you're vulnerable to SQL injection. Fix it:

$qsafe = mysql_real_escape_string($q);

"select ... like \'$qsafe\'\n"

Link to comment
https://forums.phpfreaks.com/topic/264420-whats-wrong-with-it/#findComment-1355074
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.