[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Beginner PHP Tutorial – 132 – LIKE With a Search Engine Example Part 3
by
Tags:
Comments
10 responses to “Beginner PHP Tutorial – 132 – LIKE With a Search Engine Example Part 3”
-
mysql_real_escape_string — Escapes special characters in a string for use in an SQL statement.
-
<?php
/Fazer procura numa base de dados//Fichero que liga à base de dados./
require 'connect.php';/Procura numa base de dados/
if(isset($_POST['search_name'])){$search_name = strtolower($_POST['search_name']);
if(!empty($search_name)){
/* Acrescentar segurança, ".VARIAVEL AQUI." e depois usar mysqli_real_escape_string */
$query = "SELECT name FROM names WHERE name LIKE '%".mysqli_real_escape_string($mysqlcon,$search_name)."%'";/Corre-se a Query/
if ($query_run = mysqli_query($mysqlcon,$query)){
//echo 'Query Sucess';//Only prints out info if it finds any
if(mysqli_num_rows($query_run) == NULL){
echo 'No results found in the database';
}else{
/RIP mysql_fetch_assoc/
foreach($query_run as $query_row){
$name = $query_row['name'];
echo $name.'<br>';
}
}
}else {
//mysql_error() doesnt work;
echo 'Query Fail';
}}
}
?> -
you speak fast too fast to understand !!!!
-
Add the ( names ) table to your connect.inc.php file if you having problem with mysql_num_rows.
-
Can't wait until AJAX (tut 171)
-
errors every fucking time
-
why not use isset() function?
-
You need too use `(apostrofies) ,which is under "Esc" not ' single quotation marks
-
@DesmondOO11 do you know how to create an image search engine….if you know…can you teach me….i really wanted to learn it
-
for all ppl have mysql_num_rows problem change
query = "SELECT 'bookName' FROM 'book' WHERE 'Title' LIKE '%".mysql_real_escape_string($search)."%' ";to
query = "SELECT Name FROM book WHERE Title LIKE '%".mysql_real_escape_string($search)."%' ";
Leave a Reply