![]() |
Need your feedback
Yea, this isn't working.. no idea why.
search.html HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">Code:
var xmlHttpPHP Code:
I haven't actually created the table players yet, but that shouldn't matter, it should change the results div message to a db error message in that case. |
Code:
// JavaScript line 15Also, why do you keep putting %$search% (I've noticed this in other topics)? That'll produce a syntax error because the percent symbols just aren't allowed to be used like that. Since you're using sprintf anyway, why not put the table name as an argument? (e.g, SELECT * FROM %2$s...)Depending on your php.ini settings, if you don't pass along the keywords in the query string then the PHP engine will raise a Notice error ("Undefined index") -- it's trivial to check if the key exists before trying to assign it's value to a variable. In your JavaScript, with regards to the multiple "var url", you only need to use var the first time to declare url as a variable local to that function. On line 15, quoted at the top of this post, you make reference to a str variable but the function argument is called string. I'd love to see you using semi-colons at the end of the lines but that's just a personal preference. That's it for starters, I haven't even looked at the code in more than a brief manner but the above should get you moving along a bit. |
Yea, but it's like the htm file doesn't even connect with the js file, because the div id result value doesn't change when I type in something.
Even if the php file is wrong, and that I did some query wrong, the mysql error should still be visible under the searchform :S |
Give your search function a different name. That, along with making the argument str instead of "string", should help.
|
Okey, I got this to so that the JS at least shows up:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">Code:
var xmlHttpPHP Code:
Quote:
|
After a quick look through (literally 2 mins) I would guess that the error is coming from your mix of $pResult and $gResult, surely they are both supposed to be the same?
Another suggestion would be to take a look at Prototype JS it'll make things so much easier for you. With it, you could easily cut down your Ajax Search JavsScript file to a few lines of code split between a few functions. |
Your SELECT queries are not valid SQL since the values used in the LIKE statements are not delimited by quotation marks. Both queries have the same issue which needs to be fixed.
For example: PHP Code:
|
Quote:
Quote:
However, I got this: Quote:
And this is only got to do with the PHP script, so here it is: PHP Code:
|
Hmm I personally can't see the problem. Is the query for searching guilds returning any records?
|
Yea, it says that it found 1 result(which I searched with mysql_num_rows to get that result), but it doesn't print it :S
|
Actually, no Guilds are being found. There is an error in your code which prints out that one (actually prints however many players were found) has been found when in reality it should be printing zero.
Your code (~line 101) PHP Code:
$pResult changed to $gResult)PHP Code:
|
HAHAHA, I'm such stupid :P
Thank you salathe!! :D |
Okey, I got another issue regarding this script.
The server doesn't store the actual NAME of the vocation in the database, they store it as an integrer: 1 beeing knight for example, 2 sorcerer, 3 druid and 4 paladin. And if I just print the value from the row vocation, it prints 1 to 4. However, that's not a problem to fix. PHP Code:
How would I achieve this the best way possible? |
Are the different vocations stored in their own table in the database?
|
No..
The vocation-info is stored in the c++ code in the server.. It's just a row, with a value from 1 to 4, defining what vocation the server should assign them. This row is stored in the player table.. |
You should sotore these vocations in a seperate table like Salathe has implied. You can then perform searches to your hearts content.
|
Yea, but I'm not the maker of this server script(it's a public download), so I don't really have anything to say to make them edit the db structure =//
|
Okey, I fixed so that if you search for the string "knight", the $search is equal to whatever number that is used to define knights.
However, it won't only list knights.. since it searched for lvl aswell, so it will search for players with level equal to the number of the vocation. Is there any way to define search method? Like, a checkbox. Search by: Vocations Level Name Guild And then the search form. And it uses different querys depending on what box is checked? |
We can't really help without seeing how the database is structured. Also, the fact that you can't search for vocations in the database is going to complicate the matter somewhat. If you can post a simplified database structure inicating what table and field each of your search criterias point to then that would help.
|
Code:
CREATE TABLE `accounts` ( |
| All times are GMT. The time now is 11:14 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0