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
Help with this bit of code please?
Old 12-14-2009, 05:29 AM Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
How do I echo out the image here? It's element_5 I Just need to get the correct 'punctuation" to display it: Currently I am only getting a 'broken image' for the image tag, but the text tag 'element_1' displays fine.

HTML Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>
<?php
Some php code here
?>

HTML Code:
<td align="center" valign="top">
<table border="0" align="center">

<tr><td align="center"><img src="http://www.webmaster-talk.com/images/<?php echo $row['element_5']?>" border="1"/></td></tr>
<tr><td align="center" valign="middle"><?php echo $row['element_1']?></td></tr></table><td>
Kindly help,
Thank you.
__________________
Made2Own

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

Last edited by Brian07002; 12-14-2009 at 05:30 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-14-2009, 06:57 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Anyone?
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 07:03 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
If you get a broken image pictogram, then it means the img src is wrong.
Start by investigate there.

Try to get back the full url, and look where is the error.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 07:18 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by tripy View Post
If you get a broken image pictogram, then it means the img src is wrong.
Start by investigate there.

Try to get back the full url, and look where is the error.
True, I have done that, and I still find it to be an 'impossible' feat to accomplish. The properties to the image have been:

http://localhost/scripts/images/index.php
http://localhost/scripts/images/%3E

oh, and even
http://localhost/scripts/images/
But it doesn't output the $row[element_5] which is the path to the image stored in the database. I've checked the database to make sure that was the correct field and it is.
__________________
Made2Own

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

Last edited by Brian07002; 12-14-2009 at 07:21 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 07:29 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
In that case, please, post the complete code.
Include 1 or 2 rows of your table too, please.

Just html will not let us see where the error is.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 07:40 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by tripy View Post
In that case, please, post the complete code.
Include 1 or 2 rows of your table too, please.

Just html will not let us see where the error is.

HTML Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>
PHP Code:
<?php
include('config.php');
PHP Code:
$i=21;
while(
$row=mysql_fetch_array($result)){
$i $i 1;
if(
$i == 0)
{
?> 
HTML Code:
</tr>
<tr>
PHP Code:
<?php
}
?>
HTML Code:
<td align="center" valign="top">

<table border="0" align="center">

<tr><td align="center"><img src="http://www.webmaster-talk.com/images/<?php echo $row['element_5']?>" border="1"/></td></tr>
<tr><td align="center" valign="middle"><?php echo $row['element_1']?></td></tr></table><td>
PHP Code:
<?php
}
?>
HTML Code:
</tr>
</table>
Config.php
Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "pass") or die(mysql_error());
mysql_select_db("machform") or die(mysql_error());

$query = "SELECT element_1 FROM ap_form_1";
$result = mysql_query($query)
or die("Query failed: " . mysql_error());

?>
Thanks!
__________________
Made2Own

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

Last edited by Brian07002; 12-14-2009 at 07:42 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 09:02 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
No, please...
Send the whole script, that I can paste in an editor and take a good look at it.
Not just bits and pieces!
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 09:14 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Sorry, here it is as one script:

PHP Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>

<?php
include('config.php');

$i=21;
while(
$row=mysql_fetch_array($result)){
$i $i 1;
if(
$i == 0)
{
?>

</tr>
<tr>


<?php
}
?>


<td align="center" valign="top">

<table border="0" align="center">

<tr><td align="center"><img src="http://www.webmaster-talk.com/images/<?php echo $row['element_5']?>" border="1"/></td></tr>
<tr><td align="center" valign="middle"><?php echo $row['element_1']?></td></tr></table><td>

<?php
}
?>

</tr>
</table>

Trip, just as a heads up, the output of this code is a broken image, and the text under it.
__________________
Made2Own

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

Last edited by Brian07002; 12-14-2009 at 10:01 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 10:21 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
I rewrote a bit your code, for more clarity.
But I did not found any error.

What so you have in your DB, and what is your query ?
PHP Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>

<?php
include('config.php');

$i=21;
while(
$row=mysql_fetch_array($result)){
    
$i -=1;
    if(
$i == 0){
        echo 
html<<<
</
tr>
<
tr>
html;
    }
    
    echo 
html<<<
    <
td align="center" valign="top">
        <
table border="0" align="center">
            <
tr>
                <
td align="center"><img src="images/{$row['element_5']}border="1"/></td>
            </
tr>
            <
tr>
                <
td align="center" valign="middle">
                    {
$row['element_1']}
                </
td>
            </
tr>
        </
table>
    <
td>

html;
}
?>

</tr>
</table>
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 10:34 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
Originally Posted by tripy View Post
I rewrote a bit your code, for more clarity.
But I did not found any error.

What so you have in your DB, and what is your query ?
PHP Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>

<?php
include('config.php');

$i=21;
while(
$row=mysql_fetch_array($result)){
    
$i -=1;
    if(
$i == 0){
        echo 
html<<<
</
tr>
<
tr>
html;
    }
    
    echo 
html<<<
    <
td align="center" valign="top">
        <
table border="0" align="center">
            <
tr>
                <
td align="center"><img src="images/{$row['element_5']}border="1"/></td>
            </
tr>
            <
tr>
                <
td align="center" valign="middle">
                    {
$row['element_1']}
                </
td>
            </
tr>
        </
table>
    <
td>

html;
}
?>

</tr>
</table>
This code you just sent me doesn't display anything. Empty page.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 11:05 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
That's the result of 3 years without PHP...
I inverted some characters:
PHP Code:
<table width="100%" border="0" cellpadding="3" cellspacing="3" style="padding-top:5px">
<tr>

<?php
include('config.php');
error_reporting(E_ALL);

$i=21;
while(
$row=mysql_fetch_array($result)){
    
$i -=1;
    if(
$i == 0){
        echo <<<html
</tr>
<tr>
html;
    }
    
    echo <<<html
    <td align="center" valign="top">
        <table border="0" align="center">
            <tr>
                <td align="center"><img src="images/
{$row['element_5']}" border="1"/></td>
            </tr>
            <tr>
                <td align="center" valign="middle">
                    
{$row['element_1']}
                </td>
            </tr>
        </table>
    <td>

html;
}
?>

</tr>
</table>
But you, at the same time, have your server configured to not show you any informations when an error arise.
Not the most recommended setup to develop something.
I have extended a bit the code, to force to inform you about everything that is malformed.
From an error to the use of a constant in place of a variable.

Don't be afraid of "notice" message, this is just the PHP engine telling you that it had to take a guess, and that you should rectify your code.
You are not forced to do so, but it's recommended.

MY previous question still stand, beside.
Can we see the db query you send, and the db structure?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 11:12 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
Quote:
But you, at the same time, have your server configured to not show you any informations when an error arise.
Not the most recommended setup to develop something.
I have extended a bit the code, to force to inform you about everything that is malformed.
From an error to the use of a constant in place of a variable.
I still don't get any error output from your code, I DO SEE THE BROKEN IMAGE THOUGH, WITH THE TEXT UNDER IT

Quote:
Don't be afraid of "notice" message, this is just the PHP engine telling you that it had to take a guess, and that you should rectify your code.
You are not forced to do so, but it's recommended.
See above, I didn't get any error output, including a "notice" message

Quote:
MY previous question still stand, beside.
Can we see the db query you send, and the db structure?
I believe what your looking for is my config.php, right?

Posted in Message #6 Here's the code:

PHP Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost""root""pass") or die(mysql_error());
mysql_select_db("machform") or die(mysql_error());

$query "SELECT element_1 FROM ap_form_1";
$result mysql_query($query)
or die(
"Query failed: " mysql_error());

?>
__________________
Made2Own

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

Last edited by Brian07002; 12-14-2009 at 11:14 AM..
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 11:23 AM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Posted in Message #6
Sorry, I missed it.

Ok, the query itself is simple.
Does it works when you run it in phpMyAdmin?
Does it gives you the value you where expecting?

The quote below leads me to think that your query might not return what is needed...
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 12-14-2009 at 11:25 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 12-14-2009, 11:37 AM Re: Help with this bit of code please?
Brian07002's Avatar
Defies a Status

Posts: 2,162
Name: ...
Location: ...
Trades: 0
I have figured it out, I didn't have select 'element 5' in my config files select statement. It's been a long one...I say it's time for a brew.
__________________
Made2Own

Please login or register to view this content. Registration is FREE
Brian07002 is offline
Reply With Quote
View Public Profile
 
Old 12-14-2009, 02:01 PM Re: Help with this bit of code please?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
I say it's time for a brew
Yep... It is...
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Help with this bit of code please?
 

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