Posted By: leelee700 ()
Posted On: 12/26/2006 07:29 am
|
hi everyone-
ive just realized that i have gone absolutely bonkers trying to work around my hosting company's upgrade and im looking for professional help!
here's what happened:
im developing a site that runs on php and queries a mysql database - user searches for information and they get results - if results are more than 10, the results are spaced over x number of pages. so my php code drives the search as well as the pagination of results. all was working well....
until my host upgraded my account to their hosting version 2.0 (upgraded from 1.0). well, now the pagination scheme stopped working on this new upgraded version, but the search and everything else continues to work.
ive tried all sorts of pagination schemes - my own code, free code found on the itnernet - nothing works - for whatever reason, i can not get the resutls to paginate correctly! some code works well enough for the 'next" page links to show up, but they dont go anywhere or point to the same page.
i contacted the host and they said that there upgrades can sometimes result in this type of thing, and that some sites wont work properly when they upgrade. unfortunately, they will not allow me to downgrade back to the account version where my site worked properly.
so, since ive gone bonkers trying to figure out whats wrong and find work around solitions, id like to find a professional php developer who can help me out with some pagination code that actually works! please let me know if you are such a person.
anyone else have this same issue or experiencing same issue?
|
|
Posted By: Dinkar (Staff)
Posted On: 12/26/2006 08:09 am
|
My guess:
Your current method of getting variable values isn't working. You need to get the values using some different method.
|
|
Posted By: leelee700 ()
Posted On: 12/26/2006 08:19 am
|
Thanks Dinkar. The upgrade they did now means that it runs PHP 5. Is there some special way to paginate using PHP5? Do you have some code you can share?
THanks!
|
|
Posted By: Dinkar (Staff)
Posted On: 12/27/2006 03:41 am
|
Read this. If it isn't helpful, post your code. We will try to help you.
|
|
Posted By: leelee700 ()
Posted On: 12/28/2006 04:54 am
|
thanks excell! believe it or not, i searched high and low before posting here. i generally prefer to find stuff myself than ask for help, and only turn to a forum when im at a loss. tried all sorts of code to no avail!
thanks Dinkar! i beleve the problem is related to register globals being turned off when host upgraded me. now i turned it on and the script works. wondering if turning globals on is a good idea (that's why i started other thread on that topic). ive read about it on some sights but cant figure out if its bad in my case. maybe i can post my code and get feedback on that issue?
|
|
Posted By: Dinkar (Staff)
Posted On: 12/28/2006 10:40 pm
|
This page will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.
Source: Using Register Globals
IMO, don't turn it 'ON'; but modify your code to make it secure and compatible with the latest php version.
|
|
Posted By: leelee700 ()
Posted On: 01/07/2007 05:05 pm
|
Thanks Dinkar - I finally figured that out. I had register globals off. Anyway, wonder if you can help with another question?
I'm trying to be able to search a database when a user enters multiple words into a search box. My code works fine for a search with one word, but not more than one.
The following code works fine for one search term:
//Get search term from search box
$var = @$_GET['q'] ;
//Trim extra white space
$trimmed = trim($var);
//Code to connect to database
//Some other code to check of a search term was entered, etc.
//Query database
$query = "select * from $table where $field1 LIKE
"%$trimmed%"
order by $field1";
//Etc...
BUT, the following code will NOT work (which being a newbie I'd expect to work for multiple search terms):
//Get search term from search box
$var = @$_GET['q'] ;
//Trim extra white space
$trimmed = trim($var);
//Code to connect to database
//Some other code to check of a search term was entered, etc.
//Query database
$query = "select * from $table
where $field1 LIKE "%$trimmed%
or
where $field2 LIKE "%$trimmed%
or
where $field4 LIKE "%$trimmed%
or
where $field5 LIKE "%$trimmed%
or
where $field6 LIKE "%$trimmed%
or
where $field8 LIKE "%$trimmed%
or
where $field16 LIKE "%$trimmed%
or
where $field17 LIKE "%$trimmed%"
order by $field1";
//Etc...
Basically, I'm combinding LIKE with OR. Any ideas or help would be appreciated.
BTW, here is the error message I get with the above code:
DB Error Occurred: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ' or where field1 LIKE "%105% or where field2 LIKE "%105% o
Any help would be appreciated!
|
|
Posted By: leelee700 ()
Posted On: 01/07/2007 05:05 pm
|
Oh I forgot to mention that the "105" in the error code is the search term.
|
|
Posted By: Dinkar (Staff)
Posted On: 01/08/2007 01:13 am
|
Use 'where' only once and try.
Example:
select * from $table
where $field1 LIKE "%$trimmed%
or
$field2 LIKE "%$trimmed%
or
$field3 LIKE "%$trimmed%
order by $field1";
Let us know if it is working.
|
|
Posted By: leelee700 ()
Posted On: 01/08/2007 04:37 am
|
Hi Dinkar - thanks but unfortunately that didn't work. Can you suggest a different code for searching when the user enters multiple search terms?
Thanks for your help.
|
|
Posted By: Dinkar (Staff)
Posted On: 01/08/2007 08:20 am
|
It's working, just test :)
|
|
|