How to put my variable in my if condition in my php function??

Posted on 2011-04-25
Last Modified: 2012-05-11
Hi, I am trying to put a variable in a $_GET for my conditional if statement

function bracelets() {
	global $conn, $metals;
	$query = "SELECT * FROM bracelets";
	$metal = $metals['name'];
	if(!isset($_GET['{$metal}']) {  // This is line 98
		$query .= " WHERE featured = 1";
	$result = mysql_query($query, $conn);

	$output = "";
	// These loops output the subject names with their corresponding pages underneath them
	while ($bracelets = mysql_fetch_array($result)) {
		//for ($i = 0; $i < 3; $i++) {
		//echo "<img src=\"images/" . $pictures[$i] . "\" />";
		$output .= "<a href=\"bracelets.php?bracelet=" . urlencode($bracelets["id"]) . "\">";
		$output .= "<img src=\"bracelets/" . $bracelets["filename"] . "\" />";
	return $output;

Open in new window

Its giving me this error:

Parse error: syntax error, unexpected '{' in /hermes/web09c/b2950/moo.auroriellacom/includes/library.php on line 98

But how can I get rid of the { when its needed for the if statement?? I took the {$metal} out and I still got the same error message.  Any clues??
Question by:FairyBusiness
    LVL 1

    Accepted Solution

    Try changing this if(!isset($_GET['{$metal}']) {  // This is line 98

    to this

    if(!isset($_GET['$metal'])) {  // This is line 98
    LVL 14

    Expert Comment

    by:Juan Ocasio
    Make sure your brackets are paired properly.  It may be due a bracket prior to this line or even a missing ;

    Author Closing Comment

    Yep, that worked! Didn't know I could put variables straight up in there like that! Thanks

    I just posted another php question about link if you want to take a try at it!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now