Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Can't figure out why my variable is empty.
Old 06-21-2006, 10:26 PM Can't figure out why my variable is empty.
Webmaster Talker

Posts: 626
Trades: 0
I have just converted one of my pages into a database to hopefully convert my whole site soon.

For some reason on line 73 & 74 my reference to $content_title is empty. It is very wierd because on line 67 I reference the variable and it shows correctly.

Here is a link to the page in question: http://www.moneytime.ca/products.php?pg=CASHBACK

Here is a copy of the code:

Code:
<?php
	extract($_GET);
	if(empty($pg)) {
		$pg="CASHBACK";
	}
	ob_start();	
	$host="localhost"; // Host name 
	$username="root"; // Mysql username 
	$password="password"; // Mysql password 
	$db_name="dbname"; // Database name 
	$tbl_name="pgs_products"; // Table name 

    // Connect to server and select databse.
	$curr_loc = $_SERVER['DOCUMENT_ROOT'];
		
	mysql_connect("$host", "$username", "$password")or die("Error! Please try again. <META HTTP-EQUIV=Refresh CONTENT=\"1; URL=http://www.moneytime.ca\">"); 
	mysql_select_db("$db_name")or die("Error! Please try again. <META HTTP-EQUIV=Refresh CONTENT=\"1; URL=http://www.moneytime.ca\">");  
	
	$sql = "SELECT * FROM $tbl_name WHERE pg='$pg' LIMIT 1";
	$results = mysql_query($sql);

	if(mysql_num_rows($results) == "0") {
		$pg = "CASHBACK";
		$sql = "SELECT * FROM $tbl_name WHERE pg='$pg' LIMIT 1";
		$results = mysql_query($sql);
	}
	
	while($data = mysql_fetch_array($results)) {
		extract($data);
	}
	
	mysql_close();
		
	echo <<<HEADEREND
		<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
		<html>
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		   <META NAME="description" CONTENT="$page_desc">
		   <META NAME="keywords" CONTENT="$page_keywords">
		   <META name="robots" content="index,follow">
		   <META NAME="author" CONTENT="Moneytime.ca Inc.">
		<!-- $page_keywords -->
		<!-- $page_desc -->
		<!-- $page_title -->
		
		<title>$page_title</title>
		<link rel="stylesheet" type="text/css" href="/Stylesheets/Style.css">
	</head>

<body>
HEADEREND;
	
	include("$curr_loc/banner.php");
	
	echo <<<HEADEREND
		<tr bgcolor="#D2C888">
			<td id="leftside" valign="top">
HEADEREND;
				include("$curr_loc/menus/$menu");
	echo <<<HEADEREND
			</td>		
			
			<td  valign="top" class="darkblue" style="width:78%; padding: 0px 20px 0px 10px; ">
				<img alt="$page_keywords" src="/images/$pic" style="float:right; margin-left:20px; margin-bottom:20px; width:200px; border:1px solid black;">
				<h1>$content_title</h1>
				$content
				<br>
				<br>

				<form method="post" action="/applynow">
					<input type="hidden" name="page" value="$content_title">
					<center><input type="submit" name="applynow" value="Click to inquiry about $content_title"></center>
				</form>
			</td>
		</tr>
		
		<tr>
			<td id="Footer" colspan="2">
HEADEREND;
				include("$curr_loc/footer.php"); 
				include("$curr_loc/disclaimers/mortgage.php"); 

	echo <<<HEADEREND
			</td>
		</tr>
	</table>
</body>
</html>
HEADEREND;
?>
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-21-2006, 10:39 PM Re: Can't figure out why my variable is empty.
Skorch1's Avatar
Super Talker

Posts: 115
Location: California
Trades: 0
Did you mix up $page_title and $content_title?


if not try
Code:
var_dump($page_title);
echo '<br /><br />';
var_dump($content_title);
__________________
Check out my
Please login or register to view this content. Registration is FREE
website!
Skorch1 is offline
Reply With Quote
View Public Profile Visit Skorch1's homepage!
 
Old 06-21-2006, 10:51 PM Re: Can't figure out why my variable is empty.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
I just viwed the source html from the sample link you gave, and there is no value in the first H1 tag either. There is three H1 tags, and only the third has a value which is indicating to me that vaule is comming from $content instead. So it looks as if $content_title was always empty.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-21-2006, 11:03 PM Re: Can't figure out why my variable is empty.
Webmaster Talker

Posts: 626
Trades: 0
Thanks again mgraphic!
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 06-22-2006, 05:45 AM Re: Can't figure out why my variable is empty.
Novice Talker

Posts: 5
Trades: 0
My friend i guess that there is something suspecious in ur code. There is three H1 tags, and only the third has a value which is indicating that vaule is comming from $content instead. So it looks as if $content_title was always empty. So maybe ur variable is reallt empty, that's why u have it empty in ur database.
pitas is offline
Reply With Quote
View Public Profile
 
Old 06-22-2006, 09:41 AM Re: Can't figure out why my variable is empty.
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Whoa... Deja-Vu!
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can't figure out why my variable is empty.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62107 seconds with 12 queries