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
What's wrong with this code?
Old 10-02-2011, 12:45 PM What's wrong with this code?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Fixed:

I had a ; at the end of the while loop (Fetch array) line

The purpose is to output an image (banner) from a row in mysql. I am 100% sure banners exist in the $row['banner'] column.
PHP Code:
<?php

// Connect to database

$connection mysql_connect("localhost""duckster_admin""") or die("Could not connect to database");

// Select database

$db mysql_select_db("duckster_amp"$connection) or die ("Could not select database");

// mySQL connection
$query "SELECT * FROM amp_ads";

// Show all Records

$result mysql_query($query) or die("Query Failed: " mysql_error());

// Table code here //

while($row mysql_fetch_array($result));

{

//echo "<img src=\"$row[banner]\">";

echo "<img src=\"$row['banner']\">"// This code don't work, what will work?

}

mysql_close($connection);

?>
As the echo statement says, what will work?

Error message:

Code:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /server path/
__________________
Made2Own

Please login or register to view this content. Registration is FREE

Last edited by Brian07002; 10-02-2011 at 01:42 PM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-02-2011, 03:00 PM Re: What's wrong with this code?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Use this:
PHP Code:
echo "<img src=\"".$row['banner']."\">"// This code don't work, what will work? 
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 10-02-2011, 04:19 PM Re: What's wrong with this code?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by Physicsguy View Post
Use this:
PHP Code:
echo "<img src=\"".$row['banner']."\">"// This code don't work, what will work? 
Even though I already fixed the issue, I don't think this would of worked anyway because I closed the while loop too soon.

Thanks anyway
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 10-02-2011, 04:21 PM Re: What's wrong with this code?
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
The error you gave would mean that you didn't escape the variable inside the string. Using arrays insides strings can return errors like the 'WHITESPACE' one you got there. That would have been your problem: I get them all the time.

I'm glad you got it figured out, though!
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to What's wrong with this code?
 

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