1
Okay, here’s the thing, I got this code:
<form style="" name="form">
<input placeholder="Search..." name="name" id="fn" type="text">
<input style="display: none ! important;" value="Search" id="search-btn" type="submit">
</form>
<div id = "results"></div>
<script type = "text/javascript">
$(document).ready(function(){
$('#results').load('search_results.php').show();
$('#search-btn').click(function(){
showValues();
});
$("#fn").keyup(function() {
if($(this).val().length >= 3)
showValues();
});
$(function() {
$('form').bind('submit',function(){
showValues();
return false;
});
});
function showValues() {
$.post('search_results.php', { name: form.name.value },
function(result){
$('#results').html(result).show();
});
}
});
</script>
.
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
include_once("../../cdn/lib/config.php");
$stmt = $db->query("SELECT * FROM films ORDER BY Title");
$stmt->execute();
$films = $stmt->fetchAll(PDO::FETCH_ASSOC);
isset( $_REQUEST['name'] ) ? $name=$_REQUEST['name'] : $name='';
if( empty( $name )){
foreach($films as $index => $row) { ?>
<div id="cover" class="img-thumbnail">
<div class="audiopt"></div>
<a href="<? echo $row['ID']; ?>" target="_self">
<div id="effect" class="img-thumbnail" alt="<? echo $row['Title']; ?>" title="<? echo $row['Title']; ?>"></div>
<img src="../../cdn/uploads/films/<? echo $row['Cover']; ?>" alt="<? echo $row['Title']; ?>" title="<? echo $row['Title']; ?>" class="img-thumbnail" />
</a>
</div>
<?
}
}
else{
$sql = "SELECT * FROM films WHERE Title LIKE ? ORDER BY Title"
$stmt = $db->prepare($sql);
$stmt->bindValue(1, '%'. $name .'%');
$stmt->execute();
$films = $stmt->fetchAll(PDO::FETCH_ASSOC);
if(empty($films)){?>
<div id="not-found">No films with this title (<b><? echo "$name" ?></b>)</div>
<?
}
else{
foreach($films as $index => $row) { ?>
<div id="cover" class="img-thumbnail">
<div class="audiopt"></div>
<a href="<? echo $row['ID']; ?>" target="_self">
<div id="effect" class="img-thumbnail" alt="<? echo $row['Title']; ?>" title="<? echo $row['Title']; ?>"></div>
<img src="../../cdn/uploads/films/<? echo $row['Cover']; ?>" alt="<? echo $row['Title']; ?>" title="<? echo $row['Title']; ?>" class="img-thumbnail" />
</a>
</div>
<?
}
}
}
?>
The problem is: no shaman that code works perfectly, but not on my site. I do the research and it just doesn’t react. Can anyone help me? Just at the beginning give me the dados
everyone. But when I search nothing happens.
If you access the php file that resumes the business, does the screen go blank or does it show any errors? Add these lines at the beginning of php and see if any errors appear:
ini_set('display_errors', true); error_reporting(E_ALL);
– rray
Warning: mysql_real_escape_string(): Access denied for user 'tvfootba'@'localhost' (using password: NO) in /home/user/public_html/PASTA/search_results.php on line 10

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/user/public_html/PASTA/search_results.php on line 10
gave this– thecreator
you are just using the right PDO? mysql_*(old) n is part of your code.
– rray
right, but in the shaman everything worked out..
– thecreator