search isnt working but im not sure why

i need some real help here guys, i cannot get this code to work and im at my wits end, ive looked it over and over and it just doesnt wanna work, even though at one poin ti did have it working suddenly it just doesnt wanna work and i cant see why, i think maybe i have been working on this too long and im just not able to see my error but i needed a second opinion on it.

[php]

<?php $con = mysqli_connect("localhost", "root", "", "numbers") or die(mysqli_error($con)); $k = NULL; if(isset($_GET['submit'])) { $k = $_GET['k']; } ?> nav { width: 100%; float: left; margin: 0 0 1em 0; padding: 0; background-color: #f2f2f2; border-bottom: 1px solid #ccc; } ul { list-style: none; width: 800px; margin: 0 auto; padding: 0; } li { float: left; } li a { display: block; padding: 8px 15px; text-decoration: none; font-weight: bold; color: #069; border-right: 1px solid #ccc; } li:first-child a { border-left: 1px solid #ccc; } li a:hover { color: #c00; background-color: #fff; }
<link href="style.css" rel="stylesheet" type="text/css" />

<!-- script that will only allow numbers to be entered into a text box, also limits them to 10 numbers-->
<script type="application/javascript">

function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

     return true;
  }

Personal Searchables



Example: 1112223333

<?php $min_length = 10; if(strlen($k) == $min_length) { //filter out non numeric and special characters $k = mysqli_real_escape_string($con, $_GET['$k']); echo ""; echo ""; echo "
".$k."
"; $query = "SELECT * FROM numdata WHERE numb='".$k."'"; $query2 = "SELECT * FROM numdata2 WHERE numb='".$k."'"; $query3 = "SELECT * FROM numdata3 WHERE numb='".$k."'"; $query4 = "SELECT * FROM numdata4 WHERE numb='".$k."'"; $query5 = "SELECT * FROM numdata5 WHERE numb='".$k."'"; $query6 = "SELECT * FROM numdata6 WHERE numb='".$k."'"; $query7 = "SELECT * FROM numdata7 WHERE numb='".$k."'"; $query8 = "SELECT * FROM numdata8 WHERE numb='".$k."'"; $query9 = "SELECT * FROM numdata9 WHERE numb='".$k."'"; $query10 = "SELECT * FROM numdata10 WHERE numb='".$k."'"; $query11 = "SELECT * FROM usernumdata WHERE numb='".$k."'"; $raw_results = mysqli_query($con, $query); $raw_results2 = mysqli_query($con, $query2); $raw_results3 = mysqli_query($con, $query3); $raw_results4 = mysqli_query($con, $query4); $raw_results5 = mysqli_query($con, $query5); $raw_results6 = mysqli_query($con, $query6); $raw_results7 = mysqli_query($con, $query7); $raw_results8 = mysqli_query($con, $query8); $raw_results9 = mysqli_query($con, $query9); $raw_results10 = mysqli_query($con, $query10); $raw_results11 = mysqli_query($con, $query11); $error = "
" ; if(mysqli_num_rows($raw_results) > 0) { if($results = mysqli_fetch_array($raw_results)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results2) > 0) { if($results = mysqli_fetch_array($raw_results2)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results3) > 0) { if($results = mysqli_fetch_array($raw_results3)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results4) > 0) { if($results = mysqli_fetch_array($raw_results4)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results5) > 0) { if($results = mysqli_fetch_array($raw_results5)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results6) > 0) { if($results = mysqli_fetch_array($raw_results6)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results7) > 0) { if($results = mysqli_fetch_array($raw_results7)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results8) > 0) { if($results = mysqli_fetch_array($raw_results8)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results9) > 0) { if($results = mysqli_fetch_array($raw_results9)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results10) > 0) { if($results = mysqli_fetch_array($raw_results10)) { echo "$error" ; } } elseif(mysqli_num_rows($raw_results11) > 0) { if($results = mysqli_fetch_array($raw_results11)) { echo "$error" ; } } else{ echo ""; echo "
Phone Number
Registered Number: CANNOT CALL!!
Unregistered Number: CALLING PERMITTED
"; } } else{ $length = "Remember Phone Number Must be ".$min_length. " Digits Long and Contain all Numeric Characters"; echo "
".$length."
"; } ?>
Add a New Number to the Do Not Call List
Employee Name:
Customer First Name:
Customer Last Name:
Customer Email:
Phone Number:
<?php //submission code, inserting data into mysql database $newnum = NULL; $mySqlDate = date('Y-m-d'); $mySqlTime = date('g:i a'); if(isset($_GET['add'])) { $empname = $_GET['empname']; $newnum = $_GET['newnum']; $firstname = $_GET['firstname']; $lastname = $_GET['lastname']; $email = $_GET['email']; } if(strlen($newnum) == $min_length) { //filter out non numeric and special characters $empname = mysqli_real_escape_string($con, $_GET['empname']); $newnum = mysqli_real_escape_string($con, $_GET['newnum']); $firstname = mysqli_real_escape_string($con, $_GET['firstname']); $lastname = mysqli_real_escape_string($con, $_GET['lastname']); $email = mysqli_real_escape_string($con, $_GET['email']); $check = mysqli_query($con, "SELECT count(*) FROM usernumdata WHERE numb = '".$newnum."'") or die(); $row = mysqli_fetch_row($check); if ($row[0] == 0) { $sql="INSERT INTO usernumdata (empname, numb, firstname, lastname, email, date, time) VALUES ('".$empname."','".$newnum."','".$firstname."','".$lastname."','".$email."','".$mySqlDate."','".$mySqlTime."')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "
Successfully Added New Entry
"; } else { echo "
Number Already Exists In Do Not Call List
"; } } else{ $length = "Remember Phone Number Must be ".$min_length. " Digits Long and Contain all Numeric Characters"; echo "
".$length."
"; } ?>

[/php]

any help at all is greatly appreciated guys

You’re going to have to help narrow down the issue, we’re not going to go through your whole 300+ lines of code to find the issue. You haven’t even told us what it isn’t or is doing or any errors you get when the page runs. I can see for sure that you need a better database structure, running 10 queries in a row to get the data is just stupid.

I agree with Fatsol on your data structure. Looking down the code it is just some sort of simple
do-not-call list, but, why so very many tables, fields and insane if-then’s? None of this is needed
for a simple do-not-call list. Perhaps you did not show all your code or we are missing what you
are trying to do.

So, please rephrase your question. Include what you are attempting to do. Normally to check a
table for a prior entry, you just do a select and check the number of rows. But, you add in the
“WHERE” option. So, not sure what you are attempting… Let us know…

Sponsor our Newsletter | Privacy Policy | Terms of Service