[PHP] foreach()

2004-09-08 Thread Anthony Ritter
Greetings,
The following code is from Learning PHP5 [O'Reilly] on page 90.  Example -
6.5:

I get a:

Warning: Invalid argument supplied for foreach() in
c:\apache\htdocs\or_6.4.php on line 15

after submitting the form.

I'm not sure why since the example uses the call to foreach() in which the
array $lunch is passes through the call to retireve the values of the array

Thank you for your help.
TR


form method=post action=eat.php
select name=lunch[] multiple
option value=porkBBQ Pork Bun/option
option value=chickenChicken Bun/option
option value=lotusLotus Seed Bun/option
option value=porkBean Paste Bun/option
option value=chickenBird-Nest Bun/option
/select
brbr
input type=submit name=submit
/form
Selected buns:
br
?
foreach ($_POST['lunch'] as $choice)
 {
  print You want a $choice bun.br;
 }
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] htmlentities()

2004-09-08 Thread Anthony Ritter
Copied and pasted the following sample script from the php manual and this
outputs:

...
?php
$str = A 'quote' is bbold/b;
echo htmlentities($str);

?
..

// outputs: A 'quote' is bbold/b

Not sure why the I am still getting the tags and spaces after the call to
htmlentities().

Thank you for any help.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] htmlentities()

2004-09-08 Thread Anthony Ritter
Chris Shiflett wrote:

 View source, and I think you'll understand. Or, remove the call to
 htmlentities().

 Chris
..

Thank you all for your assistance.

Best...
TR
...

...when a browser sees  lt, it prints out a  character instead of
thinking OK here comes an HTML tag.  This is the same idea (but with a
differnt syntax) as escaping a  or $ charcater inside a double quoted
string... ~[from Learning PHP5 [O'Reilly] page 102]



?php
$str = I blove/b sweet tea and div class=\fancy\rice./div 
tea\n;
echo $str;
echo br;
echo htmlentities($str);
?

// Output in view source code:

I blove/b sweet tea and div class=fancyrice./div  tea
brI lt;bgt;lovelt;/bgt; sweet tea and lt;div
class=quot;fancyquot;gt;rice.lt;/divgt; amp; tea

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Does this beginner's book exist?

2004-09-02 Thread Anthony Ritter
Chris Lott wrote in message:

 I am looking for a new text for my beginning PHP...[snipped]
...

Besides Larry's book - which is excellent - try David Sklar's book called
Learning PHP 5 (O'Reilly).

Not too much on mySQL with PHP except for chapter 7 _however_ the whole book
is grounded in the understanding of PHP syntax and constructs - if/else,
loops, arrays, functions - then moves on to databases, cookies/sessions,
forms and files.

Clear, concise and with humor and if you like Chinese food great entrees for
the array examples.

Both books are very good.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Does this beginner's book exist?

2004-09-02 Thread Anthony Ritter

Chris Lott [EMAIL PROTECTED] wrote in message:

 I am looking for a new text for my beginning PHP and MySQL programming
 class. This class is for COMPLETE beginners who have never programmed
 before. I have used, in the past, PHP4: A Beginner's Guide and PHP for
 the World Wide Web (Visual Quicktart).  (I will be using PHP4, at
 least until the Redhat Enterprise Server upgrades :)

 However, both of these books, while being well pitched towards
 beginners, also assume that register_globals is enabled, and while the
 former is more like a textbook (it has exercises and mini-quizzes) it
 doesn't do as good a job with the examples as the latter  (which has
 no exercises). My students are distance education students, so little
 things like variable scopes can be very time consuming to help them
 with-- it would be nice if the text got it right :)

 Does a book for complete beginners exist that also demonstrates basic
 good programming practices, has decent examples, and perhaps
 exercises/quizzes (not as important as the first two)?

 c
 --
 Chris Lott
...

Besides Larry's book - which is excellent - try David Sklar's book called
Learning PHP 5 (O'Reilly).

Not too much on mySQL with PHP except for chapter 7 _however_ the whole book
is grounded in the understanding of PHP syntax and constructs - if/else,
loops, arrays, functions - then moves on to databases, cookies/sessions,
forms and files.

Plus, there are questions at the end of each chapter.

Clear, concise and with humor and - if you like Chinese food - mouth
watering entrees for
the array examples.

Both books are very good.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] strcasecmp()

2004-08-29 Thread Anthony Ritter
?
$first_name = Hello;
$second_name = Hello;

if(strcasecmp($first_name,$second_name)) {
 echo words are equal;
}
else
{
 echo words are not equal.;
}
?
..

In strcasecmp() - this comparison will return 0 - interpreted by PHP as
FALSE - eventhough words are _equal_ so what will execute is words are not
equal.
whereas if the negation symbol of ! is inserted as in:

...
?
$first_name = Hello;
$second_name = Hello;

if(!strcasecmp($first_name,$second_name)) {
 echo words are equal;
}
else
{
 echo words are not equal.;
}
?
...

to read if the comparsion which is returned is not _FALSE_ excecute:
words are equal.
.

Am I on the right track with this logic?
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_fetch_array()

2004-08-18 Thread Anthony Ritter
Thank you Chris.

My question was the call to

mysql_fetch_array()

will also return a result set without the additional argument constant as
in:

while ($row = mysql_fetch_array($sql))
 {...
 // no constant is being used

There are many times that I see that used in textbooks - without the
constant - just the variable from the sql query as the argument.

TR


---
[This E-mail scanned for viruses by gonefishingguideservice.com]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mysql_fetch_array()

2004-08-17 Thread Anthony Ritter
When using mysql_fetch_array() is it necsessary to specify the second
argument - meaning the constant of MYSQL_NUM or MYSQL_ASSOC?

I have seen many examples where it is left out and it is coded:

$row = mysql_fetch_array($sql);

as opposed to

$row = mysql_fetch_array($sql, MYSQL_BOTH);

Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] RSS / eregi_replace()

2004-08-03 Thread Anthony Ritter
Greetings,

I'm using an RSS feed from the New York Times and right now the a href link
takes the user to the same window.

I'd like the link to open in it's own window by using the target .html
attribute.

I was hoping that I could use the eregi_replace() call by inserting:

a href=http://\\0;target=_blank\\0/a

where it matches any character between the link/link string in the URL.

However it is not working for me.

Viewing the xhtml of thr NY Times feed below, there are many areas of
links/links so I'm not sure whether this is the correct way to go.

Any leads or assistance will be greatly appreciated.

TR
..

?
$string=linkhttp://www.nytimes.com/2004/08/03/national/03tape.html?
ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt/link; // the
string URL

$pattern = ^(link.+/link)$;  //match any character between the link
and link

$replace_pattern= 'a href=http://\\0;target=_blank\\0/a';

$new_string=eregi_replace($pattern,$replace_pattern,$string);

echo $new_string;
?


// snippet of NYTimes RSS feed

linkhttp://www.nytimes.com/2004/08/03/politics/03intel.html?ex=1249272000;
en=e061516bea792668ei=5088partner=rssnyt/link
  descriptionMuch of the information that led to the new terror alert was
three or four years old, but even the dated evidence was
troubling./description
  authorBy DOUGLAS JEHL and DAVID JOHNSTON/author
  pubDateTue, 03 Aug 2004 00:00:00 EDT/pubDate
  /item
- item
  titleTape of Kennedy's Killing Is Getting Digital Analysis/title

linkhttp://www.nytimes.com/2004/08/03/national/03tape.html?ex=1249272000e
n=484f82ff258ab8c7ei=5088partner=rssnyt/link

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] RSS / eregi_replace()

2004-08-03 Thread Anthony Ritter
Justin Patrin [EMAIL PROTECTED] wrote in message:
 Thanks, lots of good info here. It's nice to have all of the info at once.

 I don't know about eregs myself, but I'll try a preg solution:

 $new_text = preg_replace('!link(.*?)/link!', 'a href=\1
 target=_blank\1/a', $text);


Thank you.

I tried the following:

?
$text=linkhttp://www.nytimes.com/2004/08/03/national/03tape.html?
ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt/link;

$new_text = preg_replace('!link(.*?)/link!', 'a href=\1
target=_blank\1/a', $text);

echo $new_text;
?

The output in my browser is the URL with no link - and no target=_blank.

http://www.nytimes.com/2004/08/03/national/03tape.html?
ex=1249272000en=484f82ff258ab8c7ei=5088partner=rssnyt

If you get a chance run the script through your server and see.

I'm on apache.

Any throughts?

Many thanks for your time.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php textbook

2004-08-02 Thread Anthony Ritter
Reading Creating Interactive Websites with PHP and Web Services (Sybex) by
Eric Rosebrock.

I've found it a good textbook and wanted to get some feedback from the group
about two things I noticed in most of the code throughout the book which has
helped me.

1. The author separtares .html form from .php script by using many include()
functions for the .html files.  I have found that that helps from getting
parse errors from the many escaped strings throughout the .html within a
.php file if the coder can separate the .html markup from the backend script
as much as possible.

Kind of like CSS which can separate form from content.

2. The author makes use of many switch() constructs throughout the book as
opposed to if / else.

He brings in variables from query strings when the user submits the .html
form to match the switch() contructs which then decides what action will
follow.

Anyway, I found the textbook a nice change in the way he presented his
scripts and thought others would like to share any feedback if they have
read or are reading the book.

TIA
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] form textbox with search

2004-04-20 Thread Anthony Ritter
Greets,
The following code snippet receives data from a textbox named searchtext if
the user types in a word.

It then tries to match that word from the mysql database using:

$searchtext = $_POST['searchtext'];
if ($searchtext != '') { // Some search text was specified
  $where .=  AND blurb LIKE '%$searchtext%';
}

and adding on to the WHERE sql statement.

If the user clicks the submit _without_ inserting a word, the whole database
is output due to the basic select sql statement of:

$select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price';
$from   = ' FROM merch';
$where  = ' WHERE 1=1  ';

I am trying to work out a way to display a page that might say - Please
enter a word if the user fails to insert a word in the textbox.

Any help greatly appreciated.
TR
.


?php
$dbcnx = mysql_connect('localhost', 'root', 'mypass');
mysql_select_db('sitename');

// The basic SELECT statement
$select = 'SELECT DISTINCT merch.ID, merch.blurb, merch.price';
$from   = ' FROM merch';
$where  = ' WHERE 1=1  ';

$lid = $_REQUEST['lid'];
if ($lid != '') { // An lot is selected
  $where .=  AND lid='$lid';
}

$searchtext = $_POST['searchtext'];
if ($searchtext != '') { // Some search text was specified
  $where .=  AND blurb LIKE '%$searchtext%';
}
?

table border=1 align=center
trthClick for
details/ththDescription/ththPrice/ththEdit/ththDelete/tht
hPhoto/th/tr

//etc.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
A basic ht counter script from Meloni's book on mysql (page 318).

Not working for me.
Every time I load the page the counter stays at zero.

Thanks for help.
TR
..

?
$page_name=test1;
$db=mysql_connect(localhost,root,'mypass);
mysql_select_db(sitename);
$sql = UPDATE test_track SET hits = hits + 1 WHERE page_name =
'$page_name';
$sql2=SELECT hits FROM test_track WHERE page_name='$page_name';
$res=mysql_query($sql2);
$hits = mysql_result($res,0,'hits');
?
html
body
h1You have been counted./h1
p
The current number is ? echo $hits; ?/p
/body
/html
.

// mysql SCHEMA

CREATE TABLE test_track(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
page_name VARCHAR(50),
hits INT
);

INSERT INTO test_track VALUES(1,'test1',0);


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] binary data in php

2004-04-16 Thread Anthony Ritter
Lowell Allen [EMAIL PROTECTED] wrote in message:

 You might try using $HTTP_POST_FILES rather than $_FILES -- was
 necessary in my code recently.

 --
 Lowell Allen
...

Lowell,
Thank you.

I tried that in code below.

Still - no dice.

Any other thoughts?

Best...
TR
...

?
 if ($submit) {

// connect to the database
// (you may have to adjust the hostname,username or password)

mysql_connect(localhost,root,mypass);
mysql_select_db(mydb);

 $uploadfile = $HTTP_POST_FILES['form_data']['tmp_name'];
 $uploadname = $HTTP_POST_FILES['form_data']['name'];
 $uploadtype = $HTTP_POST_FILES['form_data']['type'];
 $uploaddesc = $_POST['desc'];

// Open file for binary reading ('rb')
 $tempfile = fopen($uploadfile,'rb');

  // Read the entire file into memory using PHP's
 // filesize function to get the file size.
 $filedata = fread($tempfile,filesize($uploadfile));

// Prepare for database insert by adding backslashes
 // before special characters.
 $filedata = addslashes($filedata);

// Create the SQL query.
 $sql = INSERT INTO binary_data SET
  filename = '$uploadname',
  filetype = '$uploadtype',
  description = '$uploaddesc',
  bin_data = '$filedata';

 $ok = @mysql_query($sql);

 if(!$ok)die('Database error storing the file:'.mysql_error());

 $id= mysql_insert_id();


   print pThis file has the following Database ID: b$id/b;
   echo br;
   echo a href=\getdata.php?id=$id\Click to view file/a;
   MYSQL_CLOSE();

} else {

// else show the form to submit new data:
?

form method=post action=?php echo $PHP_SELF; ?
enctype=multipart/form-data
pFile Description:br
input type=text name=desc size=40
INPUT TYPE=hidden name=MAX_FILE_SIZE value=100
brFile to upload/store in database:br
input type=file name=form_data size=40
pinput type=submit name=submit value=submit
/form
?php
}
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] binary data in php

2004-04-16 Thread Anthony Ritter

John W. Holmes [EMAIL PROTECTED] wrote in message:


 So what's the output? How do you know it's not working? If you're not
 getting an error, then your query is running and something is going in
 the database. Are you sure the problem isn't in how you're displaying
 the data?
..
John,
I know that there is no binary file upload to the table called binary_data
in mysql database since I checked if there was a new entry through the
command line after I submit.

After I hit submit, the field that I inserted are blank.

Any other thoughts?

Thank you for your time.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] binary data in php

2004-04-16 Thread Anthony Ritter
Marek Kilimajer [EMAIL PROTECTED] wrote in message:

 You said register globals are off, didn't you? Where is the above
 variable set then?

 :)
...

That was it.

Many thanks Marek and others.

Checking through the command line the file was uploaded to mysql database.

However when clicking the getdata.php link - the file does not appear on the
screen.

The code is below.

Thank you for your time.
TR
.

//getdata.php

?
if($_GET['id']==1) {
@myql_connect(localhost,root,mypass);
@mysql_select_db(sitename);
$query = SELECT bin_data,description,filetype
  FROM binary_data
  WHERE id=1;
$result = @mysql_query($query);
$data = @mysql_result($result,0,bin_data);
$description = @mysql_result($result,0,description);
$type = @mysql_result($result,0,filetype);
Header( Content-type: $type);
echo $data.br;
echo $description.br;
}
else
 {

@mysql_connect(localhost,root,mypass);
@mysql_select_db(sitename);
$query = SELECT bin_data,description,filetype
  FROM binary_data
  WHERE id=$id;
$result = @mysql_query($query);
$data = @mysql_result($result,0,bin_data);
$description = @mysql_result($result,0,description);
$type = @mysql_result($result,0,filetype);
Header( Content-type: $type);
echo $data.br;
echo $description.br;
}
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] file upload

2004-04-15 Thread Anthony Ritter
In the following snippet, which uploads binary files to a mySQL database it
works fine when Register Globals are set to ON.
.
mysql_connect(localhost,root,pass);
mysql_select_db(adatabase);

$data = addslashes(fread(fopen($form_data, r), filesize($form_data)));

$result=mysql_query(INSERT INTO binary_data
(description,bin_data,filename,filesize,filetype) .
VALUES
('$form_description','$data','$form_data_name','$form_data_size','$form_data
_type'));

$id= mysql_insert_id();
print pThis file has the following Database ID: b$id/b;
echo br;
echo a href=\getdata.php?id=$id\Click to view file/a;

mysql_close();
...

However, when I turn the Register Globals to OFF and insert a $_FILES[ ][ ]
array for the form variables such as:

-

$data = addslashes(fread(fopen($_FILES[form_data], r),
filesize($_FILES[form_data])));

and

VALUES
('$_FILES[form_data][form_description]','$_FILES[form_data][data]','$_FILES[
form_data][form_data_name]','$_FILES[form_data][form_data_size]','$_FILES[fo
rm_data][form_data_type]'));
-

The file does not get uploaded.

Any assiatnce will be greatly appreciated.
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] binary data in php

2004-04-15 Thread Anthony Ritter
Greets,
Register globals are to off - however the files will not upload.

At wit's end - help please!

Thank all in advance.

TR


?
 if ($submit) {

// connect to the database
// (you may have to adjust the hostname,username or password)

MYSQL_CONNECT(localhost,root,mypass);
mysql_select_db(mydb);

 $uploadfile = $_FILES['form_data']['tmp_name'];
 $uploadname = $_FILES['form_data']['name'];
 $uploadtype = $_FILES['form_data']['type'];
 $uploaddesc = $_POST['desc'];

// Open file for binary reading ('rb')
 $tempfile = fopen($uploadfile,'rb');

  // Read the entire file into memory using PHP's
 // filesize function to get the file size.
 $filedata = fread($tempfile,filesize($uploadfile));

// Prepare for database insert by adding backslashes
 // before special characters.
 $filedata = addslashes($filedata);

// Create the SQL query.
 $sql = INSERT INTO binary_data SET
  filename = '$uploadname',
  filetype = '$uploadtype',
  description = '$uploaddesc',
  bin_data = '$filedata';

   $id= mysql_insert_id();

   print pThis file has the following Database ID: b$id/b;
   echo br;
   echo a href=\getdata.php?id=$id\Click to view file/a;
  MYSQL_CLOSE();

} else {

// else show the form to submit new data:
?

form method=post action=?php echo $PHP_SELF; ?
enctype=multipart/form-data
pFile Description:br
input type=text name=desc size=40
INPUT TYPE=hidden name=MAX_FILE_SIZE value=100
brFile to upload/store in database:br
input type=file name=form_data size=40
pinput type=submit name=submit value=submit
/form
?php
}
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] binary data in php

2004-04-15 Thread Anthony Ritter
John W. Holmes [EMAIL PROTECTED] wrote in message:
 Remember... we're laughing with you, not at you. You forgot to call
 mysql_query() in your code. :)
.

Hmmm... I wish it was as simple as that.

I inserted the mysql_query() below

but it still doesn't upload the file nor does it throw an error.

If you get a chance please take a look and advise.

Again, my thanks for your help,
TR


?
 if ($submit) {

// connect to the database
// (you may have to adjust the hostname,username or password)

MYSQL_CONNECT(localhost,root,mypass);
mysql_select_db(mydb);

 $uploadfile = $_FILES['form_data']['tmp_name'];
 $uploadname = $_FILES['form_data']['name'];
 $uploadtype = $_FILES['form_data']['type'];
 $uploaddesc = $_POST['desc'];

// Open file for binary reading ('rb')
 $tempfile = fopen($uploadfile,'rb');

  // Read the entire file into memory using PHP's
 // filesize function to get the file size.
 $filedata = fread($tempfile,filesize($uploadfile));

// Prepare for database insert by adding backslashes
 // before special characters.
 $filedata = addslashes($filedata);

// Create the SQL query.
 $sql = INSERT INTO binary_data SET
  filename = '$uploadname',
  filetype = '$uploadtype',
  description = '$uploaddesc',
  bin_data = '$filedata';

 $ok = @mysql_query($sql);

 if(!$ok)die('Database error storing the file:'.mysql_error());

 $id= mysql_insert_id();


   print pThis file has the following Database ID: b$id/b;
   echo br;
   echo a href=\getdata.php?id=$id\Click to view file/a;
   MYSQL_CLOSE();

} else {

// else show the form to submit new data:
?

form method=post action=?php echo $PHP_SELF; ?
enctype=multipart/form-data
pFile Description:br
input type=text name=desc size=40
INPUT TYPE=hidden name=MAX_FILE_SIZE value=100
brFile to upload/store in database:br
input type=file name=form_data size=40
pinput type=submit name=submit value=submit
/form
?php
}
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] .doc file

2004-03-30 Thread Anthony Ritter
Greets,
I've been able to open a remote URL, read it and then lop off everything
except the last line and break it into an array with its' tabs - /t .

The data will then be inserted into a table.

However, the following URL shows reservoir storage and is a .doc file.  I am
unable to run the same script with this URL since it is a .doc file - not a
.txt file.

The client has said that this is the only file that their office has and
does not offer any csv or tsv .txt files.

Is there anyway to acheive formatting this data using the following file?

http://water.usgs.gov/orh/nrwww/odrm/storage2004.doc

Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: .doc file

2004-03-30 Thread Anthony Ritter

Jason Barnett [EMAIL PROTECTED] wrote in message:

 Actually, why don't you just use plain text like this.  Sheesh,
 sometimes I forget the easy answer :)
..
Jason,
Thanks for the reply.

Since those figures change _daily_ on their site, I was hoping for a way to
open the file, read it, adjust the format by lopping off the last line into
an array and writing those values into a table - _without manually copying
and pasting the data each day into a .txt file_.

I have been able to do that with other remote URL's dynamically which were
designed as .txt files using a tab separator.  The php script opens and
reads the file every time it is changed on their server and formats the
data.

However, this file is a .doc file and I'm trying to find a way to achieve
the same result.

Best...
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] htmlspecialchars()

2004-03-25 Thread Anthony Ritter
php / mysql/ apache

I tried the following using the call to htmlspecialchars()

not sure why it is insn't working.

I get the output:
a href='test'Test/a

Thank you.
TR
..
//script

?
$new = htmlspecialchars(a href='test'Test/a, ENT_QUOTES);
echo $new;
?

// this is what is output:a href='test'Test/a
// instead of this...
// lt;a href=#039;test#039;gt;Testlt;/agt;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] isset() question

2004-02-15 Thread Anthony Ritter
The following script is from Kevin Yank's book (Sitepoint).

When I test it _without_ entering a name in the text box and hit submit, the
_next_  page
loads - however the same page should load beacuse of the conditional

if (!isset($name) ):
.

If I replace

!isset()

with

empty()


like

if (empty($name)):

and do not enter a name then the _same_ page loads which is what is supposed
to happen.

Why doesn't the call to !isset() with the negation mark loads the next page
when a name is not entered?

The script predates globals being turned off and it is below.

Thank you.
TR
.



html
head
title Sample Page /title
/head
body

?php if (!isset($name) ): ?

  !-- No name has been provided, so we
   prompt the user for one. --

  form action=?=$PHP_SELF? method=get
  Please enter your name: input type=text name=name /
  input type=submit value=GO /
  /form

?php else: ?

  pYour name: ?=$name?/p

  pThis paragraph contains a a
href=newpage.php?name=?=urlencode($name)?link/a that passes the name
variable on to the next document./p

?php endif; ?

/body
/html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] isset() question

2004-02-15 Thread Anthony Ritter
- Original Message -
From: Richard Davey [EMAIL PROTECTED]

 Hello Anthony,

 I feel the book you're learning from might not be the best out there!
 Especially as it uses the horrible if : else : endif notation,
 includes code on the same line as the PHP tags themselves and is
 teaching you to code with register globals on. Is the book still on
 sale? (i.e. did you buy it recently) or was it something you've had
 for a while/got 2nd hand?

 Best regards,
  Richard Davey
  http://www.phpcommunity.org/wiki/296.html

Thank you for the reply Richard.

Yes. The book is on sale at:

www.sitepoint.com

also, at amazon, b and n, etc.

In fact, it's now in it's second edition by Kevin Yank.

It's not a bad book - quite readable to a newbie like myself - but when I
ran that code it didn't jive with that function call.  To make sure, I
downloaded it from their site and ran it again - and the same thing
happened.

Thank you for your help.

TR






---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php_hostconnect()

2004-01-08 Thread Anthony Ritter
I currently have websites with two ISP's.

I am getting a lot of warnings throughout a .php script on one server - such
as:

php_hostconnect()

I have used the _same_ .php script exactly on my other ISP's server and I
don't get any warnings.

In addition, I have tested this script locally on Apache server without any
errors.

The site where I do not get warnnings has php 4.1.1 installed - wheras the
other site where I get php_hostcoonect() warnings is php 4.2.3

Any help will be greatly appreciated.

Thank you.
Tony Ritter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] localhost mail

2004-01-07 Thread Anthony Ritter
Using php/apache/mysql on win 98

I am testing an mail script.

The script has a .html form which receives the text input and then a .php
script to execute the variables in a mail() function.

When I publish both files - the .html and .php - to my ISP's server and
enter the data and hit submit  I receive an e-mail.

In my php.ini file I have configured the SMTP to the name of the ISP's email
server.

However, when testing the same script out locally on Apache Server: I get
the form box, enter the data but I do not receive an email.

I only use one ISP.  Is it possble they have two name servers and that is
why I am not receiving an e-mail when testing on Apache Server?

Thank you for any help.
Best...
Tony Ritter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mail()

2004-01-06 Thread Anthony Ritter
Using php/apache/mysql

I am testing an mail script.

The script has a .html form which receives the text input and then a .php
script to execute the variables in a mail() function.

When I publish both files - the .html and .php - to my ISP's server and
enter the data and hit submit  I receive an e-mail.

In my php.ini file I have configured the SMTP to the name of the ISP's email
server.

However, when testing the same script out locally on Apache Server: I get
the form box, enter the data but I do not receive an email.

I only use one ISP.  Is it possble they have two name servers and that is
why I am not receiving an e-mail when testing on Apache Server?

Thank you for any help.
Best...
Tony Ritter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] count()

2003-12-06 Thread Anthony Ritter
Marek Kilimajer [EMAIL PROTECTED] wrote in message:

 There are 10 '[PAGEBREAK]' substrings in the string. If the string is
 split apart at these substrings, it will give you total 11 parts.


Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] count()

2003-12-05 Thread Anthony Ritter
Greetings-
I'm have the follwing string called $text and throughout this string I'd
like to split this into an array by calling spliti() at the tag called
PAGEBREAK.

So, I count the array elements starting at 0 and get to 9.

When I call count(), I get 11. Could somebody please explain why this is?
Thank you.
TR
.

?
$text=

aaa[PAGEBREAK] //this is the 0 element
bbb[PAGEBREAK] //[1]
ccc[PAGEBREAK] //[2]
ddd[PAGEBREAK] //[3]
eee[PAGEBREAK] //[4]
fff[PAGEBREAK] //[5]
ggg[PAGEBREAK] //[6]
hhh[PAGEBREAK] //[7]
iii[PAGEBREAK] //[8]
jjj[PAGEBREAK] //...and this is the 9th element

;

$regexp=\[PAGEBREAK];
$textarray=spliti($regexp,$text);
$num_array=count($textarray);
$another_num_array=count($textarray)-1;

echo There are .$num_array. elements using the count() function.br;
echo If I subtract 1 since elements begin at 0, there are
.$another_num_array..;


//This is the output using count():
//...
//There are 11 elements using the count() function.
//If I subtract 1 since elements begin at 0, there are 10

?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] file paths and binaries

2003-11-23 Thread Anthony Ritter
Greetings all,
I'm looking for a tutorial or some assistance in explaning how store and
then open and read a binary file using php/mysql.

I've got a few tutorials about storing the binary data _within_ a mysql
table from Kevin Yank, phpbuilder, etc. but I've heard that it's sometime
better to keep your binaries on the server and not in the database.

Thus, if the developer just keeps the file path in a VARCHAR column like:
C:\apache\images\house.jpg
C:\apache\images\tree.jpg
etc...

and then directs that file be

fopen()
fread(), etc.
it will work without the added overhead.

I'm a bit lost in what happens after the filepaths are inserted into the
database and what steps follow in the script so that they can be opened and
read.

Any help, URL's or tutorials will be of assistance.
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] download from mysql script

2003-11-23 Thread Anthony Ritter
I'm trying to receive data from a mysql database through php.

Using the command line at mysql listed below gives me a result set.

I am able to connect to the database through php, however, when using the
following script, I receive no data when the data is in the table called
pictures in the db called sitename.

?
if($ID) {
@MYSQL_CONNECT(localhost,root,thepassword);
@mysql_select_db(sitename);
$query = select bin_data,filetype from pictures where ID=$ID;
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,bin_data);
$type = @MYSQL_RESULT($result,0,filetype);
Header( Content-type: $type);
echo $data;
}
?

// In browser window it reads:
// http://localhost/download.php?filename=7

//...and on the Command Line using the following query:
// SELECT filetype FROM pictures where ID=$ID
// gives me a image/pjpeg as the result set.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] =sessions / J. Meloni Textbook=

2003-11-19 Thread Anthony Ritter
Thanks again but here's what happens when I run that.

The form box appears.
I select an option.
I hit submit.
The page that loads says:

Warning: Invalid argument supplied for foreach() in
c:\apache\htdocs\session_yyy.php on line 13

I then hit the link:
Back to content page.

The form box appears.
I select _another_ option.
I hit submit.
The page that loads now has the _second_ value I have submitted but not the
first.

Like:
1.
2. Hal 2000

Is there a way to get the first option into the array?

If you get a chance please try the code.
Thanking you for your time.
TR
..

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] =sessions / J. Meloni Textbook=

2003-11-19 Thread Anthony Ritter
Sure.

Here it is.

There are three scripts.

session_1.php: the original form script.
session_1a.php: a revised script with a conditional else.
session_2.php: the receiving script for the session array variable.

Running script 1a and 2 works fine.

However the original script 1 and 2 gives me a error when returning to the
contents page the first time - it then fills the contents starting with the
number 2 on subsequent page loads.

as in:
1.
2. Hal 2000
3. Sonic Screwdriver

Try it and see and let me know.
Thank you.
TR
.


// this is the original script
// script session_1.php

?php
session_start();
?
html
head
titleStoring an array with a session/title
/head
body
h1Product Choice Page/h1
?php
if (isset($_POST[form_products])) {
if (!empty($_SESSION[products])) {
$products = array_unique(
array_merge(unserialize($_SESSION[products]),
$_POST[form_products]));
   }
$_SESSION[products] = serialize($products);
print pYour products have been registered!/p;
}
?
form method=POST action=?php $_SERVER[PHP_SELF] ?
PSelect some products:br
select name=form_products[] multiple size=3
optionSonic Screwdriver/option
optionHal 2000/option
optionTardis/option
optionORAC/option
optionTransporter bracelet/option
/select
brbr
input type=submit value=choose
/form
brbr
a href=session_2.phpcontent page/a
/body
/html

...
//this is a revised script with a conditional else
//script session_1a.php
?php
session_start();
?
html
head
titleStoring an array with a session/title
/head
body
h1Product Choice Page/h1

?php
if (isset($_POST['form_products'])) {
if (!empty($_SESSION['products'])) {
$products = array_unique(
array_merge(unserialize($_SESSION['products']),
$_POST['form_products']));
}else{ //this conditional has been added
$products = $_POST['form_products'] ;
}
$_SESSION['products'] = serialize($products);
print pYour products have been registered!/p;
}
?

form method=POST action=?php $_SERVER[PHP_SELF] ?
PSelect some products:br
select name=form_products[] multiple size=3
optionSonic Screwdriver/option
optionHal 2000/option
optionTardis/option
optionORAC/option
optionTransporter bracelet/option
/select
brbr
input type=submit value=choose
/form
brbr
a href=session_2.phpcontent page/a
/body
/html
..
//this is session_2.php

?php
session_start();
?
html
head
titleListing 16.5 Accessing session variables/title
/head
body
h1 Content Page/h1
?php
if (isset($_SESSION[products])) {
   print bYour cart:/bol\n;
   foreach (unserialize($_SESSION[products]) as $p) {
   print li$p;
   }
   print /ol;
}
?
a href=session_1.phpBack to product choice page/a
/body
/html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] =sessions / J. Meloni Textbook=

2003-11-19 Thread Anthony Ritter
Additinally, upon looking at the session files in:

C:/apache/tmp:

I get from session file from script session_1a.php:

products|s:23:a:1:{i:0;s:6:Tardis;};
...

However, looking at session file from script session_1.php:

I get:

products|s:2:N;;

--


Anthony Ritter [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Sure.

 Here it is.

 There are three scripts.

 session_1.php: the original form script.
 session_1a.php: a revised script with a conditional else.
 session_2.php: the receiving script for the session array variable.

 Running script 1a and 2 works fine.

 However the original script 1 and 2 gives me a error when returning to the
 contents page the first time - it then fills the contents starting with
the
 number 2 on subsequent page loads.

 as in:
 1.
 2. Hal 2000
 3. Sonic Screwdriver

 Try it and see and let me know.
 Thank you.
 TR
 .


 // this is the original script
 // script session_1.php

 ?php
 session_start();
 ?
 html
 head
 titleStoring an array with a session/title
 /head
 body
 h1Product Choice Page/h1
 ?php
 if (isset($_POST[form_products])) {
 if (!empty($_SESSION[products])) {
 $products = array_unique(
 array_merge(unserialize($_SESSION[products]),
 $_POST[form_products]));
}
 $_SESSION[products] = serialize($products);
 print pYour products have been registered!/p;
 }
 ?
 form method=POST action=?php $_SERVER[PHP_SELF] ?
 PSelect some products:br
 select name=form_products[] multiple size=3
 optionSonic Screwdriver/option
 optionHal 2000/option
 optionTardis/option
 optionORAC/option
 optionTransporter bracelet/option
 /select
 brbr
 input type=submit value=choose
 /form
 brbr
 a href=session_2.phpcontent page/a
 /body
 /html

 ...
 //this is a revised script with a conditional else
 //script session_1a.php
 ?php
 session_start();
 ?
 html
 head
 titleStoring an array with a session/title
 /head
 body
 h1Product Choice Page/h1

 ?php
 if (isset($_POST['form_products'])) {
 if (!empty($_SESSION['products'])) {
 $products = array_unique(
 array_merge(unserialize($_SESSION['products']),
 $_POST['form_products']));
 }else{ //this conditional has been added
 $products = $_POST['form_products'] ;
 }
 $_SESSION['products'] = serialize($products);
 print pYour products have been registered!/p;
 }
 ?

 form method=POST action=?php $_SERVER[PHP_SELF] ?
 PSelect some products:br
 select name=form_products[] multiple size=3
 optionSonic Screwdriver/option
 optionHal 2000/option
 optionTardis/option
 optionORAC/option
 optionTransporter bracelet/option
 /select
 brbr
 input type=submit value=choose
 /form
 brbr
 a href=session_2.phpcontent page/a
 /body
 /html
 ..
 //this is session_2.php

 ?php
 session_start();
 ?
 html
 head
 titleListing 16.5 Accessing session variables/title
 /head
 body
 h1 Content Page/h1
 ?php
 if (isset($_SESSION[products])) {
print bYour cart:/bol\n;
foreach (unserialize($_SESSION[products]) as $p) {
print li$p;
}
print /ol;
 }
 ?
 a href=session_1.phpBack to product choice page/a
 /body
 /html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] =sessions / J. Meloni Textbook=

2003-11-18 Thread Anthony Ritter
Using mysql, apache and win98

The following code is from PHP, mySQL and Apache (SAMS) by Julie Meloni.

Page 338-339 (hour 16).

After choosing my selections in the form box and hitting submit I get:
...

Warning: Invalid argument supplied for foreach() in
c:\apache\htdocs\listing16.5.php on line 13
..

I checked her errata at thickbooks.com but there was nothing for this
chapter.

Any help will be greatly appreciated.
Thank you.
TR
---

// script 16.4.php
?php
session_start();
?
html
head
titleListing 16.4 Storing an array with a session/title
/head
body
h1Product Choice Page/h1
?php
if (isset($_POST[form_products])) {
if (!empty($_SESSION[products])) {
$products = array_unique(
array_merge(unserialize($_SESSION[products]),
$_POST[form_products]));
   }
$_SESSION[products] = serialize($products);
print pYour products have been registered!/p;
}
?
form method=POST action=?php $_SERVER[PHP_SELF] ?
PSelect some products:br
select name=form_products[] multiple size=3
optionSonic Screwdriver/option
optionHal 2000/option
optionTardis/option
optionORAC/option
optionTransporter bracelet/option
/select
brbr
input type=submit value=choose
/form
brbr
a href=listing16.5.phpcontent page/a
/body
/html
..


// script 16.5.php
html
head
titleListing 16.5 Accessing session variables/title
/head
body
h1 Content Page/h1
?php
if (isset($_SESSION[products])) {
   print bYour cart:/bol\n;
   foreach (unserialize($_SESSION[products]) as $p) {
   print li$p;
   }
   print /ol;
}
?
a href=listing16.4.phpBack to product choice page/a
/body
/html
...

Warning: Invalid argument supplied for foreach() in
c:\apache\htdocs\listing16.5.php on line 13

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] =sessions / J. Meloni Textbook=

2003-11-18 Thread Anthony Ritter
Thanks John and others.

I'm using the script and no values show up in the page:
session_bb.php

after I submit the values in the select form.

If somebody would like to test both scripts (session_aa.php and
session_bb.php) and get back to me I would be grateful.

As I said, these were from her book/CD.

Thank you.
TR
.

// this is session_aa.php script
?php
session_start();
?
html
head
titleListing 16.4 Storing an array with a session/title
/head
body
h1Product Choice Page/h1
?php
if (isset($_POST[form_products])) {
if (!empty($_SESSION[products])) {
$products = array_unique(
array_merge($_SESSION[products],
$_POST[form_products]));
   }
$_SESSION[products] = $products;
print pYour products have been registered!/p;
}
?
form method=POST action=?php $_SERVER[PHP_SELF] ?
PSelect some products:br
select name=form_products[] multiple size=3
optionSonic Screwdriver/option
optionHal 2000/option
optionTardis/option
optionORAC/option
optionTransporter bracelet/option
/select
brbr
input type=submit value=choose
/form
brbr
a href=session_bb.phpcontent page/a
/body
/html
..
// ...and this is session_bb.php script
?
session_start();
?
html
head
titleListing 16.5 Accessing session variables/title
/head
body
h1 Content Page/h1
?php

if (isset($_SESSION[products])) {
   print bYour cart:/bol\n;
   foreach (unserialize($_SESSION[products]) as $p) {
   print li$p;
   }
   print /ol;
}
?
a href=session_aa.phpBack to product choice page/a
/body
/html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] naughty words / filter

2003-08-21 Thread Anthony Ritter
Hi,
I'm trying to filter a word - in this case - called badword1 - to be
replaced
with asterisks.

Listed below is my .html form and .php receiving script.

I've also added the same script which gets a hardcoded string.

In the first example, the output still shows the original message _without_
replacing the badword whereas in the second example with the hardcoded
string - it is getting replaced with *.

Any assistance would be greatly appreciated.
Thank you.
Tony Ritter

html
form action=themessage.php method=post
p
Your message:br
textarea name=message cols=40 rows=5
/textareabr
input type =submit name=submit value=Submit
/form
/html


// example #1: in the script the text in the variable $guestbook does not
get replaced.
?
$dirty_words = array(badword1,badword2,badword3);
$guestbook = stripslashes($message);
foreach ($dirty_words as $word){
 $message = str_replace($word, , $guestbook);
}
echo $message;
?
.

// example #2: in this snippet, the hardcoded string $guestbook gets
replaced with 
?
$guestbook=Boy, that Tony - he is a real badword1.
$dirty_words = array(badword1,badword2,badword3);
$message = $guestbook;
foreach ($dirty_words as $word){
 $message = str_replace($word, , $message);
}
echo $message;
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: naughty words / filter

2003-08-21 Thread Anthony Ritter
Was able to get this to filter:
.
?
}
$guestbook = stripslashes($message);
$this_is_the_message=$guestbook;
$dirty_words = array(badword1,badword2,badword3);
$message = $this_is_the_message;
foreach ($dirty_words as $word){
 $message = str_replace($word, , $message);
}
echo $message;
?

TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mysql output

2003-08-19 Thread Anthony Ritter
The following code snippet outputs a table from a mySQL database.

In version 1, I am able to get alternating background cell colors.  However,
the output gives me the same post five times.

In version 2, I am able to receive five separate posts - which is what I'm
looking for - but I'd like to get alternating cell backgrounds.

Somewhere my syntax is failing me.

Any advice would be greatly appreciated.
Thank you.
Tony Ritter

// version 1:

?php
//check for required info from the query string
if (!$_GET[topic_id]) {
   header(Location: topiclist.php);
   exit;
}

//connect to server and select database
$conn = mysql_connect(localhost, root, thisisapassword) or
die(mysql_error());
mysql_select_db(sitename,$conn)  or die(mysql_error());

//verify the topic exists
$verify_topic = select topic_title from forum_topics where topic_id =
$_GET[topic_id];
$verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error());

if (mysql_num_rows($verify_topic_res)  1) {
//this topic does not exist
$display_block = PemYou have selected an invalid topic. Please a
href=\topiclist.php\try again/a./em/p;
} else {
//get the topic title
   $topic_title = stripslashes(mysql_result($verify_topic_res,0,
'topic_title'));

   //gather the posts
   $get_posts = select post_id, post_text, date_format(post_create_time,
'%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where
topic_id = $_GET[topic_id] order by post_create_time asc;
   $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error());

   //create the display string
   $display_block = 
   PShowing posts for the strong$topic_title/strong topic:/p

   table width=100% cellpadding=3 cellspacing=1 border=1
   tr
   th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font
   /th
   th bgcolor=\#497fbf\font color=\#ff\POST/font/th
   /tr;

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
   $post_id = $posts_info['post_id'];
   $post_text = nl2br(stripslashes($posts_info['post_text']));
   $post_create_time = $posts_info['fmt_post_create_time'];
   $post_owner = stripslashes($posts_info['post_owner']);

   $i = 0;
while ($posts_info = @mysql_fetch_array($get_posts_res)) {//
begin light-dark loop
$row_class = (($i % 2) == 0) ? 'light' : 'dark';


$display_block .= 
  tr
   td width=35% valign=top
class=\$row_class\p$post_ownerbr[$post_create_time]/td
   td width=65% valign=top class=\$row_class\p$post_textbrbr
   a href=\replytopost.php?post_id=$post_id\img src=\submit.gif\
border=\0\/a/td
   /tr;
   $i++;

  }

}



  //close up the table
  $display_block .= /table;
}
?
html
head
style
p {font-family:sans arial;
   font-size: 1.25em;
}

th {
   font-family:arial;
   font-size: .75em;\
   font-color:#ff;
}

td {border:1px solid #ff;
   font-family:arial;
   font-size:.5em;
   color: #2d73b9}

.light {
  color:#000;
  background-color:#eee;
}
.dark {
  color:#000;
  background-color:#aaa;
}
/style
/head
body
titlePosts in Topic/title
/head
body
h1Posts in Topic/h1
?php print $display_block; ?
/body
/html

.


// version 2:

?php
//check for required info from the query string
if (!$_GET[topic_id]) {
   header(Location: topiclist.php);
   exit;
}

//connect to server and select database
$conn = mysql_connect(localhost, root, thisisapassword) or
die(mysql_error());
mysql_select_db(sitename,$conn)  or die(mysql_error());

//verify the topic exists
$verify_topic = select topic_title from forum_topics where topic_id =
$_GET[topic_id];
$verify_topic_res = mysql_query($verify_topic, $conn) or die(mysql_error());

if (mysql_num_rows($verify_topic_res)  1) {
//this topic does not exist
$display_block = PemYou have selected an invalid topic. Please a
href=\topiclist.php\try again/a./em/p;
} else {
//get the topic title
   $topic_title = stripslashes(mysql_result($verify_topic_res,0,
'topic_title'));

   //gather the posts
   $get_posts = select post_id, post_text, date_format(post_create_time,
'%b %e %Y at %r') as fmt_post_create_time, post_owner from forum_posts where
topic_id = $_GET[topic_id] order by post_create_time asc;
   $get_posts_res = mysql_query($get_posts,$conn) or die(mysql_error());

   //create the display string
   $display_block = 
   PShowing posts for the strong$topic_title/strong topic:/p

   table width=100% cellpadding=3 cellspacing=1 border=1
   tr
   th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font
   /th
   th bgcolor=\#497fbf\font color=\#ff\POST/font/th
   /tr;

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
   $post_id = $posts_info['post_id'];
   $post_text = nl2br(stripslashes($posts_info['post_text']));
   $post_create_time = $posts_info['fmt_post_create_time'];
   $post_owner = stripslashes($posts_info['post_owner']);

   //add to display
   $display_block .= 
   tr
   td width=35% valign=topp$post_ownerbr[$post_create_time]/td
  

Re: [PHP] mysql output

2003-08-19 Thread Anthony Ritter
 You also asked a very, very common question, i.e. how to alternate colors
in
 table rows... there are a ton of websites/tutorials out there that explain
 ways to do this.

 ---John Holmes...


Apologies for the lengthy code.

I've tried using a few tutorials and am still adrift.

Here's a snippet:

Thank you for any assistance.
Tony Ritter
..

?

table width=100% cellpadding=3 cellspacing=1 border=1
   tr
   th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font
   /th
   th bgcolor=\#497fbf\font color=\#ff\POST/font/th
   /tr;

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
   $post_id = $posts_info['post_id'];
   $post_text = nl2br(stripslashes($posts_info['post_text']));
   $post_create_time = $posts_info['fmt_post_create_time'];
   $post_owner = stripslashes($posts_info['post_owner']);

   $color1 = #CCFFCC;
   $color2 = #BFD8BC;
   $posts_info = 0;
   $row_color = ($posts_info % 2) ? $color1 : $color2;

   //add to display
   $display_block .= 
   tr
   td width=35% valign=top
bgcolor=\$row_color\p$post_ownerbr[$post_create_time]/td
   td width=65% valign=top bgcolor=\$row_color\p$post_textbrbr
   a href=\replytopost.php?post_id=$post_id\strongREPLY TO
POST/strong/a/td

   /tr;

   }

  //close up the table
  $display_block .= /table;
?
.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql output

2003-08-19 Thread Anthony Ritter
Thanks very much John.

I found the following and inserted it into my snippet for alternating
backgoriund colors.

However, I'm not sure I understand the logic.

This part:
...

$alternate = 2;
   while ($posts_info = mysql_fetch_array($get_posts_res)) {
   $post_id = $posts_info['post_id'];
   $post_text = nl2br(stripslashes($posts_info['post_text']));
   $post_create_time = $posts_info['fmt_post_create_time'];
   $post_owner = stripslashes($posts_info['post_owner']);

if ($alternate == 1) {
$color = #eaf3da;
$alternate = 2;
}
else {
$color = #d5eae9;
$alternate = 1;
}


Best...
Tony
.

$display_block = 
   PShowing posts for the strong$topic_title/strong topic:/p

   table width=100% cellpadding=3 cellspacing=1 border=0
   tr
   th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font
   /th
   th bgcolor=\#497fbf\font color=\#ff\POST/font/th
   /tr;
   $alternate = 2;
   while ($posts_info = mysql_fetch_array($get_posts_res)) {
   $post_id = $posts_info['post_id'];
   $post_text = nl2br(stripslashes($posts_info['post_text']));
   $post_create_time = $posts_info['fmt_post_create_time'];
   $post_owner = stripslashes($posts_info['post_owner']);

if ($alternate == 1) {
$color = #eaf3da;
$alternate = 2;
}
else {
$color = #d5eae9;
$alternate = 1;
}


   //add to display
   $display_block .= 
   tr
   td width=35% valign=top bgcolor=\$color\pa
href=mailto:$post_owner$post_ownerbr/a[$post_create_time]/td
   td width=65% valign=top bgcolor=\$color\p$post_textbrbr
   a href=\replytopost.php?post_id=$post_id\img src=\reply.gif\
border=\0\ align=\right\/a/td

   /tr;

   }

  //close up the table
  $display_block .= /table;


- Original Message -
From: John W. Holmes [EMAIL PROTECTED]
To: Anthony Ritter [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, August 19, 2003 9:59 PM
Subject: Re: [PHP] mysql output


 Anthony Ritter wrote:

 You also asked a very, very common question, i.e. how to alternate
colors
 
  in
 
 table rows... there are a ton of websites/tutorials out there that
explain
 ways to do this.
 
 ---John Holmes...
 
  
 
  Apologies for the lengthy code.
 
  I've tried using a few tutorials and am still adrift.
 
  Here's a snippet:
 
  Thank you for any assistance.
  Tony Ritter
  ..
 
  ?
 
  table width=100% cellpadding=3 cellspacing=1 border=1
 tr
 th bgcolor=\#497fbf\font color=\#ff\AUTHOR/font
 /th
 th bgcolor=\#497fbf\font color=\#ff\POST/font/th
 /tr;
 
 while ($posts_info = mysql_fetch_array($get_posts_res)) {
 $post_id = $posts_info['post_id'];
 $post_text = nl2br(stripslashes($posts_info['post_text']));
 $post_create_time = $posts_info['fmt_post_create_time'];
 $post_owner = stripslashes($posts_info['post_owner']);
 
 $color1 = #CCFFCC;
 $color2 = #BFD8BC;
 $posts_info = 0;

 Move the above line outside of your while loop

 $row_color = ($posts_info % 2) ? $color1 : $color2;

 $row_color = ($posts_info++ % 2) ? $color1 : $color2;

 You were setting $posts_info to zero in each loop, so it's never going
 to change. You must set it to zero outside of the loop, then increment
 it within.

 You could make this real easy and just do:

 $row_color = ($row_color == $color1) ? $color2 : $color1;

 --
 ---John Holmes...

 Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

 PHP|Architect: A magazine for PHP Professionals  www.phparch.com




 ---
 [This E-mail scanned for viruses by gonefishingguideservice.com]



---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] discussion forum from j. meloni's book

2003-08-14 Thread Anthony Ritter
Ford, Mike [LSS] [EMAIL PROTECTED] writes:

 You have a conceptual misconception.  In effect, you need to read that
query
 as:

   select ft.topic_id, ft.topic_title
  from ( forum_posts as fp
 left join forum_topics as ft
 on fp.topic_id = ft.topic_id
   )
  where fp.post_id = $_GET[post_id]

 In other words, the left join of the two tables is treated as a single
 virtual table, from which you could select any column of either original
 table.
..

Thanks Mike for the clear explanation.

TR






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] email confirmation script

2003-08-14 Thread Anthony Ritter
Thanks Jackson.

I appreciate the assistance.

Am I on the right track?

Best...
TR
..

// this is the form

html
body
form action=post method=process.php
p
Your e-mail address:br
input type=text name=namebr
input type=text name=emailbr
input type=submit name=submit value=submit
/body
/form
/html
...
//process.php
?
if ($email)
{
 $secret_variable = something_only_you_know;
 $confirmationID = md5($email.$secret_variable);
 $body = Thank you for registering $name \n;;
 $body .= Please click on the a
href=mailto:[EMAIL PROTECTED]/email_verify.php?email=$emailc
onfirmation_ID=$confirmation_IDlink/a
 mail($_POST['email'],'Thank you',$body,'From: Us Fish');
}

...

//email_verify.php
?

if ($_GET['confirmationID'] = md5($_GET['email'].$secret_variable)) {
// insert the user into the database
} else {
  // display an error message
}
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] discussion forum from j. meloni's book

2003-08-14 Thread Anthony Ritter
The following code is From Julie Meloni's textbook - PHP, mySQL and Apache
(SAMS) on page 305-307 / Listing 14.5:

It's the last script of a discussion forum which is comprised of four php
files and one html file.

The script can be seen at:
http://www.thickbook.com

Chapter 14 off the zipfile.

Anyway, in the textbook and the zip her mySQL query reads:
...
$verify = select ft.topic_id, ft.topic_title from forum_posts as fp left
join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];
.

The part that I'm confused about is:
...
select ft.topic_id, ft.topic_title from forum_posts


It seem that the alias of ft refers to forum_title - not forum_posts.

In fact, I switched the query to read as follows:

$verify = select ft.topic_id, ft.topic_title from forum_topics as ft left
join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];
..

And that seems to run fine.

Any explanations will be appreciated.

Her original code is below.

Thank you.

Tony Ritter

..


?php
//connect to server and select database; we'll need it soon
$conn = mysql_connect(localhost, root, thisisapassword) or
die(mysql_error());
mysql_select_db(sitename,$conn)  or die(mysql_error());

//check to see if we're showing the form or adding the post
if ($_POST[op] != addpost) {
   // showing the form; check for required item in query string
   if (!$_GET[post_id]) {
header(Location: topiclist.php);
exit;
   }

   //still have to verify topic and post
   $verify = select ft.topic_id, ft.topic_title from forum_topics as ft
left join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];
   $verify_res = mysql_query($verify, $conn) or die(mysql_error());
   if (mysql_num_rows($verify_res)  1) {
   //this post or topic does not exist
   header(Location: topiclist.php);
   exit;
   } else {
   //get the topic id and title
   $topic_id = mysql_result($verify_res,0,'topic_id');
   $topic_title = stripslashes(mysql_result($verify_res,
0,'topic_title'));

   print 
   html
   head
   titlePost Your Reply in $topic_title/title
   /head
   body
   h1Post Your Reply in $topic_title/h1
   form method=post action=\$_SERVER[PHP_SELF]\
   pstrongYour E-Mail Address:/strongbr
   input type=\text\ name=\post_owner\ size=40 maxlength=150

   PstrongPost Text:/strongbr
   textarea name=\post_text\ rows=8 cols=40 wrap=virtual/textarea

   input type=\hidden\ name=\op\ value=\addpost\
   input type=\hidden\ name=\topic_id\ value=\$topic_id\

   Pinput type=\submit\ name=\submit\ value=\Add Post\/p

   /form
   /body
   /html;
   }
} else if ($_POST[op] == addpost) {
   //check for required items from form
   if ((!$_POST[topic_id]) || (!$_POST[post_text]) || (!$_POST[post_owner]))
{
   header(Location: topiclist.php);
   exit;
   }

   //add the post
   $add_post = insert into forum_posts values ('', '$_POST[topic_id]',
'$_POST[post_text]', now(), '$_POST[post_owner]');
   mysql_query($add_post,$conn) or die(mysql_error());

   //redirect user to topic
   header(Location: showtopic.php?topic_id=$topic_id);
   exit;
}
?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Help Please in using fopen in PHP

2003-08-14 Thread Anthony Ritter
[EMAIL PROTECTED]
wrote in message:
 Hi Folks,

 I am currently learning php and Mysql a scripting language and DB i just
feel
 in love with. I am currently having problem in opening file to put data
 collected from clients when the purchase from an online shop. The scripts
is as
 follows.

 where i am having problem is this   // open file for appending
   $fp = fopen($DOCUMENT_ROOT/../orders/orders.txt , 'a');
[snipped]
.

Looks like that script was pulled from Welling and Thomson's textbook on PHP
and mySQL.

I've got the first edition - SAMS.

You need to create a file called:

orders.txt

which which would reside in the path of your argument to fopen().

Best...
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] discussion forum from j. meloni's book

2003-08-14 Thread Anthony Ritter
Ford, Mike [LSS] [EMAIL PROTECTED] writes:

 You have a conceptual misconception.  In effect, you need to read that
query
 as:

   select ft.topic_id, ft.topic_title
  from ( forum_posts as fp
 left join forum_topics as ft
 on fp.topic_id = ft.topic_id
   )
  where fp.post_id = $_GET[post_id]

 In other words, the left join of the two tables is treated as a single
 virtual table, from which you could select any column of either original
 table.
..

Thanks Mike for the clear explanation.

TR



---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] email confirmation script

2003-08-14 Thread Anthony Ritter
Hi,
I'm trying to find a script that does the following:

1. A user is presented with a form with a textbox for their e-mail address.
2. The user types in their e-mail addrees and submits the form.
3. A note is then sent from that server if their e-mail address , in fact,
exists.
3. If the e-mail address does exist - the user receives a note.   The user
is then presented with a link which they click to confirm and their e-mail
address in then inserted into the database.

I've searched through google for:
e-mail, confirmation, php, etc.

and have not come up with anything.

If anyone has code that I could look at, I would greatly appreciate it.

Many thanks,
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] discussion forum from j. meloni's book

2003-08-14 Thread Anthony Ritter
Jennifer Goodie [EMAIL PROTECTED] writes:

 You didn't switch the aliases around, you just switched the join order.
 This will provide unexpected results.  In order to understand it, you
should
 read up on left joins.
 http://www.mysql.com/doc/en/JOIN.html

Thank you.  But...

// the query

$verify = select ft.topic_id, ft.topic_title from forum_posts as fp left
join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];
...

My question: why - or how can - the columns ft.topic_id and ft.topic_title
come from the table forum_posts?

In the original schema, there is no column called topic_title in the table
called forum_posts.

When I change the following to read:

$verify = select ft.topic_id, ft.topic_title from forum_topics as ft left
join forum_posts as fp on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];

It works fine.

/*Roughly translated: Select the column ft.topic_id along with the column
ft.topic_title from the table called forum_topics which we'll call ft.  Then
join the table called forum_topics onto the table called forum_posts and
match the records where topic_id corresponds in both tables along with
post_id corresponds in both tables.*/




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] discussion forum from j. meloni's book

2003-08-14 Thread Anthony Ritter
Jennifer Goodie [EMAIL PROTECTED] writes:
They don't.  ft is aliased to forum_topics.


That's right.

ft is aliased to the forum_topics table.

The query reads:
...
$verify = select ft.topic_id, ft.topic_title from forum_posts as fp left
join forum_topics as ft on fp.topic_id = ft.topic_id where fp.post_id =
$_GET[post_id];
.
The question:

How can the column that is called:
ft.topic_title

in the select statement above

be taken from the table called forum_posts when it was not there in the
schema?

SELECT ft.topic_id, ft.topic_title FROM forum_posts...[snipped]

Thank you.
TR

---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] email confirmation script

2003-08-14 Thread Anthony Ritter
This is what I receive via e-mail after I click submit using the following
code.  As you can see - the html attribute a href= shows up and the whole
string in linked.  All I was looking for is a link to the URL and the word -
Click - to be underlined showing the link.

Additionally, the value (as in key/value) part of confirmation_ID  is
nowhere to be found in the query string.

Thank you for any assistance.
Tony Ritter

.
// This is what I get back via e-mail:

- Original Message -
From: Us
To: [EMAIL PROTECTED]
Sent: Thursday, August 14, 2003 2:04 PM
Subject: Thank you for registering


 Thank you for registering tony

 a
href=http://www.gonefishingguideservice.com/[EMAIL PROTECTED]
efishingguideservice.comconfirmation_ID=Click/a

-


/*the .html form which takes a name and an e-mail address */

html
body
form action=process_a.php method=post
p
Your name:br
input type=text name=namebr
Your e-mail address:br
input type=text name=emailbr
input type=submit name=submit value=submit
/body
/form
/html
...


/*process_a.php: which receives the name and email variables.  The script
then tries to then send the note back to the user with a link - called
CLICK.  When the user hits the link to email_verify.php the email address is
inserted into the database*/

?
 $msg = Thank you for registering $name\n\n;
 $msg .= a
href=\http://www.gonefishingguideservice.com/email_verify.php?email=$email;
confirmation_ID=$confirmation_IDCLICK/a;
 $secret_variable = something_only_you_know;
 $confirmation_ID = md5($email.$secret_variable);
 $to=[EMAIL PROTECTED];
 $subject=Thank you for registering;
 $mailheaders=From: Us;
 mail($to,$subject,$msg,$mailheaders);
?
.

// email_verify.php

?
if ($_GET['confirmation_ID'] = md5($_GET['email'].$secret_variable)) {
// insert the user into the database
} else {
  // display an error message
}
?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] mysql_real_escape_string

2003-08-04 Thread Anthony Ritter

Larry E . Ullman [EMAIL PROTECTED] wrote in message:

 The mysql_real_escape_string() requires a connection to the database.
 The connection identifier is defined in another script so it's brought
 in using the global statement.

 Hope that helps,
 Larry
.

Thank you Larry.

Now I see the variable $dbc as the connection to the database in other file
which uses require_once().

Best...
TR



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] mysql_real_escape_string

2003-08-03 Thread Anthony Ritter
The following function is from Larry Ullman's PHP and mySQL on page 217 -
script 6.8 - in which there is a connection to a mySQL database using PHP.

My question is that I'm not sure of the global variable $dbc.

If I am to understand...this made up function escape_data() will receive a
piece of data - say $_POST['first_name'] - and then check if
magic_quotes_gpc is turned on in the ini file.

If it returned true, then stripslashes will be applied to the data - if it
is not turned on, then slashes will be applied to the data variable.

What is the reason that the global variable $dbc is declared in the
function - I cannot find another instance of $dbc outside of the function in
script 6.8.

Thank you,
Tony Ritter
.


function escape_data($data)
{
global $dbc;
if (ini_get('magic_quotes_gpc'))
{
$data=stripslashes($data);
}
return mysql_real_escape_string($data,$dbc);
}
.
//check for a first name

if(empty($_POST['first_name']))
 {
   $fn=FALSE;
   $message='pYou forgot to enter you first name/p';
  }
else
 {
  $fn= escape_data($_POST['first_name']);   // calling the function
 }
..



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Using eregi_replace()

2003-08-01 Thread Anthony Ritter
Using eregi_replace(), is there a way to take out a piece of a sentence -
which has spaces - and then return the new sentence?

For example, to return the new sentence:

hello I must be going

from the original sentence:

blah blah blah hello I must be going blah blah.

I tried:
...
?
$text=blah blah blah hello I must be going blah blah;
$text= eregi_replace((hello.)(.going),$newtext,$text);
echo $newtext;
?
...

Thank you.
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using eregi_replace()

2003-08-01 Thread Anthony Ritter
Messju Mohr [EMAIL PROTECTED] writes:

 you mean
 $newtext= ereg_replace(.*?(hello.*going).*,\\1,$text);
 ??
..

Thank you but I get:

Warning: REG_BADRPT: in c:\apache\htdocs\string.php on line 3

Using:
.

?
$text=blah blah blah hello I must be going blah blah;
$newtext= eregi_replace(.*?(hello.*going).*,\\1,$text);
echo $newtext;
?


Regards,
TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Using eregi_replace()

2003-08-01 Thread Anthony Ritter
However, this works using:
preg_replace()

.

?
$text=blah blah blah hello I must be going blah blah;
$newtext= preg_replace(!.*?(hello.*going).*!,$1,$text);
echo $newtext;
?

Thank you all.

Is there a way I can be sure of the syntax?

!.*?(hello.*going).*!,  // the pattern which - I think - reads as follows:

!.*? //
do not use any character or characters before the grouping of hello

(hello.*going) //
get the grouping of hello and any character after that word to going

.*! //
do not use any character or characters after the grouping of going - not
sure why the exclamation is at the end if it is a negation symbol.

Please advise.

Thank you.
TR


$1, // the grouping
$text // the original string







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] strings

2003-08-01 Thread Anthony Ritter
In the following snippet, I'm trying to open and read a URL into the
variable $contents.
I'd like to use preg_replace() to return only part of that string beginning
with say - regional and ending with new - but I get the complete URL string
returned.

Thank you for any assistance.
Tony Ritter
...

?
$theurl=http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt;;
if (!($fp=fopen($theurl, r)))
 {
  echo Could not open the URL.;
  exit;
 }
$contents=fread($fp, 100);
$newtext= preg_replace(/.*?(regional.*new).*/,1,$contents);
fclose($fp);
echo $newtext;
?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strings

2003-08-01 Thread Anthony Ritter
Curt Zirzow wrote in message:

 This exact thing was talked about earlier today, with the subject
 'Using eregi_replace()'.


Right.

However, I've tried using the following code in which the text from the URL
is printed out completely and then I change the variable from $contents to
$text and using the line with preg_replace(), it still outputs the complete
text without the pattern match.

Any advice will be helpful.
Thank you.
TR


?
$theurl=http://weather.noaa.gov/pub/data/summaries/regional/ny/albany.txt;;
if (!($fp=fopen($theurl, r)))
 {
  echo Could not open the URL.;
  exit;
 }
$contents=fread($fp, 100);
fclose($fp);
echo $contents;
echo br;
$text=$contents;
$newtext= preg_replace(!.*?(REGIONAL.*YORK).*!,$1,$text);
echo $newtext;  // outputs the same text as above
?
..



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] strings

2003-08-01 Thread Anthony Ritter
Curt Zirzow writes:
 I did some testing you can see the code and results here:
 http://zirzow.dyndns.org/html/php/tests/preg/parse_doc.php
..

Thanks Curt.

I checked it out and I still pick up the following lines which I was looking
to delete on the pattern match.

They are:
.
Expires:No;;725283  //line 1
AWUS41 KALY 012014 //line 2
RWSALB // line 3
.

It could be that when the URL file is being opened and read that these
characters are on _three_ different_ lines as opposed to one line/string and
the match is not being met.

I was looking to delete those lines and to start the match at REGIONAL.

Best...
TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] anchor in php page

2003-07-29 Thread Anthony Ritter
I am trying to access a page published on a server - and then using an
anchor - to jump to a specific paragraph on that page.

For instance, if using asp, I could write:
www.thesite.com/thepage.asp?go=here

where here -the value - in the string query would be marked up as:
...
// thepage.asp

a name=here
blah,blah,blah, etc...
/a
...

Can this be done using php?

Thank you.
Tony Ritter



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: anchor in php page

2003-07-29 Thread Anthony Ritter
Ivo:
 Why not use :
 www.thesite.com/thepage.asp#here
.

Thank you Ivo.

I don't usually use asp but was wondering if the word go in asp like:

www.thesite.com/thepage.asp?go=here

 is a _reserved_ word in .asp which acts like the symbol # - serving as
the
anchor.

And if one can achieve this using php.

Thank you.
TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] isp configuratuion error

2003-04-04 Thread Anthony Ritter
When calling up a page on my web with the extension of .php, I presently get
the following notice. (please see below)

Before yesterday, I had been able to load any .php page on my web.

The ISP which hosts this web is on NT.

Please advise.
Thank you.
Tony Ritter
.

Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This means
that a page will only be served up if the REDIRECT_STATUS CGI variable is
set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual page
for CGI security.

For more information about changing this behaviour or re-enabling this
webserver, consult the installation file that came with this distribution,
or visit the manual page.






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] isp configuratuion error

2003-04-04 Thread Anthony Ritter
Burhan Khalid wrote in message:
 You need to edit the php.ini file (or if this is hosted, have your host
 change the php.ini file).

 The setting you want is : force-cgi-redirect

 You need to change this to false (0) for it to work on IIS.

 IIRC, it says something along those lines in the default
 php.ini-recommended that comes with the package.

 I'm not on my php box or else would give you the exact line to change,
 but I know its the force-cgi-redirect (might be cgi_force_redirect)
 setting that's causing this problem (had similar issue with local IIS
 install)
.

Thank you BK.

TR





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] upload question

2003-03-29 Thread Anthony Ritter
Greetings all,
Using PHP 4.1.1 / Apache Server / MS Win 98 / IE 5.5

The following script is from Julie Meloni's book PHP Fast and Easy on page
170-174.

The first part is an html form in which the user browses and chooses a file
to be upoloaded to the server.

The script works fine in that when I chose a file and hit submit it, the
file ends up in:

C:\apache\htdocs

However, in the book, in the last illustration, she explains:

Just to be sure, use the File/Open Page menu item in your _browser_ to
navigate through your filesystem and find the file that you just uploaded.

The illustration shows the .jpg file _within_ the browser screen on the
upper left hand side.

When I follow those steps and hit file / open, my paint program takes over
and opens the uploaded .jpg file and the browser interface of MS IE 5.5 is
gone.

Any advice would be appreciated.
Thank you.

Tony Ritter
...

// html form
/head
body
form action=upload.php method=post enctype=multipart/form-data
p
File to upload:
input type=file name=thefile size=30
/p
p
input type=submit name=submit value=Upload File
/p
/form
/body
/html


// .php script called  upload.php
?
if ($thefile != )
 {
  copy($thefile,C:\\apache\\htdocs\\$thefile_name)or die(Could not copy
the file.);
 }
else
 {
  echo No file to upload.;
 }
?
html
head
/head
body
p
You sent:
? echo $thefile_name; ?, a ? echo $thefile_size; ? byte file with a
mime type of ? echo $thefile_type ; ?.
/p
/body
/html




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ISP Blues

2003-03-26 Thread Anthony Ritter
The following script works fine when I test it at home using localhost on:

MS Win 98
Apache Server
PHP 4.1.1
php_gd.dll

I then publish the script to my web at my ISP's MS IIS server which is the
host and get an undefined function call of:

ImageCreate()

The ISP has said that they have installed php_gd.dll on their server but I
get that error.

I have run php scripts on this site _without_ the gd libraries.

Could somebody please advise how they should be installing the .dll file so
I can utlize the gd_libraries with php?

Many thanks,
Tony Ritter
..

The script...
?
$new_w=50;
$new_h=50;

header(Content-type: image/png);
header(Content-type: text/html);
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromPng(./square.png);

ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));

ImagePng($dst_img);

echo This is a square.;
?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] ISP Blues

2003-03-26 Thread Anthony Ritter
Marek,
For testing purposes, on my home computer with php 4.1.1 and Apache Server,
the script works fine.

Now, I'd like the script to work on my ISP's server which hosts my site.

They use MS IIS.

What are the correct steps for them to install the php_gd.dll file on their
server since that same script is causing an error when published to the web.

Many thanks,
Tony Ritter


1.


2.


3.

etc...

---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] using strcmp()

2003-03-16 Thread Anthony Ritter
The following test script for the function strcmp() is from page 114 -115 of
PHP (Hungry Minds).

I'm getting a parse error on line 6.

Using PHP 4.1.1 / MS Win 98 / Apache Server.

Many thanks...
Tony Ritter
..

?
// using strcmp()
$firstword=peach;
$secondword=mango;
$result=strcmp($firstword, $secondword)
if ($result=1)
 {
  $statement=comes after;
 }
else if ($result=-1)
 {
  $statement=comes before;
 }
else
 {
  $statement=is the same as;
 }
echo The word b$firstword/b $statement;
?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: using strcmp()

2003-03-16 Thread Anthony Ritter
Justin Garrett wrote:
 You were missing a semicolon:
 $result=strcmp($firstword, $secondword);
...

Thank you Justin and all other.
TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] cropping an image script

2003-03-13 Thread Anthony Ritter
In the following php script, the function takes the original file and crops
to the destination file.

I've ran the script using a .png file and a .jpg file.

The .png works fine whereas the .jpeg file returns only part of the image
along with a blue rectangle.

For instance - where the original image is a 200 x 300 jpeg called:

1_data.jpeg

and the destination iamge is 75x75 called:

 2_data.jpeg

and starting at the x,y coordinates of 0,0 - the script returns a 75x 75
file but only a sliver of the .jpg image is within the 75x75 blue square.

Any help will be of assistance.
Thank you.
Tony Ritter



The following is the php cropping script (with author credit):

?

//
//image crop fuction . [EMAIL PROTECTED]
//info at http://obala.net/en
//
// Yes the proses could be executed with imagecopyresized build-in function
// but with this function you get the idea of how an image color set is
constructed
//
// $cropX = source starting X
// $cropY = source starting Y
// $cropW = crop weigth
// $cropH = crop heigh
// $source = source filename
// $destination = destination filename
// $type = image type

function
im_crop($cropX,$cropY,$cropH,$cropW,$source,$destination,$type='jpeg') {

// switch known types and open source image
switch ($type) {
case 'wbmp': $sim = ImageCreateFromWBMP($source); break;
case 'gif': $sim = ImageCreateFromGIF($source); break;
case 'png': $sim = ImageCreateFromPNG($source); break;
default: $sim = ImageCreateFromJPEG($source); break;
}

// create the destination image
$dim = imagecreate($cropW, $cropH);

// pass trought pixles of source image
for ( $i=$cropY; $i($cropY+$cropH); $i++ ) {
for ( $j=$cropX; $j($cropX+$cropW); $j++ ) {
// get RGB color info about a pixel in the source image
$color = imagecolorsforindex($sim, imagecolorat($sim, $j, $i));
// insert the color in the color index of the new image
$index = ImageColorAllocate($dim, $color['red'],
$color['green'], $color['blue']);
// plots a pixel in the new image with that color
imagesetpixel($dim, $j-$cropX, $i-$cropY, $index);
}
}

// whe dont need the sorce image anymore
imagedestroy($sim);


// switch known types and save
switch ($type) {
case 'wbmp': ImageWBMP($dim, $destination); break;
case 'gif': ImageGIF($dim, $destination); break;
case 'png': ImagePNG($dim, $destination); break;
default: ImageJPEG($dim, $destination); break;
}

// free the used space of the source image
imagedestroy($dim);

}

// example
im_crop(0,0,75,75,'1_data.jpeg','2_data.jpeg','jpeg');

?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] cropping an image script

2003-03-13 Thread Anthony Ritter
I'm getting a fatal error on the following script using
MS Win 98 / Apache Server / PHP 4.1.1. / php_gd.dll

Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in
c:\apache\htdocs\testphoto.php on line 6

Is there a workaround to this function so that I can crop part of the source
.jpeg?
Thank you.
Tony Ritter
...
?
function
im_crop($cropX,$cropY,$cropH,$cropW,$source,$destination,$type='jpeg') {
// source image
$sim = ImageCreateFromJPEG($source);
// create the destination image
$dim = imagecreatetruecolor($cropW, $cropH);
// pass trought pixles of source image
for ( $i=$cropY; $i($cropY+$cropH); $i++ ) {
for ( $j=$cropX; $j($cropX+$cropW); $j++ ) {
   $pixel = imagecolorat($sim, $j, $i);
imagesetpixel($dim, $j-$cropX, $i-$cropY, $pixel);
}
}
imagedestroy($sim);
ImageJPEG($dim, $destination);
imagedestroy($dim);
}

// example
im_crop(0,0,75,75,'1_data.jpeg','2_data.jpeg','jpeg');

?


Fatal error: imagecreatetruecolor(): requires GD 2.0 or later in
c:\apache\htdocs\testphoto.php on line 6


---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: contents will not output

2003-03-11 Thread Anthony Ritter
Hugh,
That script works fine.
Thank you.

What I am trying to achieve is to pull a .jpeg from a remote URL and then
resize and/or crop it after it is placed in a variable.

Your script is able to open and read the original file for output.

In the following script, I have the variable $contents holding the file -
bar.jpg - which is - say 1000x1000 - and I am trying to reduce the size of
that file to 300x300.

I have php_gd libraries installed.

Many thanks,
Tony Ritter
...

?
 $file_to_open=http://www.foo.com/bar.jpg;;
 $fp=fopen($file_to_open,r);
 $contents=fread($fp,100); //reads to eof or  ~10K whichever comes first
 $new_w=300;
 $new_h=300;
 $dst_img=ImageCreate($new_w,$new_h);
 $src_img=ImageCreateFromJpeg($contents);

ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));
 ImageJpeg($dst_img);
 fclose($fp);
?


---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] image and text from remote URL

2003-03-11 Thread Anthony Ritter
There is a photograph named bar.jpg in a remote URL called
http://www.foo.com
The photograph is about 640 x 480 in size.

The following script allows me to open and read the file.
In addition, I have a file named data.jpg in my web folder.

I want to write the bar.jpg  into the data.jpg file and at the same time
reduce that image to 256 x 192.

After testing the following script on Apache server / MS Win 98 and PHP with
php_gd libraries it seems that I can accomplish that.

However, I cannot add a line of copy below the photo like:
?
print (It is );
print (date(l F j, Y));
?

Only the photo shows up and not the text.

How can I add a line of text along with the photo?

Thank you. The script follows...
Tony Ritter
.

?
$fh = fopen('http://www.foo.com/bar.jpg', 'r');
if ($fh) {
$imgbuffer = null;
while ($chunk = fread($fh, 100))
$imgbuffer .= $chunk;
fclose($fh);
} // o.k. to here...
$filename=C:\apache\htdocs\data.jpg;
$thephoto=$imgbuffer;
$myfile=fopen($filename,w+)or die(Could not open the file.);
fwrite($myfile,$thephoto)or die (Could not write to the file);
fclose($myfile);
?
?
$new_w=256;
$new_h=192;
header(Content-type: image/jpeg);
header(Content-type: text/html);
$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromJpeg(data.jpg);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));
ImageJpeg($dst_img);
?

?
print (It is ); // This line is not outputting to the browser.
print (date(l F j, Y)); // ...and neither is this one.

?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] image question

2003-03-10 Thread Anthony Ritter
I'm looking for a php tutorial or script which can open and read an existing
.jpg or .png from another URL.

Next, the script then modifies that image by - say - cropping off the bottom
by 20px or resizing it by 50%.

Lastly, could this modified file then be renamed on ones server?

Many thanks,
Tony Ritter






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] newbie: contents will not output

2003-03-10 Thread Anthony Ritter
I'm trying to test the following script to display the contents of the
following URL but it will not output.

Any advice will be greatly appreciated.
Thank you.
Tony Ritter
...

html
head
/head
body
?
   $file_handler = fopen(http://www.weather.com;, r);
$contents = fread($file_handler, filesize($file));
fclose($file_handler);
echo $contents;
 ?
/body
/html






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] transferring another .jpg to your own

2003-03-04 Thread Anthony Ritter
Using PHP 4.1.1. / Apache / Win 98

I'd like to use a .jpg from another URL - say:

http://www.blah.com/foo.jpg

and turn it into a variable using PHP and then once it is a variable to try
to manipulate that image using GD Libraries which are installed.

Is this possible?

I tried placing the string of the URL into a variable like:

$theoldimage=http://www.blah.com/foo.jpg;;

and then calling this function of:

$thenewimage=imagecreatefromjpeg ($theoldimage);

but it did not return a value when I echo'ed

$thenewimage

Many thanks for any advice.
Tony Ritter
..

function LoadJpeg ($imgname) {
$im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im  = imagecreate (150, 150); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc  = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, Error loading $imgname, $tc);
}
return $im;
}




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Thank you! [GD Libraries]

2003-03-03 Thread Anthony Ritter
Thank you to all that came to my aid while I was muddleing through my
attempts to install GD Libraries.

Since I had various versions of PHP from textbook CD's - I downloaded PHP
Triad which happened to be PHP version 4.1.1

I changed two lines in the php.ini file and ran the phpinfo() function call
and GD showed up without the page hanging up.

In that version, there is no php_gd2.dll - just php_gd.dll.

Again...my sincerest thanks to all.
Tony Ritter







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php.ini

2003-03-01 Thread Anthony Ritter
Rich,
I've checked my php.ini files on my drive and all I've got is one.

The php_gd2.dll file is in:

C:/PHP/extensions

There was no default folder called extensions when I installed PHP so I made
a directory called extensions under PHP.

Everytime I take out the semicolon in the .ini file, the page won't load and
I've got to shut down Apache server manually.

If I put the semicolon back in, the page loads fine.

I don't have a clue.  Somewhere between the .ini file and Apache something
is very screwed up.

TR


---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php.ini

2003-03-01 Thread Anthony Ritter
P.S.
If you get a moment, maybe you could send me a .txt file of your php.ini
file along with you php_gd2.dll setup.

That way I could check line for line.

Many thanks,
TR

---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php.ini

2003-03-01 Thread Anthony Ritter
Rich,
I've got five screenshots at this URL:

www.gonefishingguideservice.com/php1.htm

If you get a chance please take a look.

I got php_gd2.dll from the zipfile (see photo) and the extensions
sub-directory was not there when I installed.

Many thanks,
TR
.


Rich Gray:
 You said in your earlier post that in your php.ini your extension_dir is
set
 to C:\PHP\ - this is wrong it should be c:/php/extensions
 If the extensions directory was not there and you had to create it
manually
 then where did you get the php_gd2.dll from?
 The extensions sub-directory should be there for a normal installation -
did
 you install from zip?

 Rich


---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php.ini

2003-02-28 Thread Anthony Ritter
I run the following script:

?
phpinfo();
?

// the page loads o.k. when the semi-colon remains as in:
;extension=php_gd2.dll

but if I remove the semicolon as in:

extension=php_gd2.dll

the page won't load and the server hangs up.
..

\\ this is my php.ini file on MS Win 98/ PHP/ Apache


; Directory in which the loadable extensions (modules) reside.
extension_dir = C:\PHP\

; Whether or not to enable the dl() function.  The dl() function does NOT
work
; properly in multithreaded servers, such as IIS or Zeus, and is
automatically
; disabled on them.
enable_dl = On

extension=php_gd2.dll
...

Any advice on how I can install GD libraries greatly appreciated.
Thank you.
Tony Ritter






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] =at wit's end with GD Libraries=

2003-02-27 Thread Anthony Ritter
I want to thank those who tried to help with my questions about using the GD
libraries.

I still have not gotten them to function using PHP.

I've put two screenhots of the phpinfo() page at:

www.gonefishingguideservice.com/php_page.htm

If you care to take a look at those images, you'll see that I've got php and
Apache working with MS Win 98.  It also says that directories are enabled.

I've searced for the following files that I believe I need for GD Libraries
and PHP in Explorer and found:

php_gd.dll  - C:\PHP\extensions

php.ini - C:\WINDOWS

php4ts.dll - C:\WINDOWS\System

msvcrt.dll - C:\WINDOWS\System

When I load the phpinfo() page, it comes up like you see in the screenshots.

However, when I _take out_ the semi-colon as in the line:
...
extension=php_gd.dll  //semi-colon taken out
..

the page - or any page with a file extension.php will _not_load at all using
Apache.

However, when I _reinsert_ the semi-colon in the php.ini file, the .php page
then loads.

Any advice on how I can get the GD libaries to work will be greatly
appreciated.

At wit's end...

Thank you.
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] resizing .jpg file in php

2003-02-26 Thread Anthony Ritter
I'd like to use (with permission) .jpg files from a webcam from another URL.

Once that URL is opened and read via PHP as a file into my site is it
possible to resize that image?   It measures 640 x 480 pixels and I would
like to reduce the image size by 25%.

Thank you.
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] newbie: installing gd in php4

2003-02-26 Thread Anthony Ritter
Using MS Win 98 / PHP 4 and Apache.

I tried running the following script but got an undefined call to:

ImageCreate()

The following copy is located in my php.ini file...one of which is:

..
;extension=php_gd.dll
..

I tried uncommenting this line to no avail.

What is the best way to install php_gd.dll so that I can make use of the
image library.
Many thanks.

Tony Ritter



;;
; Dynamic Extensions ;
;;
; if you wish to have an extension loaded automaticly, use the
; following syntax:  extension=modulename.extension
; for example, on windows,
; extension=msql.dll
; or under UNIX,
; extension=msql.so
; Note that it should be the name of the module only, no directory
information
; needs to go here.  Specify the location of the extension with the
extension_dir directive above.


;Windows Extensions
;extension=php_mysql.dll
;extension=php_nsmail.dll
;extension=php_calendar.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
;extension=php_gd.dll
;extension=php_dbm.dll
;extension=php_mssql.dll
;extension=php_zlib.dll
;extension=php_filepro.dll
;extension=php_imap4r2.dll
;extension=php_ldap.dll
;extension=php_crypt.dll
;extension=php_msql2.dll
;extension=php_odbc.dll

--





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: resizing .jpg file in php

2003-02-26 Thread Anthony Ritter



--


Steve Magruder  wrote in message :
 To reduce its display size in an img tag, specify 640 * .75 for the width
 (assuming 640 is for width) and 480 * .75 for the height.  If you actually
 want to reduce the size of the image, then look at PHP's image-related
 functions (and the GD library).

 Steve
..

Thanks Steve.

Using MS Win 98 / PHP 4 and Apache.

I tried running the following script but got an undefined call to:

ImageCreate()

The following copy is located in my php.ini file...one of which is:

..
;extension=php_gd.dll
..

I tried uncommenting this line to no avail.

What is the best way to install php_gd.dll so that I can make use of the
image library.
Many thanks.

Tony Ritter



;;
; Dynamic Extensions ;
;;
; if you wish to have an extension loaded automaticly, use the
; following syntax:  extension=modulename.extension
; for example, on windows,
; extension=msql.dll
; or under UNIX,
; extension=msql.so
; Note that it should be the name of the module only, no directory
information
; needs to go here.  Specify the location of the extension with the
extension_dir directive above.


;Windows Extensions
;extension=php_mysql.dll
;extension=php_nsmail.dll
;extension=php_calendar.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
;extension=php_gd.dll
;extension=php_dbm.dll
;extension=php_mssql.dll
;extension=php_zlib.dll
;extension=php_filepro.dll
;extension=php_imap4r2.dll
;extension=php_ldap.dll
;extension=php_crypt.dll
;extension=php_msql2.dll
;extension=php_odbc.dll






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] newbie: installing gd in php4

2003-02-26 Thread Anthony Ritter
In my php.ini file, this is what it looks like:

...
extension_dir = C:\php4\extensions\; directory in which the loadable
extensions (modules) reside

extension=php_gd.dll


Many thanks,
TR





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] imagecreate()

2003-02-26 Thread Anthony Ritter
On MS Win 98 / Apache / PHP 4

If somebody out there using Win can check my php.ini file and advise me what
I'm doing wrong.

I have uncommented:
..
extension=php_gd.dll
..
and have included:
..
extension_dir = C:\php4\extensions

I run the php script:

?
header(Content-type:image/png);
$image=imagecreate(200,200);
imagepng($image);
?


I receive:

X-Powered-By: PHP/4.0.0 Content-type:image/png
Fatal error: Call to undefined function: imagecreate() in c:\program
files\apache group\apache\htdocs\image.php on line 3

Thank you.
TR
...

// this is in my php.ini file:

;
; Paths and Directories ;
;
include_path =   ; UNIX: /path1:/path2  Windows:
\path1;\path2
doc_root  = ; the root of the php pages, used only if nonempty
user_dir  = ; the directory under which php opens the script using
/~username, used only if nonempty
;upload_tmp_dir = ; temporary directory for HTTP uploaded
files (will use system default if not specified)
upload_max_filesize = 2097152   ; 2 Meg default limit on file uploads
extension_dir = C:\php4\extensions; directory in which the loadable
extensions (modules) reside


;;
; Dynamic Extensions ;
;;
; if you wish to have an extension loaded automaticly, use the
; following syntax:  extension=modulename.extension
; for example, on windows,
; extension=msql.dll
; or under UNIX,
; extension=msql.so
; Note that it should be the name of the module only, no directory
information
; needs to go here.  Specify the location of the extension with the
extension_dir directive above.


;Windows Extensions
;extension=php_mysql.dll
;extension=php_nsmail.dll
;extension=php_calendar.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
extension=php_gd.dll
;extension=php_dbm.dll
;extension=php_mssql.dll
;extension=php_zlib.dll
;extension=php_filepro.dll
;extension=php_imap4r2.dll
;extension=php_ldap.dll
;extension=php_crypt.dll
;extension=php_msql2.dll
;extension=php_odbc.dll


//this is the php script:

?
header(Content-type:image/png);
$image=imagecreate(200,200);
imagepng($image);
?
...

//this is what I get:

X-Powered-By: PHP/4.0.0 Content-type:image/png
Fatal error: Call to undefined function: imagecreate() in c:\program
files\apache group\apache\htdocs\image.php on line 3




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] imagecreate()

2003-02-26 Thread Anthony Ritter
Yes Adam.
Any ideas?

TR



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] imagecreate()

2003-02-26 Thread Anthony Ritter
Fine Chris.

Maybe you'd be kind enough to explain how I can get that function to work.

I've uncommented the line in the php.ini file.

In Mastering PHP (Sybex) on page 559 - Chapter 18, the authors of the
textbook - Allen and Hornberger - say when using Win to:
...
uncomment it; that's it.  Restart your webserver. That's all it takes.
...

Please advise on the steps if you get a chance.

Tony Ritter







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] imagecreate()

2003-02-26 Thread Anthony Ritter
Chris,
The function I'm trying to get...it's:

imagecreate()

I am using MS Win 98 / PHP 4 and Apache.

I tried running the following script but got an undefined call to
imagecreate()


The following copy is located in my php.ini file...one of which is:

..
;extension=php_gd.dll
..

I tried uncommenting this line to no avail.

What is the best way to install php_gd.dll so that I can make use of the
image library.

Many...many thanks.

Tony Ritter

---
[This E-mail scanned for viruses by gonefishingguideservice.com]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] syntax question

2003-02-19 Thread Anthony Ritter
Greetings...
The following is the _third_ part of a script found in Julie Meloni's book
PHP Essentials on page 118.

The script dynmically generates a form box of field names, field types and
field sizes for a mysql table depending on what the user chooses.

My question is about syntax or logic in the following snippet:

The variables:
$field_name
$field_type
$field_length

are carried over from the previous script.

.

$sql = CREATE TABLE $table_name (;

   for ($i = 0; $i  count($field_name); $i++) {

  $sql .= $field_name[$i] $field_type[$i];

  if ($field_length[$i] != ) {
   $sql .=  ($field_length[$i]),;
  } else {
   $sql .= ,;
  }
 }

 $sql = substr($sql, 0, -1);

 $sql .= );

...

My question is about the snippet:

.
  if ($field_length[$i] != ) {
   $sql .=  ($field_length[$i]),;
  } else {
   $sql .= ,;
  }
..

In that it would say that if the field_length variable is not empty then add
the (number) and comma to the sql statement

If it is empty, then just add a comma.

The question:

Is the reasoning that a comma *must* be added since this is _within_ a loop?

As in:
CREATE TABLE chairs (
id INT(5),
item VARCHAR(50),
desc TEXT ,
price FLOAT , // common should be deleted but there is no way of knowing
this within the loop.
  // that's why after the loop closes there is a
substr() function to delete the comma.
);


And that after the loop ends, the comma is then deleted using the substr()
function to complete the sql statement.

TIA,
Tony Ritter
..

The complete script:


!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2//EN
HTML
HEAD
TITLECreate a Database Table: Step 3/TITLE
style
p {font-family:arial;
font-size: .75em;}

input {border: 1px solid black;}

th {font-family:arial;
font-size: .75em;
color:red;}

h2 {font-family:arial;
font-size: 1em;}
/style


/HEAD
BODY

h2Adding ?php echo $table_name; ? Table/h2

?

 $sql = CREATE TABLE $table_name (;

   for ($i = 0; $i  count($field_name); $i++) {

  $sql .= $field_name[$i] $field_type[$i];

  if ($field_length[$i] != ) {
   $sql .=  ($field_length[$i]),;
  } else {
   $sql .= ,;
  }
 }

 $sql = substr($sql, 0, -1);

 $sql .= );

 $connection = mysql_connect(,,)
  or die(Couldn't connect to server.);

 $db = mysql_select_db(database, $connection)
  or die(Couldn't select database.);

 $sql_result = mysql_query($sql,$connection)
  or die(Couldn't execute query.);

 if (!$sql_result) {
  echo PCouldn't create table!;
 } else {
  echo P$table_name [table] has been created!;
 }



?


/BODY
/HTML





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] syntax question

2003-02-19 Thread Anthony Ritter
This is what I was getting at.

The following is correct mysql syntax in which a comma must be added after
each field - except for the last field - in this case price:

i.e.,
.

CREATE TABLE chairs(
id int(5),
item varchar(50),
desc text,
price float
);
.

However, within the loop in her script it says to add the comma after _each_
field since there is no way of knowing when the loop will end.

Thus, why is she directing the script - after the loop has ended - to lop
off the last comma by using the

substr() function call as in:

if ($field_length[$i] != )
 {
 $sql .= ($field_length[$i]) , ;
}
else
{
 $sql .= , ;
}

loop is finished.

and then...

$sql=substr($sql,0,-1); //which basically says to take the existing sql
statement string from the beginning  to the next to last character and
return it to the variable $sql thus taking off the comma.

Am I on the right track?

Thank you.
Tony Ritter
...


Ernest E Vogelsinger [EMAIL PROTECTED]

 No. The reason for the comma is that SQL dictates that column names in a
 create table statement are separated by a comma.

 This is valid SQL:
 create table chairs(
 id int(5),
 item varchar(50),
 desc text,
 price float
 );

 This is invalid and generates an SQL error when passed to the server:
 create table chairs(
 id int(5)
 item varchar(50)
 desc text
 price float
 );




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] syntax question

2003-02-19 Thread Anthony Ritter
Many thanks Jason.
TR





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] geek fishing stuff

2003-02-14 Thread Anthony Ritter
My guiding season begins in April.

Anybody out there know where I can purchase a nice mysql dolphin t-shirt?

Thank you.
TR



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] geek fishing stuff

2003-02-14 Thread Anthony Ritter
Jason Wong wrote in message:

 Try the mysql website or the mysql list?
.

Yep. I went to the mysql site and they didn't have any promo material like
t-shirts, visors, etc.

My news server doesn't have any mysql newsgroups.   SQL - yes - but not
mysql.

There was a shop online that had geek stuff...I forget the name.

And that dolphin _is_ a nice looking logo.

If you know it - please post.
Thanks.
TR





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] undefined function - crypt()

2003-02-12 Thread Anthony Ritter
Using MS Win98 / PHP /Apache

I'm getting a undefined function error - crypt()

The following scripts were taken from Larry Ullman's book on PHP on page
60-61.

Any advice would be helpful.
Thank you.

Tony Ritter
..

//ullmanform.html

!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
HTMLHEADTITLEHTML Form/TITLE
META http-equiv=Content-Type content=text/html; charset=windows-1252
META content=MSHTML 5.50.4807.2300 name=GENERATOR/HEAD
BODY
FORM action=ullmanpassword2.php method=postFirst Name INPUT
name=FirstNameBRLast Name INPUT size=40 name=LastNameBR
E-mail Address INPUT size=60 name=EmailBR
Comments TEXTAREA name=Comments rows=5 cols=40
/TEXTAREABR
INPUT type=submit value=Submit! name=SUBMIT
/FORM/BODY/HTML


// ullmanpassword2.php
HTML
HEAD
TITLE
Form Results/Using Strings/TITLE
/HEAD
BODY
?php /* This page receives and handles
the data generated by ullmanform.html. */

$FirstName = trim($FirstName);
$LastName = trim($LastName);
$Email = trim($Email);
$Comments = trim($Comments);
$Name = $FirstName .   . $LastName;
print (Your name is $Name.BR\n);
print (Your E-mail address is $Email.BR\n);
print (This is what you had to say:BR\n $CommentsBR\n);
$CryptName = crypt($Name);
print (PThis is the crypt() version of your name: $CryptName\n);
?
/BODY
/HTML
..


Fatal error: Call to undefined function: crypt()
in c:\program files\apache group\apache\htdocs\ullmanpassword2.php





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: undefined function - crypt()

2003-02-12 Thread Anthony Ritter

Greg wrote in message:
 I believe you need to have mcrypt installed.
 -Greg

.

Not sure what mcrypt is.

Please advise.

In Ullman's textbook, it says that decrypt() and encrypt(0 fuctions will not
work if PHP is not installed as a module.

However, in his example in the book, it was with crypt().

It does seem to work by calling the md5() function.

TR




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] php/mysql connection

2003-02-03 Thread Anthony Ritter

John W. Holmes wrote in message :
 Because a default install of MySQL includes an anonymous user, one with
 no username or password. There is also a root user with no password.
 Read the MySQL manual on Installation and the GRANT command on how to
 fix this.

 ---John W. Holmes...
...

John,
I was under the impression that the mysql database had as default user when
installed:
..
anonymous
root


And that the _anonymous_ user could only create a database that began with
the word - test.

Using the following commands:

...
C:\WINDOWS\cd c:\mysql\bin
C:\mysql-shareware --standalone
C:\mysql\binmysqladmin CREATE houses

Database houses created

C:\mysql\binmysql
Welcome to the mysql monitor...

mysqlUSE houses
Database changed


And the database houses was created _without_ the word test.
Why is this?

Thanking you,
Tony Ritter




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mysql/php query - wrox

2003-02-03 Thread Anthony Ritter
Chris Shiflett wrote in message:
 Your query returns two rows because you have two rows in
 the database that match the condition:

 host='localhost'

 --
 Chris
..

Chris,
I was under the impression that the mysql database had as default user when
installed:
..
anonymous
root


And that the _anonymous_ user could only create a database that began with
the word - test.

Using the following commands:

...
C:\WINDOWS\cd c:\mysql\bin
C:\mysql-shareware --standalone
C:\mysql\binmysqladmin CREATE houses

Database houses created

C:\mysql\binmysql
Welcome to the mysql monitor...

mysqlUSE houses
Database changed


As it is, I'm reading Meloni's tutorial on mysql/PHP so the question might
also apply to others in this PHP ng.

Anyway, the database houses was created _without_ the word test as the
anonymous user.
Why is this?

Thanking you,
Tony Ritter





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] php/mysql connection

2003-02-02 Thread Anthony Ritter
Newbie question and OT.  Sorry.

I am able to conncet to a mysql server with the following call to
mysql_connect().
$connect=@mysql_connect(,,);

There are no parameters in the function call.

Why can I connect if there are no parameters?

However, if I give mysqladmin the password of:
goodpassword

and call:

$connect=@mysql_connect(localhost,root,goodpassword);

I connect.

But if I call:
$connect=@mysql_connect(localhost,root,badpassword);

I cannot connect.

Or from the command line...

From the command line:
C:\Windows\cd c:\mysql\bin  \\enter

C:\mysql\bin mysqld-shareware --standalone  \\enter

C:\mysql\bin mysql \\enter  note: no password have been entered.

\\ I get the: Welcome to the MySql monitor...
...
Or...

C:\Windows\cd c:\mysql\bin  \\enter

C:\mysql\bin mysqld-shareware --standalone  \\enter

C:\mysql\bin mysql -u root - p \\ enter

Enter password  goodpassword \\ I get the: Welcome to the MySql monitor...



C:\Windows\cd c:\mysql\bin  \\enter

C:\mysql\bin mysqld-shareware --standalone  \\enter

C:\mysql\bin mysql -u root - p \\ enter
Enter password  badpassword \\ I do _not_  get the: Welcome to the MySql
monitor...


Why is this when I thought it needs a password to connect to the MySql
monitor?
Thanks,
TR






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




  1   2   >