Forum Moderators: coopster

Message Too Old, No Replies

Cant get output?

         

calbo

2:36 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



HI guys,
I'm a newbie to all this and this bit of code is annoying me as i cant figure out what is wrong.....

I have created a database where there is cross references from a supplier to another make all the information is there but cant get it to display on the screen?
Any help would be greatly appreciated....

code is as follows:

<body>
<?
include("connect.php");
?>

<form action="<?php echo $_SERVER['php_self'];?>" method="POST">
<label>enter oem number:<br />
<input name="search1" type="text" size="15"></input></label><br />
<input type="submit" value=" enter cross ref " />
</form>
<?
if (isset($_REQUEST['search1'])) {
$search = $_REQUEST['search1'];
$sql="select bowers from xref where oem ='$search'";
if (@mysql_query($sql)) {
echo '<p>' . $sql['bowers'].'</p>';
}else{
echo'<p>error retrieving cross reference: ' . mysql_error() . '</p>';
}
}
?>
</body>

cheers - Mark

[edited by: calbo at 2:46 pm (utc) on Oct. 12, 2005]

dcrombie

2:45 pm on Oct 12, 2005 (gmt 0)



Try taking out the '@' so you can see if there is an error. Also you need to have a look at the manual for mysql_query [php.net] to find out how to reference the query results.

calbo

3:01 pm on Oct 12, 2005 (gmt 0)

10+ Year Member



Hi,

U R A STAR!

thanks for pointing me in the right direction.......I've been scratching my head on this for 2 days!

I have now Changed it to:

<?
if (isset($_REQUEST['search1'])) {
$search = $_REQUEST['search1'];
$result = mysql_query("select bowers from xref where oem ='$search'");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf("bowers: %s" , $row[0], $row[1]);
}
}else{
echo'<p>error adding cross reference: ' . mysql_error() . '</p>';
}

?>

I am forever in your debt.

Thanks again - Mark