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
Having trouble fixing a parse error
Old 11-06-2005, 05:00 PM Having trouble fixing a parse error
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
Man, I swear I always get these parse errors everytime I make a site

Anyway, here's the error:

Quote:
Parse error: parse error, unexpected '[' in C:\Program Files\Apache Group\Apache2\hosted\kshdesign\products.php on line 77
Line 77 is this:

PHP Code:
$content .= "<p><a href=\"" $config['url'] . "/products.php?product_id=" $row['product_id'] . "\"><img src=\"" row['image'] . "\" alt=\"" $row['name'] . "\" width=\"150\" height=\"150\" /></p>\n"
The rest of the code is this:

PHP Code:
<?php    // Products display page

// Include config file
include ("includes/config.php");

if (isset(
$_GET['product_id'])) {

    
$product_id $_GET['product_id'];
    
    
// Connect and select database
    
include ("includes/dbconn.php");
    
    
// Define query to get product
    
$query "SELECT `name`, `short_desc`, `long_desc`, `price`, `image`, `category` FROM products WHERE `product_id`='$product_id'";
    
    
// Run the query
    
$result mysql_query($query)
        or die(
"<p class=\"error\"><strong>Error: </strong>Could not execute query (\"" $query "\"). The error returned was: " mysql_error() . "</p>\n\n");
        
    while (
$row mysql_fetch_array($result)) {
    
        
$title $row['name'];
        
        
$content "<h2>Price: \$" $row['price'] . "</h2>\n\n";
        
        
$content .= "<p><a href=\"" $config['url'] . "/products.php?category=" urlencode($row['category']) . "\">" $row['category'] . "</a><p>\n\n";
        
        
$content .= "<table border=\"1\">\n\n";
        
        
$content .= "<tr>\n\n";
        
        
$content .= "<td><img src=\"" $config['url'] . "/" $row['image'] . "\" alt=\"" $row['name'] . "\" /></td>\n";
        
$content .= "<td><p><strong>Short Description:</strong></p>\n\n";
        
$content .= "<p>" $row['short_desc'] . "</p></td>\n\n";
        
        
$content .= "</tr>\n\n";
        
        
$content .= "<tr>\n\n";
        
        
$content .= "<td><p><strong>Long Description:</strong></p>\n\n";
        
$content .= "<p>" $row['long_desc'] . "</p></td>\n\n";
        
        
$content .= "</tr>\n\n";
        
        
$content .= "</table>\n\n";
        
    }
    
    
// Close database connection
    
mysql_close();
    
} elseif (isset(
$_GET['category'])) {

    
$category urldecode($_GET['category']);
    
$offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0;
    
$size 6;
    
    
// Connect and select database
    
include ("includes/dbconn.php");
    
    
// Define query to get products form categories
    
$query "SELECT `product_id`, `name`, `price`, `image` FROM products WHERE `category`='$category' ORDER BY `product_id` DESC LIMIT $offset$size";
    
    
// Run the query
    
mysql_query($query)
        or die(
"<p class=\"error\"><strong>Error: </strong>Could not execute query (\"" $query "\"). The error returned was: " mysql_error() . "</p>\n\n");
        
    
$title $category;
    
    
$content "<table border=\"1\">\n\n";
    
    while (
$row mysql_fetch_array($result)) {
    
        
$content .= "<tr>\n\n";
        
        
$content .= "<td width=\"15%\"><div align=\"left\">\n";
        
$content .= "<p><a href=\"" $config['url'] . "/products.php?product_id=" $row['product_id'] . "\"><img src=\"" row['image'] . "\" alt=\"" $row['name'] . "\" width=\"150\" height=\"150\" /></p>\n";
        
$content .= "<p align=\"center\">" $row['name'] . "</p></td>\n\n";
        
        
$content .= "<td width=\"20%\" valign=\"top\"><ul>\n";
        
$content .= "<li><strong>Price: </strong>\$" $row['price'] . "</li>\n";
        
$content .= "<li><a href=\"" $config['url'] . "/products.php?product_id=" $row['product_id'] . "\">View more...</a></li>\n";
        
$content .= "</ul></td>\n\n";
        
        
$content .= "</tr>\n\n";
        
    }    
// end WHILE
    
    
$content .= "</table>\n\n";
    
    
// Define query to get total number of rows
    
$query "SELECT COUNT(`prodcut_id`) FROM products WHERE `category`='$category'";
    
    
// Run the query
    
$result mysql_query($query)
        or die(
"<p class=\"error\"><strong>Error: </strong>Could not execute query (\"" $query "\"). The error returned was: " mysql_error() . "</p>\n\n");
        
    
$totalrows mysql_result($result0);
    
    
$content .= "<table>\n\n";
    
    
$content .= "<tr>\n\n";
    
    
$content .= "<td width=\"50%\">";
    if (
$offset 0) {
        
$prev $offset $size;
        
$content .= "<a href=\"" $config['url'] . "/products.php?category=" urlencode($category) . "&amp;offset=" $prev "\">&laquo; Previous page</a>";
    }
    
    
$content .= "</td>\n\n";
    
    
$content .= "<td width=\"50%\">"
    
if ($totalrows > ($offset $pagesize)) {
        
$next $offset $size;
        
$content .= "<a href=\"" $config['url'] . "/products.php?category=" urlencode($category) . "&amp;offset=" $next "\">Next Page &raquo;</a>";
    }
    
    
$content .= "</td>\n\n";
    
    
$content .= "</tr>\n\n";
    
    
$content .= "</table>\n\n";
    
    
// Close database connection
    
mysql_close();

} else {    
// Nothing set, redirect to home page

    
header("Location: " $config['url'] . "/index.php");
    exit;

}    
// End IF

// Assign smarty variables and display page
include ("includes/smarty_display.php");

?>
HitRaj47 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-06-2005, 05:34 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
and is $config an associative array ?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-06-2005, 05:54 PM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
Yeah, it is...
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Old 11-06-2005, 08:09 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
You're missing a $ sign on row['image'] (should be $row['image']).

Don't worry about the parse errors, everyone gets them when they make typos in their code.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 11-06-2005, 08:27 PM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
Wow just one small thing missing and it all goes wrong!

Thanks dude!
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Old 11-07-2005, 04:40 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
I was running a website for a May Ball (a college party that has several thousand people at it). I put a single extra comma into my script and the whole website came crashing down around my ears. Oh well....
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to Having trouble fixing a parse error
 

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.24159 seconds with 12 queries