Page 1 of 1

newbie echoing help

Posted: Thu Feb 27, 2003 5:38 am
by da9nlc
The first part of my script is working fine searching database and retrieving data held within according to searchterm. The html part is working to showing the number of records I know are held in the database.

I am using phpdev's program using windows 95 and my files are kept in the www file as advised by their instruction.

The problem is when I echo, or print even tried printf functions I dont seem to be able veiw them in my browser. This is the way I have defined and written the echo statement below:

<?php

include_once("databasequery.php");

$id= $result["id"];

{
while ($row = mysql_fetch_array($result));
echo (htmlspecialchars(stripslashes($row["$id"])));
}

<?

I have written and tried a getdate() script which worked fine so im a little lost on this one as the script is being parsed and Im receiving no errors. As I itterated above I have tried echo, print and printf to no avail.


Thanks Dan

Posted: Thu Feb 27, 2003 6:09 am
by Romantik
You have mistakes:

Code: Select all

<?php 
include_once("databasequery.php");

$id= $result["id"]; ??? What it?
 
while ($row = mysql_fetch_array($result));
{ #
echo (htmlspecialchars(stripslashes($row["$id"])));
}
# no use <?
?>

So whats wrong with it

Posted: Thu Feb 27, 2003 9:03 am
by da9nlc
<?

$d = $result["id"];

//declaring variables I got fom a tutorial. In fact I kept getting an Undefined Variable Error in he echo part below before I put it in.


{
while ($row = mysql_fetch_array($result));
echo (htmlspecialchars(stripslashes($row["$id])));
}
?>

// the echo section was taken from Sam's PHP Mysql Web Development.

What should it be

<?php
echo ($row["id"]
?>

I thought that to addslashes which works ok in the script I had to therefore use the stripslashes function on return.

Re: So whats wrong with it

Posted: Thu Feb 27, 2003 9:55 am
by da9nlc
da9nlc wrote:<?

$d = $result["id"];

//declaring variables I got fom a tutorial in tutorial. In fact I kept getting an Undefined Variable Error in he echo part below before I put it in.


{
while ($row = mysql_fetch_array($result));
echo (htmlspecialchars(stripslashes($row["$id])));
}
?>

// the echo section was taken from Sam's PHP Mysql Web Development.

What should it be

<?php
echo ($row["id"]
?>

I thought that to addslashes which works ok in the script I had to therefore use the stripslashes function on return.

Posted: Thu Feb 27, 2003 11:44 pm
by Romantik
echo (htmlspecialchars(stripslashes($row["$id"])));

Posted: Fri Feb 28, 2003 12:10 am
by Redcircle
http://www.php-forum.com/p/viewtopic.php?t=1483

if you just bought that book.. take it back.. if you can't take it back.. burn it.

You will run into nothing but problems.