Help with this bit of code please?
12-14-2009, 05:29 AM
|
Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
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
Last edited by Brian07002; 12-14-2009 at 05:30 AM..
|
|
|
|
12-14-2009, 06:57 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
Anyone?
__________________
Made2Own
|
|
|
|
12-14-2009, 07:03 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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.
|
|
|
|
12-14-2009, 07:18 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by tripy
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
Last edited by Brian07002; 12-14-2009 at 07:21 AM..
|
|
|
|
12-14-2009, 07:29 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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.
|
|
|
|
12-14-2009, 07:40 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by tripy
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 % 5 == 0) { ?>
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>
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
Last edited by Brian07002; 12-14-2009 at 07:42 AM..
|
|
|
|
12-14-2009, 09:02 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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.
|
|
|
|
12-14-2009, 09:14 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
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 % 5 == 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
Last edited by Brian07002; 12-14-2009 at 10:01 AM..
|
|
|
|
12-14-2009, 10:21 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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 % 5 == 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.
|
|
|
|
12-14-2009, 10:34 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
Quote:
Originally Posted by tripy
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 % 5 == 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
|
|
|
|
12-14-2009, 11:05 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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 % 5 == 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.
|
|
|
|
12-14-2009, 11:12 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
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
Last edited by Brian07002; 12-14-2009 at 11:14 AM..
|
|
|
|
12-14-2009, 11:23 AM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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..
|
|
|
|
12-14-2009, 11:37 AM
|
Re: Help with this bit of code please?
|
Posts: 2,162
Name: ...
Location: ...
|
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
|
|
|
|
12-14-2009, 02:01 PM
|
Re: Help with this bit of code please?
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
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.
|
|
|
|
|
« Reply to Help with this bit of code please?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|