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
Adding alt / title text using php echo...
Old 10-04-2011, 11:04 AM Adding alt / title text using php echo...
Brian07002's Avatar
Defies a Status

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

This should be simple, but why am I getting a set of empty " " (quotes) without any text in the title part of the code below? Note: The image (banner) comes out just fine.

PHP Code:
 echo '<img src="'.$row['banner'].'" title="'.$row['title'].'" />'
Thank you!
Brian
__________________
Made2Own

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

Last edited by Brian07002; 10-04-2011 at 11:07 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-04-2011, 11:19 AM Re: Adding alt / title text using php echo...
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
My guess is $row['title'] is either not set or blank.

Try looking at the content of the array:
PHP Code:
print_r($row); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-04-2011, 11:48 AM Re: Adding alt / title text using php echo...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by NullPointer View Post
My guess is $row['title'] is either not set or blank.

Try looking at the content of the array:
PHP Code:
print_r($row); 
I get an empty page.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 10-04-2011, 11:53 AM Re: Adding alt / title text using php echo...
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Can you post more of your code? If the banner is showing up then $row['banner'] is set so when you call print_r you should at least get that.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-04-2011, 02:30 PM Re: Adding alt / title text using php echo...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Sorry, I had to go to cable company to get a new plug for the modem...Problems, problems, and more problems...

What do you want me to post? The entire code? It's only the echo part of the code that is giving the issue.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 10-04-2011, 03:08 PM Re: Adding alt / title text using php echo...
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
I'm trying to understand why you can't output the contents of the array. You say you get an empty page. Is that because you have error reporting disabled and there is a fatal error in your code?

Right now it looks like $row['title'] is not set. Look at the code where you set $row and see if you can figure out why the title is missing.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-04-2011, 07:33 PM Re: Adding alt / title text using php echo...
Super Spam Talker

Posts: 879
Name: Paul W
Trades: 0
Looking at some of your other questions, are you using $row as the array name in the appropriate mysql_fetch_assoc? You use it as a loop count in one place and as an array in another - is it possible that you've used a different array name here and $row['banner'] seems to work as it was set earlier in code?
__________________

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


*** New:
Please login or register to view this content. Registration is FREE
PaulW is offline
Reply With Quote
View Public Profile
 
Old 10-07-2011, 09:21 PM Re: Adding alt / title text using php echo...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
After using some error reporting, I have found that the error is now this:

PHP Code:
NoticeUndefined indextitle in index.php on line 36 
Here's the code: (note this code is a piece of the main code, but this by itself needs to become functional (the title issue to be fixed) before I combine this with the other php code, doing it this way so it's easy for me to problem solve, but it's not been easy) )

What's the trick to figuring out php? I want to love it not hate it, but it's a love / hate relationship I guess


<!-- (Mult-Column Output Code) -->
PHP Code:
<?php
// Report all PHP errors
error_reporting(-1);
?>
PHP Code:
<?php 
        
// db connection
        
include('connect.php');

        
// query
    
$query="SELECT banner FROM amp_ads";
    
$result=mysql_query($query);
 
    
$cols=5// Here we define the number of columns

    
echo "<table align=\"center\">"// The container table with $cols columns
    
do {
    echo 
"<tr>";
    for(
$i=1;$i<=$cols;$i++) { // All the rows will have $cols columns even if the records are less than $cols
    
$row=mysql_fetch_array ($result);
    if(
$row){
    
$img $row['banner'];
 
?>
HTML Code:
<td>
        <table align="center">
        <tr valign="top">
        <td>
<!-- columns can have both text and images -->


PHP Code:
<?php echo "<img src=\"$row[banner]\" border=\"1\" title=\"$row[title]\">"?>
HTML Code:
</td>
        <td>
        <b>
PHP Code:
<?php // echo $row['name'] ?></b><br />
        <?php // echo $row['email'] ?><br />
        <?php // echo $row['password'] ?><br />
HTML Code:
</td>
        <td width="50">&nbsp;</td>	<!-- Create gap between columns -->
        </tr>
        </table>
        </td>
PHP Code:
<?
    
}
    else{
    echo 
"<td>&nbsp;</td>";    //If there are no more records at the end, add a blank column
    
}
    }
    } while(
$row);
    echo 
"</table>";
 
?>
__________________
Made2Own

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

Last edited by Brian07002; 10-07-2011 at 09:29 PM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 10-07-2011, 09:43 PM Re: Adding alt / title text using php echo...
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
You are only selecting the banner:
PHP Code:
$query="SELECT banner FROM amp_ads"
assuming there is a title column in your table the query should be:
PHP Code:
$query="SELECT banner, title FROM amp_ads"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 10-07-2011, 10:02 PM Re: Adding alt / title text using php echo...
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by NullPointer View Post
You are only selecting the banner:
PHP Code:
$query="SELECT banner FROM amp_ads"
assuming there is a title column in your table the query should be:
PHP Code:
$query="SELECT banner, title FROM amp_ads"
I swear I deserve a really hard slap upside the head I *really* should have remembered basic mysql. Boy do I feel embarassed.

Thank you NullPointer for pointing that one out!
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adding alt / title text using php echo...
 

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