newbie echoing help

General discussions related to php

Moderators: macek, egami, gesf

Post Reply
da9nlc
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

newbie echoing help

Post by 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

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Post by 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 <?
?>

da9nlc
New php-forum User
New php-forum User
Posts: 21
Joined: Sun Feb 23, 2003 11:58 pm

So whats wrong with it

Post by 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

Post by 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.

Romantik
New php-forum User
New php-forum User
Posts: 67
Joined: Mon Feb 24, 2003 2:55 am
Location: ../Ukraine/Kherson
Contact:

Post by Romantik » Thu Feb 27, 2003 11:44 pm

echo (htmlspecialchars(stripslashes($row["$id"])));

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Post by 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.

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests