My page shows incomplete output please help

Started on the old forum in September 2011 · view the original in the archive · old links redirect here

#database #debugging #error #sql #sql-error

3 replies · 414 views · started 15 years ago · 1 min read

3 participants
s3nzo Developer · 156 posts #1

Hi guys sorry for asking too many questions lately.

I'm fetching database entries but my pages show incomplete output, here's the code

<?php
	require	'inc/head.inc';
	require	'inc/header.inc';
		
		$_SESSION['search']	=	mysql_real_escape_string(htmlentities(stripslashes($_POST['search'])));
		
			$sql	=	"SELECT * FROM users WHERE nick = '{$_SESSION['search']}' OR sname	= '{$_SESSION['search']}' OR fname	=	'{$_SESSION['search']}' OR city	= '{$_SESSION['search']}' LIMIT 0, 10";
			$query	=	mysql_query($sql, $con);
			if(($rows	=	mysql_num_rows($query) < 1) || empty($_SESSION['search']))
				print	'No one was found';
			else
				while($result	=	mysql_fetch_array($query))
					{
						print	'<a href=user.php?nick='.$result['nick'].'>'.$result['nick'].'</a>';
						if(!empty($result['sex']))
							print	' : '.$result['sex'];
						if(!empty($result['city']))
							print	' : '.$result['city'];
						if(!empty($result['country']))
							print	' : '.$result['country'];
						print	'<br>';
					}
	require	'inc/foot.inc';
?>

It shows everything correctly except the country, instead of showing "South Africa" it displays "South"

jaidon20k Developer · 64 posts #2

check your db, that is what is in your db

arnage Lead · 811 posts #3

Try this.

 
            $sql    =    "SELECT * FROM users WHERE nick LIKE '%".$_SESSION['search']."%' OR sname  LIKE '%".$_SESSION['search']."%' OR fname  LIKE '%".$_SESSION['search']."%' OR city  LIKE '%".$_SESSION['search']."%' LIMIT 0, 10";
👍 1
Share
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
s3nzo Developer · 156 posts #4

Thanks guys now here's another problem, code

							if(empty($result['birthyear']))
								print	'<input type=text name=year size=4 maxlength=4 value=YYYY>';
							else
								print	'<input type=text name=year size=3 maxlength=4 value='.$result['birthyear'].'>';
							if(empty($result['birthmonth']))
								print	'<input type=text name=month size=2 maxlength=2 value=MM>';
							else
								print	'<input type=text name=month size=1 maxlength=2 value='.$result['birthmonth'].'>';
							if(empty($result['birthday']))
								print	'<input type=text name=day size=2 maxlength=2 value=DD>';
							else
								print	'<input type=text name=day size=1 maxlength=2 value='.$result['birthday'].'>';

Here's output and my database

Attachments: profile update.png

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close