Small profile problem!!!

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!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Small profile problem!!!

Post 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)
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Small profile problem!!!

Post 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.
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

What errors are you getting?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

if (strlen($searchuser == ""))

should be

if (strlen($searchuser)<=0)
Post Reply