Page 1 of 1

Small profile problem!!!

Posted: Wed Mar 17, 2004 12:39 pm
by Joe
I having being trying to create a script that takes the users input from a text box and searches the database for that username then shows their profile. I seem to be having problems for what reason i don't know. Can someone please help? Below is part of the script:

<?php
$searchuser = $_POST['searchuser'];

if (strlen($searchuser == ""))
{
echo "<b>You must enter a username before proceeding...</b><br>";
echo "<br>";
}
else
{
$link = mysql_connect("???", "???", "???");
mysql_select_db("???") or die("couldnt connect" . mysql_error());
$sql = mysql_query("SELECT * FROM members WHERE username = '$searchuser'") or die(mysql_error());
$result = mysql_query($sql) or die(mysql_error());

if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
echo "<center> <p><h3>User Information for ".$searchuser."</h3><p> </center>";

Regards



Joe 8)

Re: Small profile problem!!!

Posted: Wed Mar 17, 2004 12:54 pm
by TheBentinel.com
Joe wrote:

Code: Select all

$sql = mysql_query("SELECT * FROM members WHERE username = '$searchuser'") or die(mysql_error());
If you change that line to go after a specific, known user, does it work? Like:

Code: Select all

$sql = mysql_query("SELECT * FROM members WHERE username = 'Joe'") or die(mysql_error());
That should help narrow down where the problem is.

Posted: Wed Mar 17, 2004 1:15 pm
by andre_c
What errors are you getting?

Posted: Wed Mar 17, 2004 1:53 pm
by Illusionist
if (strlen($searchuser == ""))

should be

if (strlen($searchuser)<=0)