Re: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website

2006-01-04 Thread Jochem Maas

Jim Moseby wrote:

...





Perhaps I misunderstand what the OP wanted.  I thought he was running a
webserver somewhere, and that he wanted his remote webserver to be able to
grab a file listing on his local machine by just visiting a webpage there.


if you ask me it wasn't very clear what the OP wanted, I was concerned that
the reference to php being a 'server-side' tool/language would be confusing
to the OP (or give him the wrong impression about php's capabilities).

to the OP: php being serverside is only relevant in terms of using php
as a webserver module; the 'client side' is the browser and php does not
run inside the browser (i.e. a php website can not directly interact with
anything on your own PC (unless the website lives physically on your own pc))

[actually Wez Furlong wrong a plugin for IE IIRC that allows you to use php
in the same way as you might use javascript inside the browser]



Of course PHP can query the local filesystem.  I thought he wanted it to
query a remote filesystem.

JM


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



[PHP] Newbie question: need to transfer directory contents from my local machine to my website

2006-01-03 Thread Jon Westcot
Hi all:

I'm really new at PHP and will probably embarrass myself many times over 
asking questions that have been asked gazillions of times before, so let this 
serve as a blanket apology.

Now, to my question.  Here's what I'm trying to do.  I have a simple 
database on my website that I wish to populate with information from various 
directories on my local computer.  The website is running Linux; my computer is 
running Windows XP.  Once the data are stored, I want to be able to update the 
information as things change on my local computer (not in real time, mind you, 
but at my request).

I can set up the database access easily enough, and I know how to both 
populate and query it.  What I don't know is how to obtain the information from 
my local computer via the website.  Initially, I'd like to be able to specify 
the folder on my local computer to access and whether or not to process any 
subfolders that are found.  After the data have been added, I'd like the web 
application to be able to access the individual folders without having to 
specify them again (although I'd still be able to identify new folders to 
include in subsequent updates).

I'm not really asking for anyone to write the code for me, but I am looking 
for suggestions for PHP functions to use to accomplish the inspection of my 
local computer's folders.  I'd also need to know what additional information 
I'd need to store in the database so that subsequent updates can be automated 
(i.e., do I need to somehow store my IP address?).

Any help you can send my way will be greatly appreciated!  Thanks in 
advance.

Sincerely,

Jon


Re: [PHP] php newbie question with xml files

2005-05-04 Thread Mark Cain
This should get you started:


$old_data = file_get_contents('./test.txt');
$my_data = foo bar;
$pattern = '/(.*)(\/.*)$/i';
$replacement = '$1' . $my_data . '$2';
$new_data = preg_replace($pattern, $replacement, $old_data);
echo $new_data;

or a little more succinctly

$my_data = foo bar;
$new_data = preg_replace('/(.*)(\/.*)$/i', '$1' . $my_data . '$2',
file_get_contents('./test.txt'));
echo $new_data;


Mark Cain


- Original Message -
From: Jared Sherman [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, May 03, 2005 2:00 AM
Subject: [PHP] php newbie question with xml files


 I have an xml document storing some data I need. What I want to do is
this:
 1. Scan to the end of the file.
 2. Find the closing tag.
 3. Insert a new entry in before the closing tag.

 I've tried:
 1. Creating new files and renaming them to be the original.
 2. Writing the file to a dummy file and insert my lines part way through
 then finish the last tag.

 My problem is I'm looking for a /endtag and it comes up as endtag. Is
 there anyway to force PHP to read the .xml file as a text file so it wont
 strip off the xml tag information?

 I've used fopen with fgets and fwrite, and file with fwrite

 Jared Sherman
 Totally lost newbie

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



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



Re: [PHP] php newbie question with xml files

2005-05-04 Thread Mark Cain
This should get you started:


$old_data = file_get_contents('./test.txt');
$my_data = foo bar;
$pattern = '/(.*)(\/.*)$/i';
$replacement = '$1' . $my_data . '$2';
$new_data = preg_replace($pattern, $replacement, $old_data);
echo $new_data;

or a little more succinctly

$my_data = foo bar;
$new_data = preg_replace('/(.*)(\/.*)$/i', '$1' . $my_data . '$2',
file_get_contents('./test.txt'));
echo $new_data;


Mark Cain


- Original Message -
From: Jared Sherman [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, May 03, 2005 2:00 AM
Subject: [PHP] php newbie question with xml files


 I have an xml document storing some data I need. What I want to do is
this:
 1. Scan to the end of the file.
 2. Find the closing tag.
 3. Insert a new entry in before the closing tag.

 I've tried:
 1. Creating new files and renaming them to be the original.
 2. Writing the file to a dummy file and insert my lines part way through
 then finish the last tag.

 My problem is I'm looking for a /endtag and it comes up as endtag. Is
 there anyway to force PHP to read the .xml file as a text file so it wont
 strip off the xml tag information?

 I've used fopen with fgets and fwrite, and file with fwrite

 Jared Sherman
 Totally lost newbie

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



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



Re: [PHP] php newbie question with xml files

2005-05-04 Thread disguised.jedi
 I have an xml document storing some data I need. What I want to do is this:
 1. Scan to the end of the file.
 2. Find the closing tag.
 3. Insert a new entry in before the closing tag.

There are specific classes and functions in the PHP core that can help
you do just this.

 I've tried:
 1. Creating new files and renaming them to be the original.
 2. Writing the file to a dummy file and insert my lines part way through
 then finish the last tag.

I don't think this is the right approach to take.  Maybe using the DOM
and/or the XML Parser built-in to php would help you.

 My problem is I'm looking for a /endtag and it comes up as endtag. Is
 there anyway to force PHP to read the .xml file as a text file so it wont
 strip off the xml tag information?
 
 I've used fopen with fgets and fwrite, and file with fwrite

Again, this isn't the approach to take.  There are built-in functions
for this sort of thing, as well as classes on PEAR that will help you.
 Try google!

Read through all of this and decide which approach you want to take
before you start anything...

If you use Windows or compile PHP as an Apache module in Linux, you're
all set with the XML Parser.  If not, you'll need to get the library
according to the directions in the manual.

http://www.php.net/xml

Read everything in that thoroughly, and understand it before you
continue with this approach.  Copy and play with the examples to see
how it all works.  If you'd rather handle things in an environment
designed to create and manipulate XML dynamically, rather than just
read and insert raw strings, keep reading.

You can get the DOM XML working easily in Windows, and even easier in
a GNOME environment on a linux box.  The manual has excellent
instructions.

http://www.php.net/domxml

This extension is Object-Oriented (OO), and if you don't know what
that is, you better read up on it before you try this out.  If you do,
and have an OK understanding of how OO works in PHP, then read on!  If
not, read the article

http://www.php.net/oop

Now, understand that DOM XML is very particular about the syntax and
such in an XML file.  The file MUST start with the XML declaration
(without quotes) ?xml version=1.0 in order for DOM to try and use
it.

Use the functions to read right through it all.  You'll find that this
is probably exactly what you need!

I'd use DOM XML personally.  I included the other in case you didn't
want to have to install everything.

Have fun, and good luck with PHP!

-- 
[EMAIL PROTECTED]

PHP rocks!
Knowledge is Power.  Power Corrupts.  Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

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



Re: [PHP] php newbie question with xml files

2005-05-04 Thread Jason Barnett
PHP5:
http://php.net/manual/en/ref.dom.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: php newbie question with xml files

2005-05-04 Thread Jared Sherman
Thanks these pointers have helped alot.



Jared Sherman [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I have an xml document storing some data I need. What I want to do is this:
 1. Scan to the end of the file.
 2. Find the closing tag.
 3. Insert a new entry in before the closing tag.

 I've tried:
 1. Creating new files and renaming them to be the original.
 2. Writing the file to a dummy file and insert my lines part way through 
 then finish the last tag.

 My problem is I'm looking for a /endtag and it comes up as endtag. Is 
 there anyway to force PHP to read the .xml file as a text file so it wont 
 strip off the xml tag information?

 I've used fopen with fgets and fwrite, and file with fwrite

 Jared Sherman
 Totally lost newbie 

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



[PHP] php newbie question with xml files

2005-05-03 Thread Jared Sherman
I have an xml document storing some data I need. What I want to do is this:
1. Scan to the end of the file.
2. Find the closing tag.
3. Insert a new entry in before the closing tag.

I've tried:
1. Creating new files and renaming them to be the original.
2. Writing the file to a dummy file and insert my lines part way through 
then finish the last tag.

My problem is I'm looking for a /endtag and it comes up as endtag. Is 
there anyway to force PHP to read the .xml file as a text file so it wont 
strip off the xml tag information?

I've used fopen with fgets and fwrite, and file with fwrite

Jared Sherman
Totally lost newbie 

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



[PHP] Newbie Question - an If in an Array?

2005-03-28 Thread Jackson Linux
I'm so confused. I have an array :
$display[]  = 
div class='job-date'{$cv['dates']}/div
div class='job-title'{$cv['job_title']}/div
div class='company'{$cv['company']}/div
div class='job'{$cv['job']}/div;
In SOME of the rows of this table, there is a field called sidebar. I'd  
like to have this array include a reference to this field if it exists.

I was thinking something like:
if (!empty($cv['sidebar'])){
	$sidebar_ref = 
  div class='sidebar_ref_box'a  
href='../sidebars/index.htm?s={$cv['sidebar']}' title='Sidebar'Learn  
More/a/div
	};

Can anyone offer some help?
Thanks. The whole script is below:


?php
/* invalid or missing GET? */
if (!isset($_GET['r']) || empty($_GET['r']) || !($r =   
intval($_GET['r']))) {
// show a plain vanilla index
include('/path/to/docs/cv.include.php');
exit;
}


/* With a valid $r, make some variables to help build the SQL query
 * Note three conditions join the tables yes we are aware of that */
$fields=   
'cv.cv_id,cv.category,dates,cv.job_title,cv.company,cv.job,cv.sort,cv.si 
debar,jobcat.category';
$where = WHERE cvjobcats.cv_id=cv.cv_id
	  AND cvjobcats.jobcat_id = '$r'
  AND jobcat.jobcat_id=cvjobcats.jobcat_id;
$restables = cv, cvjobcats, jobcat;
$sort  = ORDER BY cv.sort;

/* Finally the actual SQL query, using the variables just set
 * do we have a valid mysql result resource?
 */
if (!($result = mysql_query(SELECT $fields FROM $restables $where  
$sort))) {
  echo Could not successfully run query ($sql) from DB:  .   
mysql_error();
  exit;
}

/* do we have any records? if not show the list/menu */
if (mysql_num_rows($result) == 0) {
  include_once('/path/to/docs/cv.include.php');
  exit;
}
$display = array();  // this is merely an array initialization
unset($cat);
while ($cv = mysql_fetch_assoc($result)) {
/* set the category name for display in the output */
if (!isset($cat)) {
$cat = $cv['category'];
}
/*$sidebar_ref = array();
while ($cv = mysql_fetch_assoc($result)) {
  if (!empty($cv['sidebar'])){
	$sidebar_ref [] = 
  div class='sidebar_ref_box'a  
href='../sidebars/index.htm?s={$cv['sidebar']}' title='Sidebar'Learn  
More/a/div
	};
}*/

/* make an array of jobs which includes the HTML to be displayed
 * in the HTML page when we make one...
 */
$display[]  = 
div class='job-date'{$cv['dates']}/div
div class='job-title'{$cv['job_title']}/div
div class='company'{$cv['company']}/div
div class='job'{$cv['job']}/div;
}
/* be nice - tell mysql to free the resultset */
mysql_free_result($result);
/*
 * And now, wrap up the PHP and make the page...
 */
echo ?xml version='1.0' ?\n;
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN  
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
		titleResume /title
		link rel='stylesheet' href='http://domain.com/docs/style.css'   
type='text/css' /
	/head
body

!-- CALL EVERYTHING BELOW A PAGE --
div id='page-display'
!--START HEADER --?php include_once  
/path/to/docs/header.include.php ?!-- END HEADER  --

!-- BEGIN LEFT SIDE --
div id='left-sidebar'
?php include_once /path/to/docs/left-sidebar.cv.include.php; ?
/div
!-- END LEFT SIDE --
!--START MAIN CONTENT AREA--
div id='content'

h1Reacute;sumeacute;/h1
?php include_once /path/to/docs/cv.$r.include.php; ?
div class='job-category'?php echo $cat?/div

?php
if (sizeof($display)) {
echo 
div id='table-of-contents'
;
echo join(\n\t\t, $display);
echo 
/div
;
}

?
/div
!--END MAIN CONTENT AREA--
!--BEGIN FOOTER--
div id='footer'?php include_once /path/to/docs/footer.include.php  
?/div
!--END FOOTER--

/div
!--END PAGE--
/body
/html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Jackson Linux
Hi, everyone, I apologise if this posts twice; I'm having issues with 
my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some 
articles. This works great:

$content = strip_tags($article['content']);
$striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250 
characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?
Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Jay Blanchard
[snip]
Hi, everyone, I apologise if this posts twice; I'm having issues with 
my outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some 
articles. This works great:

 $content = strip_tags($article['content']);
 $striptease = substr($content, 0, 275);

but cuts off words right in the midd ...
[/snip]

http://www.php.net/explode you can use to get individual words.

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



[PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Jackson Linux
Hi, everyone,
I'm 'teasers' of the first, say 200 to 250 characters of some articles. 
This works great:

$content = strip_tags($article['content']);
$striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250 
characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?
Thanks in advance,
Jack
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread John Nichel
Jackson Linux wrote:
Hi, everyone, I apologise if this posts twice; I'm having issues with my 
outgoing email server.

I'm making 'teasers' of the first, say 200 to 250 characters of some 
articles. This works great:

$content = strip_tags($article['content']);
$striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250 
characters, then count backwards to the last space and chop it there.

Does anyone have an ideas/scripts for this?
Thanks in advance,
Jack
You can do something like this...
function subEndWord ( $string, $start, $max ) {
$string = substr ( $string, $start, $max );
$string = preg_replace ( /\s\w+$/, , $string );
return $string;
}
Untested, but should work.  Tinker with the RegEx to perfect it.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: breaking a substr() string on a space

2005-03-11 Thread Richard Lynch

 Hi, everyone,

 I'm 'teasers' of the first, say 200 to 250 characters of some articles.
 This works great:

  $content = strip_tags($article['content']);
  $striptease = substr($content, 0, 275);

 but cuts off words right in the midd ...

 I'd like to find a way to take $content, look at the first 250
 characters, then count backwards to the last space and chop it there.

 Does anyone have an ideas/scripts for this?

$pos = strpos($content, ' ');
$pos = $pos ? $pos : strlen($content);
$teaser = substr($content, 0, $pos);

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Newbie Question: breaking a substr() string on a space SOLVED

2005-03-11 Thread Jackson Linux
Hi, everyone,
Thanks for the great suggestions! I've looked at all and found that the 
one here:

http://www.php.net/explode
that Jay recommended was the easiest for me to wrap my brain around. I 
wll tinker with the other ones as well - it's all really interesting.

The function was:
function wordlimit($string, $length = 50, $ellipsis = ...)
{
   $paragraph = explode( , $string);
   if($length  count($paragraph))
   {
   for($i = 0; $i  $length; $i++)
   {
   if($i  $length - 1)
   $output .= $paragraph[$i] .  ;
   else
   $output .= $paragraph[$i] . $ellipsis;
   }
   return $output;
   }
   return $string;
}
And boy does it work easily!!!
Thanks again all who replied.
Jack


On 11 Mar 2005, at 12:36, Richard Lynch wrote:

Hi, everyone,
I'm 'teasers' of the first, say 200 to 250 characters of some 
articles.
This works great:

 $content = strip_tags($article['content']);
 $striptease = substr($content, 0, 275);
but cuts off words right in the midd ...
I'd like to find a way to take $content, look at the first 250
characters, then count backwards to the last space and chop it there.
Does anyone have an ideas/scripts for this?
$pos = strpos($content, ' ');
$pos = $pos ? $pos : strlen($content);
$teaser = substr($content, 0, $pos);
--
Like Music?
http://l-i-e.com/artists.htm

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


RE: [PHP] Newbie Question re substr

2005-03-08 Thread Kim Madsen
From: Jackson Linux [mailto:[EMAIL PROTECTED] 
Sent: 8. marts 2005 04:23

First of all, echo the output to see if You get, what Tou expect in a debug 
situation:

if (!empty($where)) {

echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0 200); // get first 200 chars 
// print and see if we get, what we expect
Print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
print lia href='{ . $_SERVER['PHP_SELF'] . 
}?a={$article_id}'}title='{$title}'{$article['title']}/abr 
/\n$content/li;
  }
}

echo 
 /ul;

I´ve put the  in front of title since the link otherwise would be a 
href=a=1234title=sometext, which is not what You want I guess.

And I substituted the 

  $article['content'] = substr($article['content'], 0 200);/li; } }

with

  $content/li;

since I believe You want to print the content and not just assign it? Otherwise 
the br / makes no sense :-)

 Can anyone help ?

I hop that did the trick for You :-)

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler
Naverland 31

DK-2600 Glostrup
www.comx.dk 
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]

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



Fwd: [PHP] Newbie Question re substr

2005-03-08 Thread Jackson Linux
Thanks, Kim! Still having difficulties though..
On 8 Mar 2005, at 03:29, Kim Madsen wrote:

From: Jackson Linux [mailto:[EMAIL PROTECTED]
Sent: 8. marts 2005 04:23
First of all, echo the output to see if You get, what Tou expect in a 
debug situation:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0 200); // get first 200 
chars
// print and see if we get, what we expect
Print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
print lia href='{ . $_SERVER['PHP_SELF'] . 
}?a={$article_id}'}title='{$title}'{$article['title']}/abr 
/\n$content/li;
  }
}

echo 
 /ul;
I´ve put the  in front of title since the link otherwise would be 
a href=a=1234title=sometext, which is not what You want I guess.

And I substituted the
  $article['content'] = substr($article['content'], 0 200);/li; } }
with
  $content/li;
since I believe You want to print the content and not just assign it? 
Otherwise the br / makes no sense :-)

Can anyone help ?
I hop that did the trick for You :-)
It's really sensible and logical what you did. I really appreciate it.
1. $content = substr($article['content'], 0 200); // get first 200 
chars   is choking, and I've looked in docs and can't understand why. 
I get

Parse error: parse error, unexpected T_LNUMBER in 
/usr/www/users/domain/dynamic/templates/substr.htm on line 57

2.  This correction:
I´ve put the  in front of title since the link otherwise would be 
a href=a=1234title=sometext, which is not what You want I guess.
Wow. Actually I wanted it to make a href='a=1234' title='sometext' - 
does this:

print lia href='{ . $_SERVER['PHP_SELF'] . }?a={$article_id}'}' 
title='{$title}'{$article['title']}/abr /\n$content/li;

do that? (I ask because I can;t make any of it work?!)
Thanks so much for your help.


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler
Naverland 31
DK-2600 Glostrup
www.comx.dk
Telefon: +45 70 25 74 74
Telefax: +45 70 25 73 74
E-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-

-
Nick Selby
Flyguides, Inc.
347 675 8295
http://www.flyguides.com/press/selby.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question re substr

2005-03-08 Thread Jackson Linux
On 8 Mar 2005, at 11:40, Richard Lynch wrote:
1. $content = substr($article['content'], 0 200); // get first  
200
chars   is choking, and I've looked in docs and can't understand why.
I get

Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57
In this line, PHP is somehow encountering a T_NUMBER (a number) where  
it
*expects* to see something else.

Like a comma.
Look between your 0 and 200 very carefully.

Thanks for taking the time. I had suspected that earlier, but when I  
put it in all sorts of OTHER stuff happened.

Then I saw your post and tried again. I saw that I had made another  
mistake later on. So you've solved that part - thanks!.

ExceptExcept it doesn't pull the content from the db and substr it  
to 200 characters. It pulls the id number and the title no problem, and  
I am sure that $article['content'] points to the right place (or at  
least it's named right) but it's just not getting the content:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0, 400); // get first 200  
chars
// print and see if we get, what we expect
// print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
$table_of_contents[] = lia  
href='{$_SERVER['PHP_SELF']}? 
a={$article_id}'}title='{$title}'{$article['title']}/abr/ 
$contentbr /a  
href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'  
title='{$article['title']}' ... [Read article]/a/li/li;
  }
}

echo 
 /ul;
Thanks in advance. . .
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-08 Thread Richard Lynch
James Williams wrote:
 rory walsh wrote:
 Can anyone tell me if there is a difference between double quotes and
 single quotes? Cheers,
 Rory.

 What's up Rory... actually there *is* a difference.  Double quotes are
 parsed by the php engine, meaning it goes through and finds variables
 and stuff which it can parse, ex. print(Here is a variable:
 $variable!); will print Here is a variable: The value of the variable!

 Single quotes are not parsed by the php engine, so the same code with
 single quotes (print('Here is a variable: $variable!'); will return
 Here is a variable: $variable!  I hope that answeres your question

This is not quite 100% correct.

PHP still parses single quotes, but only replaces two (2) special
character combinations:

\' turns into '
\\ turns into \

The point is that you still might want to embed an apostrophe in single
quotes, and so you use \ for that, and you might want to embed \ so you
use \ for that as well.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re [PHP] Newbie Question re substr: Solved

2005-03-08 Thread Jackson Linux
Sorry if this posts twice. Thanks everyone for the help.
The missing comma was the problem with the display; the missing  
specification of the column at the start of the sql query was the  
problem with getting the data from the column.

Again, thanks all who replied for the fast and excellent help.
On 8 Mar 2005, at 11:40, Richard Lynch wrote:
1. $content = substr($article['content'], 0 200); // get first  
200
chars   is choking, and I've looked in docs and can't understand why.
I get

Parse error: parse error, unexpected T_LNUMBER in
/usr/www/users/domain/dynamic/templates/substr.htm on line 57
In this line, PHP is somehow encountering a T_NUMBER (a number) where  
it
*expects* to see something else.

Like a comma.
Look between your 0 and 200 very carefully.

Thanks for taking the time. I had suspected that earlier, but when I  
put it in all sorts of OTHER stuff happened.

Then I saw your post and tried again. I saw that I had made another  
mistake later on. So you've solved that part - thanks!.

ExceptExcept it doesn't pull the content from the db and substr it  
to 200 characters. It pulls the id number and the title no problem, and  
I am sure that $article['content'] points to the right place (or at  
least it's named right) but it's just not getting the content:

if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
  while ($article = mysql_fetch_assoc($result)) {
// humanize data
$article_id = $article['article_id'];
$title = $article['title'];
$content = substr($article['content'], 0, 400); // get first 200  
chars
// print and see if we get, what we expect
// print id=$article_idbrtitle=$titlebrcontent=$contentp;
// now make the real stuff
$table_of_contents[] = lia  
href='{$_SERVER['PHP_SELF']}? 
a={$article_id}'}title='{$title}'{$article['title']}/abr/ 
$contentbr /a  
href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'  
title='{$article['title']}' ... [Read article]/a/li/li;
  }
}

echo 
 /ul;
Thanks in advance. . .
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question re substr

2005-03-08 Thread Richard Lynch




Jackson Linux wrote:
 On 8 Mar 2005, at 11:40, Richard Lynch wrote:

 1. $content = substr($article['content'], 0 200); // get first
 200
 chars   is choking, and I've looked in docs and can't understand why.
 I get

 Parse error: parse error, unexpected T_LNUMBER in
 /usr/www/users/domain/dynamic/templates/substr.htm on line 57

 In this line, PHP is somehow encountering a T_NUMBER (a number) where
 it
 *expects* to see something else.

 Like a comma.

 Look between your 0 and 200 very carefully.



 Thanks for taking the time. I had suspected that earlier, but when I
 put it in all sorts of OTHER stuff happened.

 Then I saw your post and tried again. I saw that I had made another
 mistake later on. So you've solved that part - thanks!.

 ExceptExcept it doesn't pull the content from the db and substr it
 to 200 characters. It pulls the id number and the title no problem, and
 I am sure that $article['content'] points to the right place (or at
 least it's named right) but it's just not getting the content:

Put in a var_dump($article) where you think you have 'content' right.

See what you have.

Make sure 'content' is in your list of fields you are retrieving.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Newbie Question re substr

2005-03-07 Thread Jackson Linux
Hi,
I'm really new and getting lots of help but need some assistance.
I'm running a script which gets specific articles from a database if 
they're entered in the URL after the ? . For instance if someone asks 
for

www.foo.com/index.htm?a=1234
then the script would look for an database entry with the id of 1234 
and display it in the page.

If there's no number specified (www.foo.com/index.htm) or if the number 
given is to an article which doesn't exist, it gets the titles of all 
the articles available and prints them as links to the proper article 
number.

I'd also like it to grab the first 200 characters of text from the 
$content field of the entry.

With help I have the title link part and I suspect I'm close but I keep 
messing up the syntax

The code is:
snip
if (!empty($where)) {
echo 
 ul;
 $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
 $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}' 
title='{$article['title']}'{$article['title']}/abr /
$article['content'] = substr($article['content'], 0 200);/li;
}
}

echo 
 /ul;
/snip
Can anyone help ?
Thanks in advance!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question re substr

2005-03-07 Thread Zareef Ahmed
On Mon, 7 Mar 2005 22:23:19 -0500, Jackson Linux
[EMAIL PROTECTED] wrote:
 Hi,
 I'm really new and getting lots of help but need some assistance.
 
 I'm running a script which gets specific articles from a database if
 they're entered in the URL after the ? . For instance if someone asks
 for
 
 www.foo.com/index.htm?a=1234
 
 then the script would look for an database entry with the id of 1234
 and display it in the page.
 
 If there's no number specified (www.foo.com/index.htm) or if the number
 given is to an article which doesn't exist, it gets the titles of all
 the articles available and prints them as links to the proper article
 number.
 
 I'd also like it to grab the first 200 characters of text from the
 $content field of the entry.
 
 With help I have the title link part and I suspect I'm close but I keep
 messing up the syntax
 
 The code is:
 
 snip
 
 if (!empty($where)) {
 
 echo 
  ul;
   $article = mysql_fetch_assoc($result);
 } else {
 while ($article = mysql_fetch_assoc($result)) {
   $table_of_contents[] = 
 lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'

 title='{$article['title']}'{$article['title']}/abr /
 $article['content'] = substr($article['content'], 0 200);/li;

change these two lines to 

title='{$article['title']}'{$article['title']}/abr /.
substr($article['content'], 0, 200)./li;

zareef ahmed 


 }
 }
 
 echo 
  /ul;
 
 /snip
 
 Can anyone help ?
 
 Thanks in advance!
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net

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



Re: [PHP] Newbie Question re substr

2005-03-07 Thread Jackson Linux
Zareef,
Almost
On 7 Mar 2005, at 23:52, Zareef Ahmed wrote:
From: [EMAIL PROTECTED]
Subject:Re: [PHP] Newbie Question re substr
Date:   7 March 2005 23:52:15 GMT-05:00
To:   [EMAIL PROTECTED]
Cc:   php-general@lists.php.net
Reply-To: [EMAIL PROTECTED]
On Mon, 7 Mar 2005 22:23:19 -0500, Jackson Linux
[EMAIL PROTECTED] wrote:
Hi,
I'm really new and getting lots of help but need some assistance.
I'm running a script which gets specific articles from a database if
they're entered in the URL after the ? . For instance if someone asks
for
www.foo.com/index.htm?a=1234
then the script would look for an database entry with the id of 1234
and display it in the page.
If there's no number specified (www.foo.com/index.htm) or if the number
given is to an article which doesn't exist, it gets the titles of all
the articles available and prints them as links to the proper article
number.
I'd also like it to grab the first 200 characters of text from the
$content field of the entry.
With help I have the title link part and I suspect I'm close but I keep
messing up the syntax
The code is:
snip
if (!empty($where)) {
echo 
 ul;
  $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
  $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'

title='{$article['title']}'{$article['title']}/abr /
$article['content'] = substr($article['content'], 0 200);/li;
change these two lines to
title='{$article['title']}'{$article['title']}/abr /.
substr($article['content'], 0, 200)./li;
zareef ahmed

I did that and now it reads this:

if (!empty($where)) {
echo 
 ul;
 $article = mysql_fetch_assoc($result);
} else {
while ($article = mysql_fetch_assoc($result)) {
 $table_of_contents[] = 
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
lia href='{$_SERVER['PHP_SELF']}?a={$article['article_id']}'
title='{$article['title']}'{$article['title']}/abr /.
substr($article['content'], 0, 200)./li;
}
}
\
Which doesn't kick back errors but also does not pull any 
$article['content'] - it leaves a line break but no text is being 
inserted from the content row.
?

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


[PHP] Newbie question: qutoes?

2005-03-06 Thread rory walsh
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

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


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread James Williams
rory walsh wrote:
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.
What's up Rory... actually there *is* a difference.  Double quotes are 
parsed by the php engine, meaning it goes through and finds variables 
and stuff which it can parse, ex. print(Here is a variable: 
$variable!); will print Here is a variable: The value of the variable!

Single quotes are not parsed by the php engine, so the same code with 
single quotes (print('Here is a variable: $variable!'); will return 
Here is a variable: $variable!  I hope that answeres your question

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


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Jochem Maas
rory walsh wrote:
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

apart from the visual difference :-)... yes.
with double quotes string interpolation is done. whats that?
run this code to see the difference:
?php
$varA = 123;
echo ' this is $varA';
echo  this is $varA;
?
basically use double quotes only when you need it... needing it includes times
when using double quotes saves you having to escape _lots_ of single quotes,
i.e. when it makes code easier to read (JMHO) e.g.:
$str = '\'this\' \'is\' a \'stupidly\' \'quoted\' string';
$str = 'this' 'is' a 'stupidly' 'quoted' string;
---
so now you have at least 2 things to google:
1. string interpolation (+ PHP)
2. string/char escaping (+ PHP)
have fun :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Matt Harnaga
Double quotes expand variables, that is, if $a = 2, then
echo The value is $a2;
will print The value is 2.
Single quotes return strings literally. So, echo 'The value is $a2' 
would print The value is $a2

Cheers
rory walsh wrote:
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

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


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread rory walsh
Thanks guys, that clears up a lot! Cheers, actually I have to say 
goodbye to broadband for a while so I hope that I can make it on my own! 
That's why I have been asking all these obvious little questions! Cheers,
Rory.

Jochem Maas wrote:
rory walsh wrote:
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

apart from the visual difference :-)... yes.
with double quotes string interpolation is done. whats that?
run this code to see the difference:
?php
$varA = 123;
echo ' this is $varA';
echo  this is $varA;
?
basically use double quotes only when you need it... needing it includes 
times
when using double quotes saves you having to escape _lots_ of single 
quotes,
i.e. when it makes code easier to read (JMHO) e.g.:

$str = '\'this\' \'is\' a \'stupidly\' \'quoted\' string';
$str = 'this' 'is' a 'stupidly' 'quoted' string;
---
so now you have at least 2 things to google:
1. string interpolation (+ PHP)
2. string/char escaping (+ PHP)
have fun :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Matt Harnaga
You might want to check this out as well:
http://www.zend.com/zend/tut/using-strings.php
rory walsh wrote:
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

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


[PHP] Newbie question

2005-02-18 Thread Adams, Tom
Does anyone know how to force PHP to require all local variables to be declared 
prior to use or if this is even possible?

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



Re: [PHP] Newbie question

2005-02-18 Thread Adrian
error_reporting(E_ALL);
Then you will get a notice when you try to read a variable which
doesn't exist.

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



[PHP] newbie question regarding forms and drop down list

2005-02-03 Thread Max Krone
I am pretty new to php, so if I am asking a poor question, please forgive me.

I have a few input forms using html and php that will take input from
text boxes and then put that input into a MySql database. All of the
information for the form is put in between a form method element.

When I try to add code for a drop donw inside the form method
element, the code doesn't work, and I get a parse error. The code will
work outside the element.

I assume I am just missing something dumb. Could someone please
enlighten me. I can post my code if it will help.

Thanks,
Max Krone

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



Re: [PHP] newbie question regarding forms and drop down list

2005-02-03 Thread W Luke
On Thu, 3 Feb 2005 15:45:51 -0800, Max Krone [EMAIL PROTECTED] wrote:

 I assume I am just missing something dumb. Could someone please
 enlighten me. I can post my code if it will help.

Code please, Max!

-- 
Will   The Corridor of Uncertainty   http://www.cricket.mailliw.com/
 - Sanity is a madness put to good use -

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



[PHP] newbie question ; calling php script with parrameters from html

2005-02-02 Thread Sagaert Johan
can i use this kind of construction in my html code ?

a href=test.php?selection=highSelect high/a


if yes , how do i retrieve the passed string in the php code

Johan

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



AW: [PHP] newbie question ; calling php script with parrameters from html

2005-02-02 Thread Mirco Blitz
Hi,
There are multiple Ways of getting that string.
If your PHP-Server has globals=on in php ini you will recive that string in
$selection variable.

If not you recive it in $_GET[selection]

So I use a function to handle POST and GET Variabels.

   function getpost_ifset($test_vars)
{
$return = FALSE;
  if (!is_array($test_vars)) 
  {$test_vars = array($test_vars);}

foreach($test_vars as $test_var) {
if (isset($_POST[$test_var])) {
global $$test_var;
$$test_var = $_POST[$test_var];
$return =
TRUE;
} elseif (isset($_GET[$test_var])) {
global $$test_var;
$$test_var = $_GET[$test_var];
$return =
TRUE;
}
}
return $return;
} 

If i now want to get a ariable i either POST or GET from an URL i don't care
if POST or GET.
I just do

getpost_ifset(selection);

and then I have a variable called $selection in my code with the given
value.

You could also do something like this.

if(getpos_ifset(selection))
{
echo Selection variable is there with value: .$selection;
}
else
{
echo No Selection Variable givin in Link;
}

Hope that helps.
Mirco Blitz
-Ursprüngliche Nachricht-
Von: Sagaert Johan [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 2. Februar 2005 11:38
An: php-general@lists.php.net
Betreff: [PHP] newbie question ; calling php script with parrameters from
html

can i use this kind of construction in my html code ?

a href=test.php?selection=highSelect high/a


if yes , how do i retrieve the passed string in the php code

Johan

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

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



RE: [PHP] newbie question ; calling php script with parrameters from html

2005-02-02 Thread Chris W. Parker
Sagaert Johan mailto:[EMAIL PROTECTED]
on Wednesday, February 02, 2005 2:38 AM said:

 can i use this kind of construction in my html code ?
 
 a href=test.php?selection=highSelect high/a

Yes.

 if yes , how do i retrieve the passed string in the php code

?php

$value = $_GET['selection'];

?

Be sure to validate the data first though.



Chris.

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



[PHP] Newbie question? diagnosing a script

2004-12-22 Thread Al Guevara

Hi Yall!

I dont know if Im goin overboard askin this, but here goes... What /how does 
one use to diagnose a php script (for a link exchange) as to why it wont 
work/write to the file? With Cgi, one can use a telnet shell.. is there a 
thing to use for diagnosing php?

Thank Mucho


submit page
http://www.arizona-commercial-real-estate.com/links/submit.php

page script writes to
http://www.arizona-commercial-real-estate.com/links/index.php

zip file of entire php script folder
http://www.arizona-commercial-real-estate.com/links.zip

phpinfo
http://www.arizona-commercial-real-estate.com/test.php



Re: [PHP] Newbie question? diagnosing a script

2004-12-22 Thread Richard Lynch
Al Guevara wrote:
 I dont know if Im goin overboard askin this, but here goes... What /how
 does one use to diagnose a php script (for a link exchange) as to why it
 wont work/write to the file? With Cgi, one can use a telnet shell.. is
 there a thing to use for diagnosing php?

Perhaps http://php.net/error_log would be useful to you.

In real-time, on a Development server, just echo out whatever values you
need to debug what's happening.

You can also do something like this to analyze server output:

telnet www.arizona-commercial-real-estate.com 80
[your server prints stuff here]
GET /links/index.php HTTP/1.0
Host: www.arizona-commercial-real-estate.com


Hit an 'extra' return after the Host: line (or any other headers) and out
spews the web page with all headers.

H.   I guess the 'wget' application is way easier, hunh?  Not as fun
though :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Newbie question

2004-11-28 Thread Pascal Platteeuw
Hello everyone,

Here is a newbie question for you guys who are much more advanced than me
:-)
I want ot do an automatic redirection in a php page... Is there something
equivalent to response.redirect used in ASP?

Thanks in advance,

Pascal Platteeuw

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



RE: [PHP] Newbie question

2004-11-28 Thread Mike
Look at header()

http://us2.php.net/manual/en/function.header.php

-M 

 -Original Message-
 From: Pascal Platteeuw [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, November 28, 2004 11:34 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Newbie question
 
 Hello everyone,
 
 Here is a newbie question for you guys who are much more 
 advanced than me
 :-)
 I want ot do an automatic redirection in a php page... Is 
 there something equivalent to response.redirect used in ASP?
 
 Thanks in advance,
 
 Pascal Platteeuw
 
 --
 PHP General Mailing List (http://www.php.net/) To 
 unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP] Newbie question

2004-11-28 Thread John Nichel
Pascal Platteeuw wrote:
Hello everyone,
Here is a newbie question for you guys who are much more advanced than me
:-)
I want ot do an automatic redirection in a php page... Is there something
equivalent to response.redirect used in ASP?
Thanks in advance,
Pascal Platteeuw
http://us4.php.net/header
--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] newbie question

2004-11-15 Thread Richard Davey
Hello Max,

Monday, November 15, 2004, 6:26:43 PM, you wrote:

MK } else if ($_POST[FirstName] != ) {

Where you use $_POST you should have the syntax as follows:

$_POST['var']

(note the quote marks)

Without them, PHP is going to think you're passing in a constant
called FirstName (etc) which of course you're not.

MK $add_table = INSERT into table values (NULL, '$_POST[FirstName]',
MK '$_POST[LastName], '$_POST[Address], '$_POST[City], 
'$_POST[State],
MK '$_POST[Zip], '$_POST[phone],'$_POST[email]);
MK mysql_query($add_table) or die(mysql_error());

You really *really* shouldn't insert POST data directly into a table,
for reasons please see Chris's very good read on PHP Security here:

http://shiflett.org/php-security.pdf

But back to the question in hand - try and see what has happened,
extend your code a bit at the end:

mysql_query($add_table);

if (mysql_error($conn))
{
   echo Something bad happened with MySQL:  . mysql_error($conn);
}
else
{
echo There was no SQL error;
}

Try outputting the SQL (echo $add_table) and then pasting it into
PHPMyAdmin or a MySQL command session and see what it gives you. If
that works fine, the error is in the communication with the MySQL
server (authentication perhaps) and not the SQL itself.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 I am not young enough to know everything. - Oscar Wilde

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



[PHP] newbie question

2004-11-15 Thread Max Krone
Hello all,

I am new to php programming and web programming in general. I have
created a php file that if it works will create a simple form for
inputing contact information and then once the submit button is
pressed, the information is saved into a MySQL database.

When I try to submit, I get no error messages, but no data goes into
the MySQL table. I have verified that my MySQL User and Password are
correct and I believe I am actually connecting to the database.

Please look at what I have created and tell me what I am doing wrong,
what I can do better, why I am an idiot, et .al.

Thanks,
Max

?php
if ($_POST[FirstName] == ) {
$display_block = h1Add an Entry/h1
form method=\post\ action=\$_SERVER[PHP_SELF]\
PstrongFirst/Last Names:/strongbr
input type=\text\ name=\FirstName\ size=30 maxlength=75
input type=\text\ name=\LastName\ size=30 maxlength=75

PstrongAddress:/strongbr
input type=\text\ name=\Address\ size=30

PstrongCity/State/Zip/strongbr
input type=\text\ name=\City\ size=30 maxlength=50
input type=\text\ name=\State\ size=5 maxlength=2
input type=\text\ name=\Zip\ size=10 maxlength=10

PstrongTelephone Number:/strongbr
input type=\text\ name=\phone\ size=30 maxlength=25

PstrongEmail Address:/strongbr
input type=\text\ name=\email\ size=30 maxlength=150

Pinput type=\submit\ name=\submit\ value=\Add Entry\/p
/FORM;

} else if ($_POST[FirstName] != ) {
//time to add to tables, so check for required fields
if (($_POST[FirstName] == ) || ($_POST[LastName] == ) ||
($_POST[city] == ) ||
  ($_POST[State] == ) || ($_POST[Zip] == ) || ($_POST[phone] == ) 
||
  ($_POST[email] == )) {
header(Location: addentry.php);
exit;
}

//connect to database
$conn = mysql_connect(localhost, user, password)
  or die(Failure to attach to database);
mysql_select_db(database, $conn) or die(Failure to attach to 
database);

//add to first and last name
$add_table = INSERT into table values (NULL, '$_POST[FirstName]', 
'$_POST[LastName], '$_POST[Address], '$_POST[City], 
'$_POST[State],
'$_POST[Zip], '$_POST[phone],'$_POST[email]);
mysql_query($add_table) or die(mysql_error());


}
?
HTML
HEAD
TITLEAdd an Entry/TITLE
/HEAD
BODY
?php echo $display_block; ?
/BODY
/HTML

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



RE: [PHP] newbie question

2004-11-15 Thread Chris W. Parker
Greg Donald mailto:[EMAIL PROTECTED]
on Monday, November 15, 2004 11:08 AM said:

 ?php
 if ($_POST[FirstName] == ) {
 $display_block = h1Add an Entry/h1
 form method=\post\ action=\$_SERVER[PHP_SELF]\
 PstrongFirst/Last Names:/strongbr
 input type=\text\ name=\FirstName\ size=30 maxlength=75
 input type=\text\ name=\LastName\ size=30 maxlength=75
 
 It's trivial for a malicious attacker to bypass your maxlength, just
 an FYI.  You should check with strlen() after the post, or possibly
 look into javascript form validation.

Greg, I'm sure you already understand this but I just wanted to add to
your statement for those that may not.

Javascript should not be relied upon for data validation as a security
measure. It should merely be used as a convenience to the user (so they
don't have to wait for a page to reload just to see some error notices)
and to take load off the server (so the server does not have to process
a page 10 times while the customer refines their input to match your
criteria). Having said that, make sure to always have server side
validation in place even if you *do* in fact also use Javascript on the
client side.



Chris.

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



Re: [PHP] newbie question

2004-11-15 Thread Greg Donald
On Mon, 15 Nov 2004 10:26:43 -0800, Max Krone [EMAIL PROTECTED] wrote:
 When I try to submit, I get no error messages, but no data goes into
 the MySQL table. I have verified that my MySQL User and Password are
 correct and I believe I am actually connecting to the database.
 
 Please look at what I have created and tell me what I am doing wrong,
 what I can do better, why I am an idiot, et .al.
 
 ?php
 if ($_POST[FirstName] == ) {
 $display_block = h1Add an Entry/h1
 form method=\post\ action=\$_SERVER[PHP_SELF]\
 PstrongFirst/Last Names:/strongbr
 input type=\text\ name=\FirstName\ size=30 maxlength=75
 input type=\text\ name=\LastName\ size=30 maxlength=75

It's trivial for a malicious attacker to bypass your maxlength, just
an FYI.  You should check with strlen() after the post, or possibly
look into javascript form validation.

 PstrongAddress:/strongbr
 input type=\text\ name=\Address\ size=30
 
 PstrongCity/State/Zip/strongbr
 input type=\text\ name=\City\ size=30 maxlength=50
 input type=\text\ name=\State\ size=5 maxlength=2
 input type=\text\ name=\Zip\ size=10 maxlength=10
 
 PstrongTelephone Number:/strongbr
 input type=\text\ name=\phone\ size=30 maxlength=25
 
 PstrongEmail Address:/strongbr
 input type=\text\ name=\email\ size=30 maxlength=150
 
 Pinput type=\submit\ name=\submit\ value=\Add Entry\/p
 /FORM;
 
 } else if ($_POST[FirstName] != ) {
 //time to add to tables, so check for required fields
 if (($_POST[FirstName] == ) || ($_POST[LastName] == ) ||
 ($_POST[city] == ) ||
   ($_POST[State] == ) || ($_POST[Zip] == ) || ($_POST[phone] == 
 ) ||
   ($_POST[email] == )) {
 header(Location: addentry.php);
 exit;
 }
 
 //connect to database
 $conn = mysql_connect(localhost, user, password)
   or die(Failure to attach to database);
 mysql_select_db(database, $conn) or die(Failure to attach to 
 database);
 
 //add to first and last name
 $add_table = INSERT into table values (NULL, '$_POST[FirstName]',
 '$_POST[LastName], '$_POST[Address], '$_POST[City], 
 '$_POST[State],
 '$_POST[Zip], '$_POST[phone],'$_POST[email]);

You're missing the closing single quote on most all the $_POST variables.

 mysql_query($add_table) or die(mysql_error());

How about:

or die(mysql_error() . ' query was: ' . $add_table)

so you can see your query as it goes to the database.

 
 }
 ?
 HTML
 HEAD
 TITLEAdd an Entry/TITLE
 /HEAD
 BODY
 ?php echo $display_block; ?
 /BODY
 /HTML

Also, your code is subject to SQL injection.  You might want to
investigate PHP's addslashes() function.  And maybe read this too:

http://shiflett.org/php-security.pdf


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



[PHP] Newbie Question: DHTML client Http Post to PHP running under Apache/Win XP

2004-08-27 Thread Bestman4unowwa
Does the PHP script have to be already running to communicate send a HTTP Post 
varibale to it (from a DHTML client browser)?  Or can it initiate the HTTP Post fron 
the client that activates the PHP script?

I know this must seems simple but I'm having troble receiving these varible from my 
client. When I find out the value of the vaiable I stick it into a MySQL table. Both 
client DHTML and server PHP work well alone but I can't seem to et the connection 
going using localhost.

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



Re: [PHP] Newbie Question: DHTML client Http Post to PHP running under Apache/Win XP

2004-08-27 Thread John Holmes
From: [EMAIL PROTECTED]
Does the PHP script have to be already running to
communicate send a HTTP Post varibale to it (from a
DHTML client browser)?  Or can it initiate the HTTP
Post fron the client that activates the PHP script?
Just like any other web page, the POST request causes the web server to 
start the PHP script which receives the posted values. They are then 
available in the $_POST array. print_r($_POST) is your friend here (and 
mine!!).

Without seeing your code I'll have to resort to my crystal ball for the 
problems and right now it's leading me to believe your PHP script needs 
watering around line 45.

---John Holmes... 

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


[PHP] Newbie question about isset and binary conditionals

2004-06-07 Thread Al
I posted this previously; but the subject was misleading.
I could use one additional clarification regarding good practice.
As I understand the php manual the following is acceptable and I assume 
good practice.

$foo= TRUE;
if($foo) do..  ;  where $foo is a binary; but not a variable.
isset should be used for variables, such as;
isset($var) for variables and be careful with $var= ' '; etc.  because 
$var is assigned, i.e., set.

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


[PHP] Newbie question about isset and binary conditionals

2004-06-07 Thread Al
I posted this previously; but the subject was misleading.
I could use one additional clarification regarding good practice.
As I understand the php manual the following is acceptable and I assume 
good practice.

$foo= TRUE;
if($foo) do..  ;  where $foo is a binary; but not a variable.
isset should be used for variables, such as;
isset($var) for variables and be careful with $var= ' '; etc.  because 
$var is assigned, i.e., set.

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


RE: [PHP] Newbie question about isset and binary conditionals

2004-06-07 Thread Ford, Mike [LSS]
On 07 June 2004 14:04, Al wrote:

 I posted this previously; but the subject was misleading.

You seem to have several possible misconceptions in your posting -- this may
just be me misreading you, but anyway...

 I could use one additional clarification regarding good practice.
 
 As I understand the php manual the following is acceptable
 and I assume
 good practice.
 
 $foo= TRUE;

Not only acceptable but encouraged.

 
 if($foo) do..  ;  where $foo is a binary; but not
 a variable.

$foo is always a variable -- it can contain values of several types, one of
which is Boolean (not binary -- that's just a way of representing integers)
TRUE/FALSE.
 
 isset should be used for variables, such as;
 
  isset($var) for variables and be careful with $var= ' ';
 etc.  because
 $var is assigned, i.e., set.

To work out which test you need to use, it's crucial to understand what
evaluates to FALSE in a Boolean context (which the test of an if() statement
is.  This is covered in precise detail in the PHP manual at
http://www.php.net/manual/en/language.types.boolean.php#language.types.boole
an.casting, but to summarize:

   the following are considered FALSE: Boolean FALSE, numeric zero (0 or
0.0), the strings  and 0, an empty array or object, and NULL; all other
values are TRUE.  In addition to this, an unset variable will be evaluated
as NULL, and hence considered FALSE, but PHP will also issue an undefined
variable warning in this case (which may or may not be suppressed by your
PHP configuration!).

On the other hand, isset($var) will return TRUE if $var has been set to any
value except NULL, and FALSE otherwise -- so an isset() test on all the
other values listed above (including FALSE!) will be TRUE.

Other tests you may want to look into are empty() http://www.php.net/empty
and is_null() http://www.php.net/is-null; there are also some handy tables
at http://uk.php.net/manual/en/types.comparisons.php to help you see what
the various tests return.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] Newbie question about isset and binary conditionals

2004-06-07 Thread Al
That's a big help Mike. 

My server has the error level set such that my incorrect use of if($var) 
did not show undefined variables. Though everything seemed to work OK.

I'm going my code and using if( TRUE or FALSE) isset() and empty() as 
appropriate.

Al..

Mike Ford wrote:
On 07 June 2004 14:04, Al wrote:
 

I posted this previously; but the subject was misleading.
   

You seem to have several possible misconceptions in your posting -- this may
just be me misreading you, but anyway...
 

I could use one additional clarification regarding good practice.
As I understand the php manual the following is acceptable
and I assume
good practice.
$foo= TRUE;
   

Not only acceptable but encouraged.
 

if($foo) do..  ;  where $foo is a binary; but not
a variable.
   

$foo is always a variable -- it can contain values of several types, one of
which is Boolean (not binary -- that's just a way of representing integers)
TRUE/FALSE.
 

isset should be used for variables, such as;
isset($var) for variables and be careful with $var= ' ';
etc.  because
$var is assigned, i.e., set.
   

To work out which test you need to use, it's crucial to understand what
evaluates to FALSE in a Boolean context (which the test of an if() statement
is.  This is covered in precise detail in the PHP manual at
http://www.php.net/manual/en/language.types.boolean.php#language.types.boole
an.casting, but to summarize:
  the following are considered FALSE: Boolean FALSE, numeric zero (0 or
0.0), the strings  and 0, an empty array or object, and NULL; all other
values are TRUE.  In addition to this, an unset variable will be evaluated
as NULL, and hence considered FALSE, but PHP will also issue an undefined
variable warning in this case (which may or may not be suppressed by your
PHP configuration!).
On the other hand, isset($var) will return TRUE if $var has been set to any
value except NULL, and FALSE otherwise -- so an isset() test on all the
other values listed above (including FALSE!) will be TRUE.
Other tests you may want to look into are empty() http://www.php.net/empty
and is_null() http://www.php.net/is-null; there are also some handy tables
at http://uk.php.net/manual/en/types.comparisons.php to help you see what
the various tests return.
Cheers!
Mike
-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 
 

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


Re: [PHP] Newbie question about good coding practice [isset]

2004-06-06 Thread Justin Patrin
Curt Zirzow wrote:
* Thus wrote K.Bogac Bokeer ([EMAIL PROTECTED]):
When $var is 0?
?
 $var = 0;

or
  $var = '';
  $var = array();
  $var = false;

 // Output: $var: $var not exists
 if ( $var )
   echo '$var: $var existsbr';
 else


Curt
or null
--
paperCrane Justin Patrin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread Al
if($var) do something;
verses
if(isset($var)) do something;
The simple form if($var) seems to work fine and I see it in code often.
Is there a good reason for using isset?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread Larry E . Ullman
if($var) do something;
verses
if(isset($var)) do something;
The simple form if($var) seems to work fine and I see it in code often.
Is there a good reason for using isset?
Yes, if you don't use isset(), you may see notices (errors) if the 
variable is not set. This depends upon the error reporting settings of 
the server. However, if you use isset() you won't see notices 
regardless.

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


Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread K.Bogac Bokeer
When $var is 0?
?
  $var = 0;
  // Output: $var: $var not exists
  if ( $var )
echo '$var: $var existsbr';
  else
echo '$var: $var not existsbr';
  // Output: isset(): var exists
  if ( isset($var) )
echo 'isset(): $var existsbr';
  else
echo 'isset(): $var not existsbr';
?
Larry E . Ullman wrote:
if($var) do something;
verses
if(isset($var)) do something;
The simple form if($var) seems to work fine and I see it in code often.
Is there a good reason for using isset?

Yes, if you don't use isset(), you may see notices (errors) if the 
variable is not set. This depends upon the error reporting settings of 
the server. However, if you use isset() you won't see notices regardless.

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


Re: [PHP] Newbie question about good coding practice [isset]

2004-06-05 Thread Curt Zirzow
* Thus wrote K.Bogac Bokeer ([EMAIL PROTECTED]):
 When $var is 0?
 
 ?
   $var = 0;

or
  $var = '';
  $var = array();
  $var = false;

 
   // Output: $var: $var not exists
   if ( $var )
 echo '$var: $var existsbr';
   else



Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



[PHP] (Newbie question) Advice on comment system (no db!) design issues

2004-06-03 Thread Yngve
Hi!

I am about to write a comment system in PHP, but as i am not any good at PHP
i am seeking some advice.

This is what i want from the system:
* Flexibility! I want to be able to attach it where i want let the user give
comments easily. For example comments could be on a blog entry or on a
downloadable file, whatever i like it to be.
* I will moderate all comments from all commentpoints before they are
published.
* Not use a database.

I am wondering what the best approach is?

I thought of this:
Use an object oriented approach, and have a class called CommentSystem.

When i create an instance of the class the commentpoint id (some
integer/string) is passed and the comments are read into the object.

After the object creation i can display all comments using something similar
to: aCommantSystem-outputHTML() in my code.

The inner datastructure holding the comments should be an array, perhaps
multidimensional with different data in each column? When a comment is added
using something similar to
aCommantSystem-addComment($username,$comment,$date) the array has one
element appended to it.

Persistent storage of the commentsystem is done through serialize and
unserialize and saved to a file with equal name to the specific
commentpoint id.

I will have some way to list all new comments from all commentpoints so that
i can moderate them (accept/refuse) before they are to be viewed in public.
I haven´t thought of some good way to do this though.

Does the above sound like a good solution? Or should i do it in some other
way? All feedback would be appreciated!

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



Re: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread PHP4web
ok let say that you have 2 or more variables with same name but there are
difference in numbering And Values like this :

$var1 = 1 ;
$var2 =  12 ;
// etc ..

now you must now how much of number of this varibles before you deal with it
or you must store it on array to know how to count it in the fly like this :

$var[var1] = 1;
$var[var2] = 12;
// etc ..
$var_count  = count($var); // give you the count

now you can deal with vars like this :

$i = 1;
do {
$NewVar[NewVar.$i] = $var[var.$i] * $WhatEver ;
$i++;
}
while ($i = $var_count );

And finally you can extract vars by extract() to make them in normal shape
if you get my point

- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, May 28, 2004 8:01 AM
Subject: RE: [PHP] Newbie Question: Variables on the fly


 Thanks for the reply Denis,

 Let me elaborate a bit.

 I have a php page which I want to pass a series of variables via a url
string.

 eg

 myPage.php?dataPoint1=10dataPoint2=20dataPoint3=30

 The thing is I won;t know until runtime how many dataPoints there will be
 so I have also included 1 additional url variable

 eg

 myPage.php?totalDataPoints=3dataPoint1=10dataPoint2=20dataPoint3=30

  From there I want to take those data points and do several things with
 each of them.  The keep things simple lets say I want to multiply each by
3
 and then divide it by 2 and put it into a new variable (under the same
 naming system).

 eg

 $xtemp=$HTTP_GET_VARS[totalDataPoints];

 do {
  A line here which will take each dataPoint and multiply by 3 and
 divide by 2 and assign it to a new variable with the same numbering system
 (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
  $xtemp--;
 } while ($xtemp0);

 Make any more sense?

 Thanks.


 At 01:24 AM 28/05/2004, Dennis Seavers wrote:
 Maybe others will catch on to your intention, but I think you need to
 provide a bit more information.  For example, what variables do you want
to
 create (drawn from a file source, or create on the fly)?  Where will they
 come from (a database, perhaps)?  You could create a script that creates
 variables from scratch, following a (hopefully) finite mathematical
 formula.  Or you could manipulate data that already exists, turning this
 data into some kind of variables.
 
 Ultimately, you'll have to give a better of sense of the end result you'd
 like.
 
 Dennis Seavers
 
 
   [Original Message]
   From: [EMAIL PROTECTED]
   To: PHP List [EMAIL PROTECTED]
   Date: 05/27/2004 9:17:11 PM
   Subject: [PHP] Newbie Question: Variables on the fly
  
   Hello,
  
   I'm sure this is a newbie question but I don't know the syntax.
  
   I want to create a series of variables within a php script at runtime
 with
   a for loop.
  
   eg
  
   myVar1
   myVar2
   myVar3
   etc
  
   What is the proper syntax to do this?
  
   Thanks,
  
   Tim
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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




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



RE: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Steve Edberg
At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url string.
eg
myPage.php?dataPoint1=10dataPoint2=20dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there 
will be so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3dataPoint1=10dataPoint2=20dataPoint3=30
From there I want to take those data points and do several things 
with each of them.  The keep things simple lets say I want to 
multiply each by 3 and then divide it by 2 and put it into a new 
variable (under the same naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 
and divide by 2 and assign it to a new variable with the same 
numbering system (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp0);

Make any more sense?
Thanks.

Strictly speaking, your original question referred to what PHP calls 
'variable variables':

http://us3.php.net/manual/en/language.variables.variable.php
However, most of what you can do with them can be done more simply 
with arrays. In your example above, use

myPage.php?dataPoint[]=10dataPoint[]=20dataPoint[]=30
and you get an array
$dataPoint[0]=10
$dataPoint[1]=20
$dataPoint[2]=30
The number of data points is count($dataPoint). See
http://us3.php.net/manual/en/language.variables.external.php
for more info on this technique.
steve edberg


At 01:24 AM 28/05/2004, Dennis Seavers [EMAIL PROTECTED] wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers

 [Original Message]
 From: [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Date: 05/27/2004 9:17:11 PM
  Subject: [PHP] Newbie Question: Variables on the fly
 Hello,
 I'm sure this is a newbie question but I don't know the syntax.
 I want to create a series of variables within a php script at runtime
with
 a for loop.
 eg
 myVar1
 myVar2
 myVar3
 etc
 What is the proper syntax to do this?
 Thanks,
  Tim


--
+--- my people are the people of the dessert, ---+
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
+ said t e lawrence, picking up his fork +
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Curt Zirzow
* Thus wrote Steve Edberg ([EMAIL PROTECTED]):
 At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
 
 However, most of what you can do with them can be done more simply 
 with arrays. In your example above, use
 
   myPage.php?dataPoint[]=10dataPoint[]=20dataPoint[]=30
 

I'd also suggest to add the index in the dataPoints, so you're not
relying on the browser or php to determain what order the array
will be built.

myPage.php?dataPoint[1]=10dataPoint[3]=20dataPoint[1]=30


Go Aggies!

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



RE: [PHP] Newbie Question: Variables on the fly

2004-05-28 Thread Tim Winters
Steve!!!
This is great!
I had no idea you could use arrays in url variables.  That makes everything 
much easier.

Thanks very much
Tim
At 06:26 AM 28/05/2004, Steve Edberg wrote:
At 2:01 AM -0300 5/28/04, [EMAIL PROTECTED] wrote:
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url 
string.

eg
myPage.php?dataPoint1=10dataPoint2=20dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there will be 
so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3dataPoint1=10dataPoint2=20dataPoint3=30
From there I want to take those data points and do several things
with each of them.  The keep things simple lets say I want to multiply 
each by 3 and then divide it by 2 and put it into a new variable (under 
the same naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 and 
divide by 2 and assign it to a new variable with the same numbering 
system (eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp0);

Make any more sense?
Thanks.

Strictly speaking, your original question referred to what PHP calls 
'variable variables':

http://us3.php.net/manual/en/language.variables.variable.php
However, most of what you can do with them can be done more simply with 
arrays. In your example above, use

myPage.php?dataPoint[]=10dataPoint[]=20dataPoint[]=30
and you get an array
$dataPoint[0]=10
$dataPoint[1]=20
$dataPoint[2]=30
The number of data points is count($dataPoint). See
http://us3.php.net/manual/en/language.variables.external.php
for more info on this technique.
steve edberg


At 01:24 AM 28/05/2004, Dennis Seavers [EMAIL PROTECTED] wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers

 [Original Message]
 From: [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Date: 05/27/2004 9:17:11 PM
  Subject: [PHP] Newbie Question: Variables on the fly
 Hello,
 I'm sure this is a newbie question but I don't know the syntax.
 I want to create a series of variables within a php script at runtime
with
 a for loop.
 eg
 myVar1
 myVar2
 myVar3
 etc
 What is the proper syntax to do this?
 Thanks,
  Tim

--
+--- my people are the people of the dessert, ---+
| Steve Edberg  [EMAIL PROTECTED] |
| University of California, Davis  (530)754-9127 |
| Programming/Database/SysAdmin   http://pgfsun.ucdavis.edu/ |
+ said t e lawrence, picking up his fork +
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie Question: Variables on the fly

2004-05-27 Thread csnm
Hello,
I'm sure this is a newbie question but I don't know the syntax.
I want to create a series of variables within a php script at runtime with 
a for loop.

eg
myVar1
myVar2
myVar3
etc
What is the proper syntax to do this?
Thanks,
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Newbie Question: Variables on the fly

2004-05-27 Thread Dennis Seavers
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.

Ultimately, you'll have to give a better of sense of the end result you'd
like.

Dennis Seavers


 [Original Message]
 From: [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Date: 05/27/2004 9:17:11 PM
 Subject: [PHP] Newbie Question: Variables on the fly

 Hello,

 I'm sure this is a newbie question but I don't know the syntax.

 I want to create a series of variables within a php script at runtime
with 
 a for loop.

 eg

 myVar1
 myVar2
 myVar3
 etc

 What is the proper syntax to do this?

 Thanks,

 Tim

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

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



RE: [PHP] Newbie Question: Variables on the fly

2004-05-27 Thread Dennis Seavers
Yikes!!

List members, I apologize for sending a reply-requested e-mail over this
list.  Feel free to punish me by responding.  What's worse: I took another
list member to task for the same thing!

Ego deflation commences in 5 ... 4 ... 3 ... 

Dennis JackArse (the JackArse is silent)


 [Original Message]
 From: Dennis Seavers [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Date: 05/27/2004 9:30:19 PM
 Subject: RE: [PHP] Newbie Question: Variables on the fly

 Maybe others will catch on to your intention, but I think you need to
 provide a bit more information.  For example, what variables do you want
to
 create (drawn from a file source, or create on the fly)?  Where will they
 come from (a database, perhaps)?  You could create a script that creates
 variables from scratch, following a (hopefully) finite mathematical
 formula.  Or you could manipulate data that already exists, turning this
 data into some kind of variables.

 Ultimately, you'll have to give a better of sense of the end result you'd
 like.

 Dennis Seavers


  [Original Message]
  From: [EMAIL PROTECTED]
  To: PHP List [EMAIL PROTECTED]
  Date: 05/27/2004 9:17:11 PM
  Subject: [PHP] Newbie Question: Variables on the fly
 
  Hello,
 
  I'm sure this is a newbie question but I don't know the syntax.
 
  I want to create a series of variables within a php script at runtime
 with 
  a for loop.
 
  eg
 
  myVar1
  myVar2
  myVar3
  etc
 
  What is the proper syntax to do this?
 
  Thanks,
 
  Tim
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

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

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



RE: [PHP] Newbie Question: Variables on the fly

2004-05-27 Thread csnm
Thanks for the reply Denis,
Let me elaborate a bit.
I have a php page which I want to pass a series of variables via a url string.
eg
myPage.php?dataPoint1=10dataPoint2=20dataPoint3=30
The thing is I won;t know until runtime how many dataPoints there will be 
so I have also included 1 additional url variable

eg
myPage.php?totalDataPoints=3dataPoint1=10dataPoint2=20dataPoint3=30
From there I want to take those data points and do several things with 
each of them.  The keep things simple lets say I want to multiply each by 3 
and then divide it by 2 and put it into a new variable (under the same 
naming system).

eg
$xtemp=$HTTP_GET_VARS[totalDataPoints];
do {
A line here which will take each dataPoint and multiply by 3 and 
divide by 2 and assign it to a new variable with the same numbering system 
(eg $myNewVar1=$HTTP_GET_VARS[dataPoint1]*3/2;
$xtemp--;
} while ($xtemp0);

Make any more sense?
Thanks.
At 01:24 AM 28/05/2004, Dennis Seavers wrote:
Maybe others will catch on to your intention, but I think you need to
provide a bit more information.  For example, what variables do you want to
create (drawn from a file source, or create on the fly)?  Where will they
come from (a database, perhaps)?  You could create a script that creates
variables from scratch, following a (hopefully) finite mathematical
formula.  Or you could manipulate data that already exists, turning this
data into some kind of variables.
Ultimately, you'll have to give a better of sense of the end result you'd
like.
Dennis Seavers
 [Original Message]
 From: [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Date: 05/27/2004 9:17:11 PM
 Subject: [PHP] Newbie Question: Variables on the fly

 Hello,

 I'm sure this is a newbie question but I don't know the syntax.

 I want to create a series of variables within a php script at runtime
with
 a for loop.

 eg

 myVar1
 myVar2
 myVar3
 etc

 What is the proper syntax to do this?

 Thanks,

 Tim

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


[PHP] newbie question about preg_match

2004-05-20 Thread Al
I'm trying to compose a general purpose text snip expression to extract 
a text segment from a string.

Should this work for all reasonable cases?  It seems to work for several 
test strings. 

$start= str1;
$end= str2;
preg_match (|$start (.*) ? $end |i, $contents, $text);
  
$segment= $text[1];

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


Re: [PHP] newbie question about preg_match

2004-05-20 Thread John W. Holmes
From: Al [EMAIL PROTECTED]

 I'm trying to compose a general purpose text snip expression to extract
 a text segment from a string.

 Should this work for all reasonable cases?  It seems to work for several
 test strings.

 $start= str1;

 $end= str2;

 preg_match (|$start (.*) ? $end |i, $contents, $text);

 $segment= $text[1];

Looks like you have some extra spaces in there that'll mess it up. The '?'
for example, is only applying to the space before it.

You want

preg_match(|$start(.*?)$end |i, $contents, $text);

Note that this will only return one match when there could be more,
depending upon your string. If you want all of them, use preg_match_all().

---John Holmes...

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



Re: [PHP] newbie question about preg_match

2004-05-20 Thread Al
If I have multiple instances that match the pattern, but only want the 
first one, which is the best way to handle it?

Putting the U flag seems to work, but I don't understand the full 
implications of using it here. 

preg_match(|$start(.*?)$end |Ui, $contents, $text);
Alternatively, I could use preg_match_all and use $text [1]. 

Thanks
John W. Holmes wrote:
From: Al [EMAIL PROTECTED]
 

I'm trying to compose a general purpose text snip expression to extract
a text segment from a string.
Should this work for all reasonable cases?  It seems to work for several
test strings.
$start= str1;
$end= str2;
preg_match (|$start (.*) ? $end |i, $contents, $text);
$segment= $text[1];
   

Looks like you have some extra spaces in there that'll mess it up. The '?'
for example, is only applying to the space before it.
You want
preg_match(|$start(.*?)$end |i, $contents, $text);
Note that this will only return one match when there could be more,
depending upon your string. If you want all of them, use preg_match_all().
---John Holmes...
 

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


RE: [PHP] newbie question about preg_match

2004-05-20 Thread Chris W. Parker
Al mailto:[EMAIL PROTECTED]
on Thursday, May 20, 2004 12:51 PM said:

 If I have multiple instances that match the pattern, but only want the
 first one, which is the best way to handle it?

reread the last sentence in John's post.

 John W. Holmes wrote:
 
 From: Al [EMAIL PROTECTED]

[snip]

 Note that this will only return one match when there could be more,
 depending upon your string. If you want all of them, use
 preg_match_all(). 



hth,
chris.

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



[PHP] Newbie question about operators

2004-04-07 Thread Gabe
Looking at the code below, what exactly is happening with the $name=$value
part?  I looked in the PHP online documentation and I can't find that
operator.  What is it doing exactly and what is it called?

foreach ($some_array as $name=$value)
{
 ... some code ...
}

Thanks alot!

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Matt Matijevich
[snip]
foreach ($some_array as $name=$value)
{
 ... some code ...
}
[/snip]

http://www.php.net/foreach 

will give you a good explanation.

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Gabe
Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?


Matt Matijevich [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 [snip]
 foreach ($some_array as $name=$value)
 {
  ... some code ...
 }
 [/snip]

 http://www.php.net/foreach

 will give you a good explanation.

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



Re: [PHP] Newbie question about operators

2004-04-07 Thread Red Wingate
arrays :-)

you are defining arrays like:

$x = array ( 'a' = 'Apple' , 'b' = 'Banana' , ... );

 -- red

Gabe wrote:

Thanks for the page.  That was helpful.  Just to make sure, is that
operator only typically used then with foreach loops and arrays?
Matt Matijevich [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
foreach ($some_array as $name=$value)
{
... some code ...
}
[/snip]
http://www.php.net/foreach

will give you a good explanation.


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


[PHP] Newbie question on arrays

2004-03-28 Thread Willem van der Scheun
Hi,

I've written the piece of code below and I do not get any output out of the 2 
dimensional array. I do not see what's wrong. Must be something obvious I guess.

?php

$monthname[NL][1] = Januari;
$monthname[NL][2] = Februari;
$monthname[NL][3] = Maart;
$monthname[NL][4] = April;
$monthname[NL][5] = Mei;
$monthname[NL][6] = Juni;
$monthname[NL][7] = Juli;
$monthname[NL][8] = Augustus;
$monthname[NL][9] = September;
$monthname[NL][10] = Oktober;
$monthname[NL][11] = November;
$monthname[NL][12] = December;

$monthname[BR][1] = Janeiro;
$monthname[BR][2] = Fevreiro;
$monthname[BR][3] = Março;
$monthname[BR][4] = Abril;
$monthname[BR][5] = Maio;
$monthname[BR][6] = Junho;
$monthname[BR][7] = Julho;
$monthname[BR][8] = Augosto;
$monthname[BR][9] = Setembro;
$monthname[BR][10] = Outobro;
$monthname[BR][11] = Novembro;
$monthname[BR][12] = Decembro;

$monthname[EN][1] = January;
$monthname[EN][2] = February;
$monthname[EN][3] = March;
$monthname[EN][4] = April;
$monthname[EN][5] = May;
$monthname[EN][6] = June;
$monthname[EN][7] = July;
$monthname[EN][8] = August;
$monthname[EN][9] = September;
$monthname[EN][10] = October;
$monthname[EN][11] = November;
$monthname[EN][12] = December;

function show_lang_date($timestamp, $country)
{
  $date = getdate($timestamp);
  echo mday = . $date['mday'] .  ;
  echo country = $country ;
  $mon = $date[mon];
  echo mon = . $mon .  ;
  echo $monthname[$country][$mon];
  echo \n;
}

$timestamp = time();
show_lang_date($timestamp, NL);
show_lang_date($timestamp, BR);
show_lang_date($timestamp, EN);

?

When I run this I get the following output

Content-type: text/html
X-Powered-By: PHP/4.3.3

mday = 28 country = NL mon = 3
mday = 28 country = BR mon = 3
mday = 28 country = EN mon = 3

so no monthname!

[PHP] Newbie question on Array

2004-03-28 Thread carlson

Sorry, I am new and could not supply the correct search strings on search 
sites to answer by question.


I am trying to construct an array with key-value from a resultSet which will 
be used often within the page or between pages.

Which looks like this:

 $optionBox=select used_1, rub from rub_table order by rub asc;
$rs_box=mysql_query($optionBox,$con);
$arr=Array(
while($row=mysql_fetch_array($rs_box))
{
 '$row[used_1]' = '$row[rub]'  ,
});
 
 ,--- This does not need to appear in the last loop.

Is this possible?, if yes what is wrong with my code?.

many thanks for your help..

(._.)---Carlson

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



Re: [PHP] Newbie question on Array

2004-03-28 Thread Jason Wong
On Monday 29 March 2004 03:27, [EMAIL PROTECTED] wrote:

 I am trying to construct an array with key-value from a resultSet which
 will be used often within the page or between pages.

 Which looks like this:

  $optionBox=select used_1, rub from rub_table order by rub asc;
   $rs_box=mysql_query($optionBox,$con);
   $arr=Array(
   while($row=mysql_fetch_array($rs_box))
   {
'$row[used_1]' = '$row[rub]'  ,
   });

  ,--- This does not need to appear in the last loop.

 Is this possible?

No. Try:

  $optionBox=select used_1, rub from rub_table order by rub asc;
  $rs_box=mysql_query($optionBox,$con);
  while($row=mysql_fetch_array($rs_box)) {
$my_array[$row['used_1']] = $row['rub'];
  }
  print_r($my_array);


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
It is impossible for an optimist to be pleasantly surprised.
*/

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



[PHP] newbie question

2004-02-24 Thread wannes
hi -

i don't know much about php, but somehow i managed to install a simple 
php-guestbook on my website:
http://www.maanzand.be/guestbookk/readbook.php

unfortunately, i cannot get it to work
everything seems fine, but i can't manage to write to the guestbook.txt 
file
(permissions are readwrite, so i don't think that is causing the 
problem)
readbook.php  addbook.php seem to work fine, but when i fill in a 
message and hit the submit-button, nothing happens...

if anyone of you php-breathing maestro's could take a look at the 
guestbook and check if there's sth out of the ordinary, i would be 
eternally grateful...

maybe there are some features on the side of the server that i need to 
activate or something, so i've put the info.php file on the site too, 
if that helps you any further...
http://www.maanzand.be/info.php

thanx a billion,
wannes -
-
Just because I have a short attention span doesn't mean that I...
http://www.maanzand.be - under constant construction

[EMAIL PROTECTED]
016 28 48 42 - 0486 21 32 92

Re: [PHP] newbie question

2004-02-24 Thread Chris Hayes
could it be that this is an old script that requires register_globals to be 
turned ON or so?
if you can read Dutch, read http://www.phpfreakz.nl/artikelen.php?aid=88

At 12:25 24-2-04, you wrote:
hi -

i don't know much about php, but somehow i managed to install a simple 
php-guestbook on my website:
http://www.maanzand.be/guestbookk/readbook.php

unfortunately, i cannot get it to work
everything seems fine, but i can't manage to write to the guestbook.txt file
(permissions are readwrite, so i don't think that is causing the problem)
readbook.php  addbook.php seem to work fine, but when i fill in a message 
and hit the submit-button, nothing happens...

if anyone of you php-breathing maestro's could take a look at the 
guestbook and check if there's sth out of the ordinary, i would be 
eternally grateful...

maybe there are some features on the side of the server that i need to 
activate or something, so i've put the info.php file on the site too, if 
that helps you any further...
http://www.maanzand.be/info.php

thanx a billion,
wannes -
-
Just because I have a short attention span doesn't mean that I...
http://www.maanzand.be - under constant construction

[EMAIL PROTECTED]
016 28 48 42 - 0486 21 32 92
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Newbie question

2004-01-13 Thread James Marcinek
Hello Everyone,

I'm new to this so forgive my ignorance. I'm trying to use php with MySQL
as a database. I'm using apache 2.0 in addition to Mysql 4.1.

I created a simple page (using book to learn) and when I try to go to a
simple  php script I recieve the following error:

Call to undefined function:  mysql_connect()

I've followed the instructions and the mysql_connect() function has the
correct arguments supplied (host, user, passwd);

Can anyone shed any light on this? I've looked at the php.ini file and it
looks ok. the apache has the php.conf file in the conf.d directory.

The book I'm learning from had some simple examples pages that I created
early on and they work; however this is the first attempt at trying to use
php to connect.

Any help would be appreciated.

Thanks,

James

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



Re: [PHP] Newbie question

2004-01-13 Thread Richard Davey
Hello James,

Tuesday, January 13, 2004, 3:37:17 PM, you wrote:

JM The book I'm learning from had some simple examples pages that I created
JM early on and they work; however this is the first attempt at trying to use
JM php to connect.

Post your code (if it's from a book I'm guessing it isn't very long),
will be able to pinpoint cause of the error then.

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



RE: [PHP] Newbie question

2004-01-13 Thread Sam Masiello

It appears as if you don't have MySQL support compiled in with your PHP
build.  If you installed it from source you will want to recompile PHP
with the --with-mysql option.  I have never installed PHP from RPM
though so if you installed it that way, perhaps someone else in the
group can provide some guidance on how to do that.

HTH!

--Sam



James Marcinek wrote:
 Hello Everyone,
 
 I'm new to this so forgive my ignorance. I'm trying to use php with
 MySQL as a database. I'm using apache 2.0 in addition to Mysql 4.1. 
 
 I created a simple page (using book to learn) and when I try to go to
 a simple  php script I recieve the following error: 
 
 Call to undefined function:  mysql_connect()
 
 I've followed the instructions and the mysql_connect() function has
 the correct arguments supplied (host, user, passwd); 
 
 Can anyone shed any light on this? I've looked at the php.ini file
 and it looks ok. the apache has the php.conf file in the conf.d
 directory.  
 
 The book I'm learning from had some simple examples pages that I
 created early on and they work; however this is the first attempt at
 trying to use php to connect.  
 
 Any help would be appreciated.
 
 Thanks,
 
 James

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



[PHP] Newbie question... date.

2004-01-13 Thread DL
Hi all,

I was wondering how you get the year, month, and day from a timestamp.
(mySQL timestamp, Eg: 20040113130137)  What PHP function(s) do I use?  An
example would be great

Cheers,
David

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



Re: [PHP] Newbie question... date.

2004-01-13 Thread Chris Boget
 I was wondering how you get the year, month, and day from a timestamp.
 (mySQL timestamp, Eg: 20040113130137)  What PHP function(s) do I use?  An
 example would be great

I *believe* you can use strtotime();

Chris

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



Re: [PHP] Newbie question... date.

2004-01-13 Thread Ray
On Tuesday 13 January 2004 13:57, DL wrote:
 Hi all,

 I was wondering how you get the year, month, and day from a
 timestamp. (mySQL timestamp, Eg: 20040113130137)  What PHP
 function(s) do I use?  An example would be great

 Cheers,
 David

http://www.php.net/manual/en/function.strtotime.php
copied from the comments (formatting may be lost)

scott at pigandcow dot com
29-Dec-2003 09:54
Unfortunately, strtotime() can't convert mysql timestamps of the form 
MMDDhhmmss (the default 14 character timestamp).  Here's a 
function to do it for you:

function convert_timestamp ($timestamp, $adjust=) {
   $timestring = substr($timestamp,0,8). .
 substr($timestamp,8,2).:.
 substr($timestamp,10,2).:.
 substr($timestamp,12,2);
   return strtotime($timestring. $adjust);
}

Remember that the $adjust string needs to be properly spaced- + 30 
days, not +30days!

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



[PHP] newbie question about header()

2003-12-21 Thread Scott Taylor


I am simply trying to redirect users from one page to another.  Yet when 
I use this code I get the following error:

*Warning*: Cannot add header information - headers already sent by 
(output started at 
/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php:8) 
in 
*/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php* 
on line *9*
*
*

html
head
/head
body

?php
header('Location: http://www.slashdot.org/'); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?
/body
/html


I know the workaround with the meta tag (meta http-equiv=REFRESH 
content=0; URL=http://www.slashdot.org/;, but I just don't understand 
what I am doing wrong here.  I'm sure someone here knows

Thank you in advance,

Scott Taylor
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] newbie question about header()

2003-12-21 Thread Website Managers.net
Unless you're using an 'if' statement, the header redirect must be the first line of 
the page, above any HTML markup.

Jim
www.websitemanagers.net

- Original Message - 
From: Scott Taylor [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, December 21, 2003 8:04 PM
Subject: [PHP] newbie question about header()


| 
| 
| I am simply trying to redirect users from one page to another.  Yet when 
| I use this code I get the following error:
| 
| *Warning*: Cannot add header information - headers already sent by 
| (output started at 
| /usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php:8) 
| in 
| */usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php* 
| on line *9*
| *
| *
| 
| html
| head
| /head
| 
| body
| 
| ?php
| header('Location: http://www.slashdot.org/'); /* Redirect browser */
| 
| /* Make sure that code below does not get executed when we redirect. */
| exit;
| ?
| 
| /body
| /html
| 
| 
| 
| I know the workaround with the meta tag (meta http-equiv=REFRESH 
| content=0; URL=http://www.slashdot.org/;, but I just don't understand 
| what I am doing wrong here.  I'm sure someone here knows
| 
| Thank you in advance,
| 
| Scott Taylor
| [EMAIL PROTECTED]
| 
| -- 
| PHP General Mailing List (http://www.php.net/)
| To unsubscribe, visit: http://www.php.net/unsub.php
| 
|

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



Re: [PHP] newbie question about header()

2003-12-21 Thread John W. Holmes
Scott Taylor wrote:



I am simply trying to redirect users from one page to another.  Yet when 
I use this code I get the following error:

*Warning*: Cannot add header information - headers already sent by 
(output started at 
/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php:8) 
in 
*/usr/local/psa/home/vhosts/miningstocks.com/httpdocs/etc/php/login/admin/test.php* 
on line *9*
*
*

html
head
/head
body

?php
header('Location: http://www.slashdot.org/'); /* Redirect browser */
/* Make sure that code below does not get executed when we redirect. */
exit;
?
You can't have any output before trying to use header(). html, etc, 
are considered output. So, the very first line in your file must be 
?php and you can use header() before you echo anything within that PHP 
block.

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

php|architect: The Magazine for PHP Professionals  www.phparch.com

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


Re: [PHP] newbie question about header()

2003-12-21 Thread Justin French
On Monday, December 22, 2003, at 01:13  PM, Website Managers.net wrote:

Unless you're using an 'if' statement, the header redirect must be the 
first line of the page, above any HTML markup.
That's not entirely accurate.

---Quoted from http://php.net/header ---
Remember that header() must be called before any actual output is sent, 
either by normal HTML tags, blank lines in a file, or from PHP. It is a 
very common error to read code with include(), or require(), functions, 
or another file access function, and have spaces or empty lines that 
are output before header() is called. The same problem exists when 
using a single PHP/HTML file.


header() doesn't need to be 'the first line of the page', but it does 
need to be placed above/before any output gets sent to the browser.

bad:
html
? header(...); ?
bad:
?
echo foo;
header(...);
?
good:
?
include('something.inc');
session_start();
$foo = 'bah';
header(...);
?
if there's any code following the redirect (which you don't want to 
execute), I'd also strongly recommend having an exit; after the 
header():

?
include('something.inc');
if($foo)
{
header(...);
exit;
}
// some other stuff that shouldn't get executed after redirect
?
Justin French

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


[PHP] newbie question about scope

2003-11-12 Thread news.comcast.giganews.com
I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:

A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that it could not be trusted, however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.

Matthew

PS. How do you scope queries?

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



Re: [PHP] newbie question about scope

2003-11-12 Thread Derek Ford
news.comcast.giganews.com wrote:

I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:
   A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that it could not be trusted, however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.
Matthew

PS. How do you scope queries?

 

You're thinking about this in the wrong way, it seems. The server 
probably has register_globals Off, where previously he was programming 
with it being On. or vise-versa. They should be Off, and should be left 
off, but programming with them off needs some adjusting. Variables such 
as post and get data are now 'superglobals', and must use the 
appropriate arrays; $_GET[], and $_POST[]. There are things like 
extract(), but using them is not advised. as per your question about 
scope queries, be more concrete :)

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


RE: [PHP] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
A client moved their site from a server (unknown details) to a
hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed
that
they are coming from an earlier version of apache/php.
[/snip]

It is likely then that register_globals is set to OFF in the php.ini. In
earlier versions this directive was set to ON. It was a security issue
that was more about bad coding than a PHP vulnerability. If you passed a
form field with the name of userName it could be accessed by PHP in the
$userName variable, with RG off you would have to access it via
$_GET['userName'] or $_POST['userName'] dependent upon the processing
method of the form.

[snip]
Also, how bad is the _REQUEST scope I read that it could not be
trusted
[/snip]

Again, bad coding would present a danger here.

[snip]
PS. How do you scope queries?
[/snip]

I am not sure what you are asking here. Do you mean making a query
public or private?

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



Re: [PHP] newbie question about scope

2003-11-12 Thread news.comcast.giganews.com

Derek Ford [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 news.comcast.giganews.com wrote:

 I am an experienced web developer who is just getting into php.  I have
had
 a php project fall into my lap and wanted a little advice.  Here is the
 scoop:
 
 A client moved their site from a server (unknown details) to a
hosting
 facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
 they are coming from an earlier version of apache/php.  Anyway it appears
 that whoever created the site in the first place did not believe in
scoping
 variables.  Now any variable that is not properly scoped will not be read
by
 the server.  I know I can simply scope all of the variables, but I was
 hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
 read that it could not be trusted, however the previous developer
created
 the app in such a way that several places a variable could be _GET or
_POST.
 I apologize for the rambling and possible incoherency of this message, I
am
 a bit tired.
 
 Matthew
 
 PS. How do you scope queries?
 
 
 
 You're thinking about this in the wrong way, it seems. The server
 probably has register_globals Off, where previously he was programming
 with it being On. or vise-versa. They should be Off, and should be left
 off, but programming with them off needs some adjusting. Variables such
 as post and get data are now 'superglobals', and must use the
 appropriate arrays; $_GET[], and $_POST[]. There are things like
 extract(), but using them is not advised. as per your question about
 scope queries, be more concrete :)

I agree that is the way it should be, but my client is looking for a quick
fix, not a good one.  In the end it is fortunate for my client that the
quick fix is not a viable one.  I agree that all variables should be scoped,
it is the right way to do things.  I think I have my query question figured
out.

Thanks

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



RE: [PHP] newbie question about scope

2003-11-12 Thread Jay Blanchard
[snip]
Unless I'm misunderstanding something, PHP does not implement
scoping (at least in the sense that many other programming languages
do) prior to PHP5.  
[/snip]

Actually it does implement scoping, see
http://us2.php.net/language.variables.scope

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



Re: [PHP] Newbie question about Class

2003-10-17 Thread Becoming Digital
 I was afraid that was the case. 

You've nothing to fear but fear itself.  Sessions are your friend.

Edward Dudlik
Those who say it cannot be done
should not interrupt the person doing it.

wishy washy | www.amazon.com/o/registry/EGDXEBBWTYUU



- Original Message - 
From: Al [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, 15 October, 2003 14:15
Subject: Re: [PHP] Newbie question about Class


I was afraid that was the case. 

Tom Rogers wrote:

Hi,

Thursday, October 16, 2003, 3:35:56 AM, you wrote:
A My question seems fundamental.  I want to set a variable in one function 
A in a class and then want to use the value in a second function.  
A However, the functions are called a html page with two passes.  Submit 
A reloads the page and an if(...) calls the second function in the class.

A If I declare on the first run:
A $get_data = new edit_tag_file();
A $edit_args= $get_data- edit_prep();

A The on the second pass, I'm stuck.  I can't declare a new instance of 
A edit_tag_data.
A And, it appears the object is gone after I leave the page. 

A Will the class structure do this for me or must I save the values in 
A $GLOBAL or something?

A Thanks


You need to pass the values to the next page or save them in a session

  


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

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



Re: [PHP] Newbie question about Class

2003-10-17 Thread Rory McKinley
Hi Al

Sessions and objects are quite easy to use in the latest version of PHP, and
would be my personal recommendation. I have a coupleof test scripts that I
regularly
mangle when trying to see if something is doable...if you like, you can
contact me offlist and I will mail these to you and you can try it out for
yourself.

Regards

Rory McKinley
Nebula Solutions
+27 82 857 2391
[EMAIL PROTECTED]
There are 10 kinds of people in this world,
those who understand binary and those who don't (Unknown)
- Original Message - 
From: Al [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, October 15, 2003 8:15 PM
Subject: Re: [PHP] Newbie question about Class


 I was afraid that was the case.

 Tom Rogers wrote:

 Hi,
 
 Thursday, October 16, 2003, 3:35:56 AM, you wrote:
 A My question seems fundamental.  I want to set a variable in one
function
 A in a class and then want to use the value in a second function.
 A However, the functions are called a html page with two passes.  Submit
 A reloads the page and an if(...) calls the second function in the
class.
 
 A If I declare on the first run:
 A $get_data = new edit_tag_file();
 A $edit_args= $get_data- edit_prep();
 
 A The on the second pass, I'm stuck.  I can't declare a new instance of
 A edit_tag_data.
 A And, it appears the object is gone after I leave the page.
 
 A Will the class structure do this for me or must I save the values in
 A $GLOBAL or something?
 
 A Thanks
 
 
 You need to pass the values to the next page or save them in a session
 
 
 

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




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



[PHP] Newbie question about Class

2003-10-15 Thread Al
My question seems fundamental.  I want to set a variable in one function 
in a class and then want to use the value in a second function.  
However, the functions are called a html page with two passes.  Submit 
reloads the page and an if(...) calls the second function in the class.

If I declare on the first run:
   $get_data = new edit_tag_file();
   $edit_args= $get_data- edit_prep();
The on the second pass, I'm stuck.  I can't declare a new instance of 
edit_tag_data.
And, it appears the object is gone after I leave the page. 

Will the class structure do this for me or must I save the values in 
$GLOBAL or something?

Thanks

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


RE: [PHP] Newbie question about Class

2003-10-15 Thread Chris W. Parker
Al mailto:[EMAIL PROTECTED]
on Wednesday, October 15, 2003 10:36 AM said:

 Will the class structure do this for me or must I save the values in
 $GLOBAL or something?

I think you'd have to send the value via $_GET or save it in a session
variable if you want to retrieve it on another page.


Chris.

--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



Re: [PHP] Newbie question about Class

2003-10-15 Thread Tom Rogers
Hi,

Thursday, October 16, 2003, 3:35:56 AM, you wrote:
A My question seems fundamental.  I want to set a variable in one function 
A in a class and then want to use the value in a second function.  
A However, the functions are called a html page with two passes.  Submit 
A reloads the page and an if(...) calls the second function in the class.

A If I declare on the first run:
A $get_data = new edit_tag_file();
A $edit_args= $get_data- edit_prep();

A The on the second pass, I'm stuck.  I can't declare a new instance of 
A edit_tag_data.
A And, it appears the object is gone after I leave the page. 

A Will the class structure do this for me or must I save the values in 
A $GLOBAL or something?

A Thanks


You need to pass the values to the next page or save them in a session

-- 
regards,
Tom

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



Re: [PHP] Newbie question about Class

2003-10-15 Thread Al
I was afraid that was the case. 

Tom Rogers wrote:

Hi,

Thursday, October 16, 2003, 3:35:56 AM, you wrote:
A My question seems fundamental.  I want to set a variable in one function 
A in a class and then want to use the value in a second function.  
A However, the functions are called a html page with two passes.  Submit 
A reloads the page and an if(...) calls the second function in the class.

A If I declare on the first run:
A $get_data = new edit_tag_file();
A $edit_args= $get_data- edit_prep();
A The on the second pass, I'm stuck.  I can't declare a new instance of 
A edit_tag_data.
A And, it appears the object is gone after I leave the page. 

A Will the class structure do this for me or must I save the values in 
A $GLOBAL or something?

A Thanks

You need to pass the values to the next page or save them in a session

 

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


<    1   2   3   4   5   6   >