PHP URL Variable

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
RobbieL
Forum Commoner
Posts: 31
Joined: Fri Mar 23, 2007 5:57 pm

PHP URL Variable

Post by RobbieL »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Evening all,

I'm new to PHP, coming from a Coldfusion background, and am currently creating a very small WML application with PHP. It's a very simple application, but there is one part of the PHP code I'm having trouble with. I'm trying to pass a value of a query through to another page using a URL variable, but just can't seem to get it right.

The code for the entire page is as follows:

Code: Select all

<?php header("Content-Type: text/vnd.wap.wml"); echo '<?xml version="1.0"?>'; ?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<?php

$Conn = mssql_connect("STUDENT1X","sql0503101","**********") or die("Unable to connect to server");
$Db=mssql_select_db("sql0503101",$Conn);
$result = mssql_query("SELECT TOP 5 title, author, date , blogID FROM blogs ORDER BY date DESC");

?>

<wml>
	
	<card id="index" title="Metanews">
	<p align="center"><b>Newest 5 Blogs</b></p>
	<?php 
	while($RS = mssql_fetch_array($result)) 
	{
	echo '<p><anchor title="Latest News Stories"><go href="readblogs.php?id=$blogID"/>'.$RS['title'].'</anchor></p>';
	echo '<p><small>Author: '.$RS['author'].'</small></p>';
	echo '<p><small>Date: '.$RS['date'].'</small></p>';
	echo '<p>-----</p>';
	} 
	?>

	<p><do type="prev" label="Back"><prev/></do><do type="accept" label="Home"><go href="index.php"/></do></p>
	</card>

</wml>
What I'm unsure about is the "$blogID" in the URL. I have a query earlier on in the page that calls for blogID, for the purpose of the value going into this URL Varialbe. Is that the right syntax for putting the value of "blogID" in the URL?

Any help would be much apprecaited. :)


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Two Choices. Change the single quotes into double quotes

Code: Select all

$foo = 'bar';
echo "HI!: $foo"; //HI!: bar
echo 'HI!: $foo'; //HI!: $foo
Or, use concatenation (you're already using it for $RS['title'])

Code: Select all

echo '<p><anchor title="Latest News Stories"><go href="readblogs.php?id=' . $blogID . '"/>' . $RS['title'] . '</anchor></p>';
RobbieL
Forum Commoner
Posts: 31
Joined: Fri Mar 23, 2007 5:57 pm

Post by RobbieL »

Thanks for the speedy reply, much appreciated.

Tried the second the option you offered first, and received the error message "Unknown MIME type 'text/html'."

Any ideas what that means?
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

Hey Abertay student,
I would remove your login and pass from the php code if you show it here ;)
Post Reply