Reputation: 16163
I have a form where users enter the amount of rent to pay.
<form action="search_results.php" method="get">
<input type="text" name="rent" value="$" />
</form>
I am using jQuery to keep the dollar sign in the field when the user enters their rent amount.
$('input[name=rent]').keyup(function() {
$(this).val(function(i,v) {
return '$' + v.replace('$',''); //remove existing, add back.
});
});
When the form sends to the search_results.php page, it sends to the url with the following get variable attached to it:
When the page begins to load, it shows the following error message:
Warning: mysqli_error() expects exactly 1 parameter, 0 given in /nfs/c09/h01/mnt/12345/domains/www.domain.com/html/search_results.php on line 551
I'm pretty sure the error occurs because my sql statement is using the $_GET['rent'] variable to sort through all the listings with less than the rent amount entered, and it cannot do that with the dollar sign in it.
How can I remove the dollar sign character from the input field before it sends to the search_results.php page OR how can I remove the %24 from the url on the search_results.php page and then reload the page?
Upvotes: 1
Views: 936
Reputation: 5817
This errors occurs because you are not giving mysqli resource to it.
if (!mysqli_query($link, $query)) {
printf("Errormessage: %s\n", mysqli_error($link));
}
You are simply calling this function like that: mysqli_error();
Upvotes: 0
Reputation: 3225
Well, here is a better solution - You can filter the data after he passed:
$rent = str_replace('$','',$_GET['rent']);
$rent = str_replace('%24','',$rent);
Btw - I suggest you to learn more about SQL injection.
Upvotes: 1
Reputation: 144689
try this:
$('form').submit(function(){
$('input[name=rent]').val($('input[name=rent]').val().replace('$', ''))
})
Upvotes: 2
Reputation: 9130
This should work:
$('form').submit(function(){
$('input[name=rent]').val(function(index, valueWith$){
return valueWith$.substring(1);
});
return true;
});
Upvotes: 1