PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Can someone please help me with my code. It is supposed to be a search engine that takes 3 parameters (Name, Category,State). It should print 10 records to a page, and the remainder records should be sent to the next page. However, it is not working and I dont know whats wrong with the code. I've been on it for 3 days. Please can someone help?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[color=red][b]Everah[/b] | I modified your post title to be a little more in line with what you actually need help with.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]2.[/b] Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.[/quote]
Theres no error message, it will just print 10 records on the first page and even though there should be more, there is no option to click next. The NExt link does not appear.
Guy303 wrote:Theres no error message, it will just print 10 records on the first page and even though there should be more, there is no option to click next. The NExt link does not appear.
Before we get to deep in trying to fix all of the errors in this code (and there are plenty of issues with the code) the issue asked by the original poster needs to be addressed. Next is not showing. 10 results are, but next is not.
Try looking at the code I replied with before. The 'Next' display is controlled by that conditional evaluating to true. Since you are not seeing the next link, that conditional is not evaluating to true.
Before we get to deep in trying to fix all of the errors in this code (and there are plenty of issues with the code) the issue asked by the original poster needs to be addressed. Next is not showing. 10 results are, but next is not.
Fair enough, still I think the original poster needs to throw and display errors in the first place (i.e. get rid of all '@' and turn error_reporting(2047))
I totally agree with you. There are number of things that need to be worked on in that code. But he came to us looking for why his 'Next' link wasn't there. I think before we lay the smack down on him for that cruddy code , we should at least help figure out his original issue.
Thank you guys for taking the time to reply. When i get rid of that "if statement" the code works, except that in the last page the next link appears when it shouldn't. I appreciate you guys looking at the code, I just started php and I really am happy you all took the time to respond. I wanted to keep you guys up to date so you dont think I gave up. I will work on this some more and let you know the result. Thanks again.
Everah wrote:I totally agree with you. There are number of things that need to be worked on in that code. But he came to us looking for why his 'Next' link wasn't there.
$s = empty($s) ? 0 : $s;
print 's has the value: ' . $s . "\n"; // where does this mysterious $s come from all of a sudden? Do you refer to $_GET['s'] maybe?
$query .= $sub . "ORDER BY Business_Name, City LIMIT $s, $limit"; // end of string
print 'the query is: ' . $query . "\n";
$result = mysql_query($query) or die(mysql_error($connection)); // this assumes, you called the result of mysql_connect(), $connection, modify this to the real variable name
$numrows = mysql_num_rows($results);
print 'numrows says it is: ' . $numrows . "\n";
Post everything that has been printed out by now and we'll take it from there
thank you very much for your willing to help. Thank you. Here is what I got...
s has the value: 0
Notice: Undefined variable: sub in /home/assyrian/www/www/directory/search.php on line 56
Notice: Undefined variable: limit in /home/assyrian/www/www/directory/search.php on line 56
Notice: Undefined variable: query in /home/assyrian/www/www/directory/search.php on line 56
the query is: ORDER BY Business_Name, City LIMIT 0,
Notice: Undefined variable: connection in /home/assyrian/www/www/directory/search.php on line 58
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/assyrian/www/www/directory/search.php on line 58
Notice: Undefined variable: sub in /home/assyrian/www/www/directory/search.php on line 56
Notice: Undefined variable: limit in /home/assyrian/www/www/directory/search.php on line 56
Notice: Undefined variable: query in /home/assyrian/www/www/directory/search.php on line 56
the query is: ORDER BY Business_Name, City LIMIT 0,
You don't use exactly the code you have posted originally, since in this code $sub is at least defined, $limit is 10 and $query is at least "SELECT * FROM Users WHERE ". Are you sure you haven't commented something out?
Notice: Undefined variable: connection in /home/assyrian/www/www/directory/search.php on line 58
As I said, you must rename this to the variable name you have chosen in mysql_connect.php
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in /home/assyrian/www/www/directory/search.php on line 58
Follow up error
-----------------
I just read the last postings again and figured there must have been a misunderstanding about my 'modify your code' posting. I didn't mean 'Replace your existing code with mine' but 'Modify the areas I have modified'. If you replaced your code, this would explain the strange error messages you posted.