Jump to content


Photo

Searching Database


  • Please log in to reply
10 replies to this topic

#1 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 21 April 2006 - 08:02 PM

well, i have tried various codes and this is the one i have got now:

My Form (search.php):

<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="Array[user]" type="text" id="Array[user]"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>

and this is the php (searchres.php):

<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="Array[user]" type="text" id="Array[user]"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>

<HTML>
<HEAD></HEAD>
<BODY>
<?php
$Array["user"] =trim ($Array["user"]);

$Host="i dunt believe it";
$Username="damn";
$Password="hahaha";
$DBName="meh";
$TableName="yeah";
  
$Link = mysql_connect($Host, $Username, $Password);
$Query="SELECT * from $TableName Where user = $Array[user]";
$Result= mysql_db_query ($DBName, $Query, $Link);




echo "Results: <br>$Row[user] ($Row[playerid]) <BR> ";

mysql_close ($Link);
 ?>
</BODY>
</HTML>

now i get no errors when searching it just doesnt bring any results up :S

go here to see what i mean:

[a href=\"http://twottk.com/game\" target=\"_blank\"]HERE[/a]

and login using the following:

Username: testacc
password: test123

#2 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 23 April 2006 - 03:02 PM

can anyone help?

#3 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 23 April 2006 - 03:37 PM

firstly, search.php needs to be modified so that session_start() is the first thing in the page.

PS. you might wanna remove your username & password details from your code that you're sharing with the world.
wisewood: proven fact, I am both wise, and wooden.

#4 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 23 April 2006 - 09:10 PM

thanks for the heads up

#5 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 25 April 2006 - 08:42 PM

bump

#6 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 25 April 2006 - 09:06 PM

Try this

<HTML>
<HEAD></HEAD>
<BODY>
<FORM NAME="searchphone" METHOD="post" ACTION="searchres.php">
Enter Last Name: <input name="search_query" type="text"><BR>
<input type="submit" name="Submit" value="Submit">

</FORM>
</BODY>
</HTML>

<HTML>
<HEAD></HEAD>
<BODY>
<?php
$search_query = trim($_POST['search_query']);

$Host="i dunt believe it";
$Username="damn";
$Password="hahaha";
$DBName="meh";
$TableName="yeah";
  
$Link = mysql_connect($Host, $Username, $Password);
$Query="SELECT * from $TableName Where user = '$search_query'";
$Result= mysql_db_query ($DBName, $Query, $Link) or die(mysql_error());
$Row = mysql_fetch_array($Result);
$num = mysql_num_rows($Result);
$user = $Row['user'];
$playerid = $Row['playerid'];

if($num == "0"){
echo "Search for $search_query returned no results";
}
else{

echo "Results: <br>$user ($playerid) <BR> ";

}

mysql_close ($Link);
?>
</BODY>
</HTML>

If you're not part of the solution, you're part of the precipitate

#7 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 28 April 2006 - 07:25 PM

that didnt work either :(

#8 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 28 April 2006 - 08:03 PM

So lets say youre searching for "bob". Then is this what you are getting when you search?

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]The search for bob returned no results[/quote]

If you're not part of the solution, you're part of the precipitate

#9 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 29 April 2006 - 02:09 PM

no it wasnt echoeing correctly, well still isnt but now i have loads of errors

#10 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 30 April 2006 - 08:47 AM

What kind of errors? you need to be more specific
If you're not part of the solution, you're part of the precipitate

#11 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 30 April 2006 - 10:20 AM

oh i have fixed that now, thanks i might add a tut on it :D show people how i did it etc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users