SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Value is not carrying to the variable

  1. #1
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Value is not carrying to the variable

    The following syntax is not working:

    PHP Code:
    include_once ("../includes_php/header.".$Brand.".php"); 
    I want to insert the $Brand variable so the correct header will appear. If I insert the actual variable, then the header DOES appear. Here is more of the code:

    PHP Code:
    $plq = mysql_query 
    (    "SELECT Photo, PartNo, ItemName, MSRP, Descr, Brand, DateCreated
        FROM aeproducts
        $where" 
    ); 

    $Brand = $plq['Brand'];

    $message = array(
        "<p class='msgbanner1'><strong>ERROR. Please try again another time.</strong></p>",
        "<p class='msgbanner1'><strong>Sorry, I cannot find that information. Please check your typing and try again.</strong></p>",
        "<p class='msgbanner2'>You searched for <strong>$text</strong></p>",
        "<p class='msgbanner2'><strong>Please try again without using punctuation.</strong></p>",
        "<p class='msgbanner2'>30 random items shown. Please specify your part(s) by using the Search box above.</p>",
        "<p class='msgbanner2'>Too many results returned. No thumbnails shown.</p>"

        );
    ?>

    <table id="main">
        <tr><td colspan="2" id="header">
    <!-- **** HEADER IMAGE ******* -->

    <?php
    include_once ("../includes_php/header.".$Brand.".php"); 
    ?>
    How do I make sure the $Brand content goes from the query into the include line? I've tried several different possibilities of single and double quotes, with and without the concatenation. Warning message:

    Warning: include_once(../includes_php/header..php) [function.include-once]: failed to open stream: No such file or directory

    Again, adding the actual value in place of $Brand makes the script work.

    Thanks,
    Steve

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,049
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The actual value of $Brand is... well, nothing.

    You can't just treat a query like an array. You need to turn it into one:
    PHP Code:
    $plqq mysql_query("SELECT Photo, PartNo, ItemName, MSRP, Descr, Brand, DateCreated FROM aeproducts $where");
    $plq mysql_fetch_array($plqq);
    $Brand $plq['Brand'];
    $message = array( 
        
    "<p class='msgbanner1'><strong>ERROR. Please try again another time.</strong></p>"
        
    "<p class='msgbanner1'><strong>Sorry, I cannot find that information. Please check your typing and try again.</strong></p>"
        
    "<p class='msgbanner2'>You searched for <strong>$text</strong></p>"
        
    "<p class='msgbanner2'><strong>Please try again without using punctuation.</strong></p>"
        
    "<p class='msgbanner2'>30 random items shown. Please specify your part(s) by using the Search box above.</p>"
        
    "<p class='msgbanner2'>Too many results returned. No thumbnails shown.</p>" 

        
    ); 
    echo <<<HTML

    <table id="main"> 
        <tr>
            <td colspan="2" id="header"> 
                <!-- **** HEADER IMAGE ******* --> 
    HTML;
    include_once (
    '../includes_php/header.'.$Brand.'.php');
    ?> 
    Off Topic:

    By the way, table-based designs have been out the window for years. Using <div> tags with CSS styling is the best, and most powerful, way of building HTML designs
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  3. #3
    SitePoint Wizard
    Join Date
    Feb 2007
    Location
    Southern California
    Posts
    1,145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I neglected to build an array from the query first! ARRRRRRRgh.

    Thanks!
    Steve

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •