0

Hi, its problem in my site. Picture in news is not working and i can't solve problem.
Please help!

Image - http://www.bildites.lv/images/16gsnx5prru092k60br3.jpg

<?php
$id = (int)get_get( 'id' );
$news = $db->query( "SELECT * FROM news WHERE id = $id" );
$news_id = $db->fetch( $news );
if( $news_id['id'] )
{
$res = $db->query( "SELECT * FROM news WHERE id = $id" );
$row = $db->fetch( $res );
echo page_title($row['title']);
echo '<h1><a href="' . BASE . '/">Jaunumi</a> » ' . $row['title'] . '</h1>';
$user = $users->info($row['author_id']);
	echo ('<div id="news-inside">
		<h2><a href="/news/view/' . $row['id'] . '/' . $row['seostring'] . '">' . $row['title'] . '</a></h2>
		<div id="news_ramis">
		<img src="' . $row['image'] . '" width="155px" height="105px" style="border: medium none;">
		</div>
		<img style="margin:-3px;" title="Pievienots" src="' . BASE . '/themes/' . SITE_THEME . '/images/date-time.png"> &nbsp;' . format_time($row['date']) . '
		&nbsp;<img style="margin:-3px;" title="Pievienoja" src="' . BASE . '/themes/' . SITE_THEME . '/images/author.gif"> &nbsp;<a href="/user/' . $user['id'] . '/' . $user['username'] . '/">' . $user['username'] . '</a>
		<br />
		<font color="black">' . bb2html($row['text']) . '</font>
		</div>
		');
		
if( $row['com_allowed'] == 1 )
{
	echo error( "Raksta autors ir liedzis komentēt šo rakstu!", "890px" );
}
else
{
	comments( $row['id'], "news" );
}
}
else
{
	$page->set_page_title( 'ID neeksistē' );
	echo '<h1>Kļūda</h1>';
	echo error( "Jaunums ar šādu ID neeksistē!", "890px" );
} 
?>

Edited by birkenfeldo: n/a

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by hag++
0

you have to be carefull while using a variable inside a query string

$news = $db->query( "SELECT * FROM news WHERE id = ".$id."" );

and

$res = $db->query( "SELECT * FROM news WHERE id =".$id."" );

Edited by azywebcoder: n/a

0

you have to be carefull while using a variable inside a query string

$news = $db->query( "SELECT * FROM news WHERE id = ".$id."" );

and

$res = $db->query( "SELECT * FROM news WHERE id =".$id."" );

No that's not correct. If you use double quotes you do not need to concatenate with the . operator. The one thing you have to be careful of is does the value need single quotes around it? If so, this is the correct syntax:

$res = $db->query( "SELECT * FROM news WHERE id = '$id'" );

If no single quotes are required then this is what you need:

$res = $db->query( "SELECT * FROM news WHERE id = $id" );

Now as far as your problem with pulling the picture goes, have you ran your select statement directly against your database to ensure it does return results? If so does the id returned match the picture's filename? (Remember case counts!)

Edited by hag++: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.