Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

newbie echoing help

General discussions related to php

Moderators: macek, egami, gesf

newbie echoing help

Postby da9nlc » Thu Feb 27, 2003 5:38 am

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
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

Postby Romantik » Thu Feb 27, 2003 6:09 am

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 <?
?>
Romantik
New php-forum User
New php-forum User
 
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson

So whats wrong with it

Postby da9nlc » Thu Feb 27, 2003 9:03 am

<?

$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.
Last edited by da9nlc on Thu Feb 27, 2003 9:58 am, edited 1 time in total.
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

Re: So whats wrong with it

Postby da9nlc » Thu Feb 27, 2003 9:55 am

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.
da9nlc
New php-forum User
New php-forum User
 
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

Postby Romantik » Thu Feb 27, 2003 11:44 pm

echo (htmlspecialchars(stripslashes($row["$id"])));
Romantik
New php-forum User
New php-forum User
 
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson

Postby Redcircle » Fri Feb 28, 2003 12:10 am

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.
User avatar
Redcircle
Moderator
Moderator
 
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA


Return to PHP General

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.