PHP code doesn't return any results from MySQL Database -


i have problem connecting mysql search fields. php code looks logical doesn't show results. direct search in mysql working absolutely fine. when comes website search doesn't work.

i removed/swapped host, user, password, dbname before pasted here.

thank help!

<body>  <?php $q = intval($_get['q']);  $con = mysqli_connect('host','user','password','dbname'); if (!$con) {     die('could not connect: ' . mysqli_error($con)); }  mysqli_select_db($con,"dbname"); $sql="select * user id = '".$q."'"; $result = mysqli_query($con,$sql);  echo "<table> <tr> <th>first name</th> <th>last nname</th> <th>city/village</th> <th>oblast</th> <th>language</th> <th>download</th> </tr>"; while($row = mysqli_fetch_array($result)) {     echo "<tr>";     echo "<td>" . $row['firstname'] . "</td>";     echo "<td>" . $row['lastname'] . "</td>";     echo "<td>" . $row['cityvillage'] . "</td>";     echo "<td>" . $row['oblast'] . "</td>";     echo "<td>" . $row['language'] . "</td>";     echo "<td>" . $row['download'] . "</td>";     echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> 

try changing line:

$sql="select * user id = '".$q."'"; 

to this:

$sql="select * user id = '$q'"; 

your concatenation , dropping out of query appears causing problems.

note vulnerable sql injection. since using mysqli, may wish consider using mysqli prepared statements.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -