Jump to content

Easy Syntax Error?


jjmusicpro

Recommended Posts

so i pass in a id value, and query the db for the result, for some reason i cant get back data from the query, i echo out my query string, put it into mssql and it works fine...

 

but my page shows blank values for the item it gets

 

any ideas?

 

$id = $_POST['id'];
						if($id != ""){

							if($db = mysql_connect("localhost", "xxx","jxxx")){
								if(mysql_select_db("xxxxxx",$db)){
									$acc1 = "select * from newitems where ID='".$id."'";
										$query = mysql_query($acc1);
										}

										echo $id;
										echo $acc1;

										echo'<div style="background-image:url(tmp/backgroundrepeat.gif); background-repeat:repeat; padding-bottom:4px; padding-top:4px; padding-left:4px; padding-right:4px; border:solid #FFFFFF thin; margin-right:15px;"><strong>Selected Article - '. $query["newstitle"] .' </strong> </div>';
										echo"<font class=\"smaller low\">Data of Article-".$id." ".$query["dateadded"]."</font><br>";
										echo $result["newsinformation"];[code]

[/code]

Link to comment
https://forums.phpfreaks.com/topic/109095-easy-syntax-error/
Share on other sites

try

<?php
$id = $_POST['id'];
						if($id != ""){

							if($db = mysql_connect("localhost", "xxx","jxxx")){
								if(mysql_select_db("xxxxxx",$db)){
									$acc1 = "select * from newitems where ID='".$id."'";
										$query = mysql_query($acc1);
										$query = mysql_fetch_array($query); // add thi line
										}

										echo $id;
										echo $acc1;

										echo'<div style="background-image:url(tmp/backgroundrepeat.gif); background-repeat:repeat; padding-bottom:4px; padding-top:4px; padding-left:4px; padding-right:4px; border:solid #FFFFFF thin; margin-right:15px;"><strong>Selected Article - '. $query["newstitle"] .' </strong> </div>';
										echo"<font class=\"smaller low\">Data of Article-".$id." ".$query["dateadded"]."</font><br>";
										echo $result["newsinformation"];
?>

Link to comment
https://forums.phpfreaks.com/topic/109095-easy-syntax-error/#findComment-559666
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.