0

The database in mysql(xampp) is called bodymechanix and the table is called clients1. In the table theres two columes, first_4 and last_4. I keep getting this message after submitting the form "MySQL returned an empty result set (i.e. zero rows). (Query took 0.0010 seconds.)" and the data is not visable in mysql Here is a piece of my code...thank you! This is my database, it wont even show the table with data like my other databases

<input class="form-textbox validate[required]" type="text" size="10" name="q4_name[first]" id="first_4" />
<label class="form-sub-label" for="first_4" id="sublabel_first" style="min-height: 13px;"> First Name </label>

<input class="form-textbox validate[required]" type="text" size="15" name="q4_name[last]" id="last_4" />
<label class="form-sub-label" for="last_4" id="sublabel_last" style="min-height: 13px;"> Last Name </label>

<button id="input_2" type="submit" class="form-submit-button">
Submit </button>

<?php
if(isset($_POST["input_2"])){

    $q4_name[first]=$_POST['q4_name[first]'];
    $q4_name[last]=$_POST['q4_name[last]'];

    $con=mysqli_connect('localhost','root','') or die(mysqli_error($con));
    mysqli_select_db($con,'bodymechanix') or die("cannot select DB");

    $query=mysqli_query($con, "SELECT * FROM clients WHERE          first_4='".$q4_name[first]."' AND last_4='".$q4_name[last]."'");
    $numrows=mysqli_num_rows($query);
    if($numrows!=0)
    {
    while($row=mysqli_fetch_assoc($query))
    {
    $dbfirst_4=$row['first_4'];
    $dblast_4=$row['last_4'];
    }
?>  
  • 1
    [Little Bobby](http://bobby-tables.com/) says ***[your script is at risk for SQL Injection Attacks.](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php)*** Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! [Don't believe it?](http://stackoverflow.com/q/38297105/1011527) – Jay Blanchard Nov 30 '16 at 13:49
  • 1
    `$_POST['q4_name[first]'];` => `$_POST['q4_name']['first'];` – Qirel Nov 30 '16 at 13:49
  • check your error_reporting and fix all noticed and warnings ... hint ... read how to quote in php – donald123 Nov 30 '16 at 13:49
  • `if(isset($_POST["input_2"])){` this will also fail you, because there is nothing with `name="input_2"`, just `id="input_2"` (won't work with ids) – Qirel Nov 30 '16 at 13:51
  • Thanks fot the replies! input_2 is the submit button, do i change it to the class? (form-submit-button) – Aaron Kavanagh Nov 30 '16 at 15:39

0 Answers0