[PHP] Re: Using Logical OR operator in IF statement???

2001-10-21 Thread James, Yz

Hi Brad,

This worked for me:

?

if ((substr($sString, 0, (strlen($sString)-1) == -)) || (substr($sString,
0, 1) == -)) {
 echo you can't have a dash at the beginning or end of your string.;
}

?

.. but I'd tend to go for a regex as a solution to what you're after,
which involves less code:

?

if (preg_match(/^-|-$/s, $string)) {
 echo You cannot have a \-\ character at the beginning or end of your
string.;
} else {
 echo Whatever;
}

?

Just my thoughts...

James

Brad Melendy [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello,
 Ok, this works:

 if (substr($sString,(strlen($sString)-1)!=-)) {
 print You can't have a dash at the end of your string.;
 }

 and this works:
 if (substr($sString,0,1)!=-) {
 print You can't have a dash at the beginning of your string.;
 }

 But, this doesn't work for any case:
 if ((substr($sString,(strlen($sString)-1)!=-)) or
 (substr($sString,0,1)!=-)) {
 print you can't have a dash at the beginning or end of your string.;
 }

 What could be wrong?  I've used a logical OR operator in the middle of an
IF
 statement like this before, but for some reason, this just isn't working.
 Anyone got any ideas?  I suppose I can just evaluate this with two
different
 IF statements, but it seems like I shoud be able to do it in one and
reduce
 duplicate code.  Thanks very much in advance.

 .Brad






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: strip HTML

2001-10-20 Thread James, Yz

The easiest way would be to use strip_tags(), though you could craft your
own regular expression.

http://www.php.net/strip_tags

James

Gary [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello All,
   How would I strip all HTML before the info in inserted to MySQL? The
 info is sent with a form. We Have one person that insist on using HTML.

 TIA
 Gary




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: parsing a string

2001-10-18 Thread James, Yz

Hey John,
something like this might work:

?

$string = This is a string with an embedded image [bird.gif,this is a
bird];

$string = preg_replace(/\[(.*?\.)(gif|jpg),(.*?)\]/i, img src=\\\1\\2\
alt=\\\3\, $string);

echo $string;

?

James

John A. Grant [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm reading some HTML text from a file and echoing it to
 stdout. The HTML text contains IMG but I would rather
 have the server do the work of looking up the image size.
 I know how to lookup the image size with getimagesize().
 My problem is in coming up with a good format for embedding
 a reference to the image in the text and then writing the code
 to parse it.

 So instead of this:
 here is some text img src=bird.gif width=100 height=20
 alt=this is a bird and here is more text and another
 image img src=plane.gif width=123 height=23
 alt=this is a plane and more text

 I would like to have something like this:
 here is some text [bird.gif,this is a bird] and here
 is more text and another image [plane.gif, this is a plane]
 and more text

 Crossing line boundaries is not an issue - each text string
 is complete. I need to be able to dump out the string until I
 see a reference to an image, then extract the name and alt text,
 handle it (by emitting IMG) and continue to echo text from
 the string until I encounter another image reference.

 My problem is in coming up with a syntax for this and then
 to write the code to extract the information.

 In the above example, I'm using the syntax:
 [filename,text]

 but it's conceivable that the HTML text might also contain
 [some plain text not related to images]

 so I thought about some of these:
 {filename,alt text} - not good, text might contain {plain text]
 @filename, alt text@
 img(filename,alt text)

 Using the same @ delimiter at each end might make it easier
 to use explode() to split the text.  But perhaps img(filename,text)
 is more elegant, but it might need more skills than I have in using
 regex to recognize it and extract it.  Also I need to figure out how
 to extract and echo the plain text around it.

 Any ideas are appreciated. Thanks.

 --
 John A. Grant  * I speak only for myself *  (remove 'z' to reply)
 Radiation Geophysics, Geological Survey of Canada, Ottawa
 If you followup, please do NOT e-mail me a copy: I will read it here






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] local time v.s. server time

2001-08-25 Thread James, Yz

Hi Joe,

GMT isn't affected by daylight savings (altough in the UK we are using
British Summer Time at the moment, which is GMT +1), so that's the constant
you can work from if you're not experiencing daylight savings schemes where
you are.  I have written out an example for you below.

We get the Y-m-d H:i:s format of time using gmdate() (which Mysql likes).
We convert that lot to a timestamp.  The function I've created takes two
arguments: whether to add or take time from the timestamp that is generated,
and the offset in hours.  So, to emulate what Mysql's now() function does,
you can do something like this

?

$now = GenerateOffset(-, 6); // takes off 6 hours.
$query = @mysql_query(INSERT INTO table (datetime) VALUES ('$now'),
$connection);

?

And you should get correct datetime formats for your timezone into your
table (providing you have put your correct offset from GMT).


?

function GenerateOffset($plusminus, $offset) {

 $datetime = gmdate(Y-m-d H:i:s);
 list($date, $time) = explode( , $datetime);
 list($year, $month, $day) = explode(-, $date);
 list($hour, $minute, $second) = explode(:, $time);

 $timestamp = mktime($hour, $minute, $second, $month, $year, $day);

 if ($plusminus == +) {
  $newtime = $timestamp + (3600 * $offset);
 } else {
  $newtime = $timestamp - (3600 * $offset);
 }

 $newdate = date(Y-m-d H:i:s, $newtime);

 return $newdate;
}

?

Hope this helps.

James

Joe Sheble ) [EMAIL PROTECTED] wrote in message
 Alas, I don't have this luxury since it's not my server, but one that is
 hosted with a web hosting provider.  They control the setup and
 configuration of the machines... since it's a shared server I doubt I'll
 convince them to set the timezone to my location, thus throwing everyone
 else on the same server out of whack...

 I can use the putenv() function though for use in PHP and then when saving
 the date and time into mySQL actually use the PHP date and time functions
 instead of the mySQL Now() function...

 Where would I find the TZ codes to use for my area?

 thanx

  -Original Message-
  From: Don Read [mailto:[EMAIL PROTECTED]]
  Sent: Friday, August 24, 2001 8:39 PM
  To: Joe Sheble (Wizaerd)
  Cc: General PHP List
  Subject: RE: [PHP] local time v.s. server time
 
 
 
  On 25-Aug-2001 Joe Sheble \(Wizaerd\) wrote:
   My website is hosted with a provider, and there is a three hour
  difference
   in timezones, so when saving date and times to the database,
  they reflect
   the server time and not my own local time.  The clincher is I
  know I could
   do some time math and just substract 3 hours, but I live in
  Arizona, so we
   do not go through daylight savings time.  So right now it's a three
hour
   difference, but when the time change happens, I'll only be two
  hours behind.
  
   Because of this, what is the best method to get my local date and time
   entered into the database instead of the server date and time??
  
 
  In my case the server is in Atlanta, but I have to sync with my
  credit-card
  processor on the left coast.
 
  So first i start the database (MySQL) on Pacific time with:
  -
  TZ=PST8PDT
  export TZ
  /usr/local/bin/safe_mysqld --user=mysql  /dev/null 
 
  
  To make PHP date/time functions jive, during initialization:
 
 
 putenv('TZ=PST8PDT');  // Server on Pacific time
 
  No matter that i'm in Texas (CST), everything is now reported on Pac
time.
 
  Regards,
  --
  Don Read   [EMAIL PROTECTED]
  -- It's always darkest before the dawn. So if you are going to
 steal the neighbor's newspaper, that's the time to do it.
 
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Help with linux / apache / php

2001-08-17 Thread James, Yz

Hi all,

I'll apologise right away - this is more or less completely off topic,
though it is remotely connected with PHP (so that's my excuse).

At the moment, the company I work for is hosted on a co-located server.  We
have one main domain and many sub domains.  Here's how they are (roughly set
up):

www.mainsite.com
www.sub1.mainsite.com
www.sub2.mainsite.com
www.sub3.mainsite.com
www.subn.mainsite.com

The document trees are like this:

/home/mainsite/www // main dir
/home/mainsite/www/sub1 //sub 1
/home/mainsite/www/sub2 // sub2
(etc)

We have just (in the last month or so) leased a cobalt raq all for our own
use.  Great.  However, the sites using this box are setup and maintained
using a web interface that comes as default with the box.  when setting up
sites (subs or otherwise), it adds sites (and you have to specify users for
those sites) with directory trees like this:

/home/sites/site1/web
/home/sites/site2/web
(etc)

Obviously, this causes problems (like for the php scripts that are running
on the current setup, where files are included / required as a part of the
main directory, and out of the document root (/home/mainsite/includes might
be an example)).

So, I'd like to learn how to use linux (bearing in mind that I have very
limited experience of unix based systems).  I can perform the very basic
commands, but would like to learn how to use / mainpulate the box through
shell access rather than over a web interface (which ultimately, I'm
assuming, will give me more flexibility - for example, I'd rather know how
to install the latest version of php onto the server following the
installation instructions than to attempt to do it through another medium).

I've bought a couple of books and hope to delve into them in the course of
the weekend and the next few weeks to come.  I'm assuming that one of the
first steps would be to install linux on my home machine and get a feel for
it (currently I'm running windows ouch).

So, here come the questions.
Where can I find the latest version of linux?  I have had a brief look at
freshmeat.net and linux.com, but didn't find any download sections (I didn't
look too hard, for reasons soon to be explained).

If I install linux, can I still use windows as a secondary OS (perhaps
running over the top of linux?)

If I can run windows as well as linux, am I best formatting my main drive,
installing linux, then windows?

Is the httpdconf file one of the main files i need to confifure for sites,
or are there many others (I've read a little about setting users up in vi
and will read more on that, but are there mounds of files that you need to
configure when setting up a new virtual site?)

I'm sorry about asking what's probably obvious to most of you, but that's
part of my reasoning behind asking on here - most of you will probably be
familiar with this stuff.  Another reason for asking here is that I don't
know of any other relevant alt groups.

I'm sure these questions have been asked many times before, but it really
has been one of those weeks, and I'm about fit to drop dead of exhaustion
(not your problem, I know, but the sympathy vote might work ;)) - I've had a
quick look through the archives and other sources, but the mounds of text
that surround the basic questions I'm asking are (in my dazed state) making
me even more dizzy.

Lastly, thanks for reading.  Any advice any of you can give, or any basic
pointers you might have, are greatly appreciated. Please cc any replies.

Thanks and goodnight,
James



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Text area ...

2001-08-06 Thread James, Yz

Hi Kok,

use nl2br();

$string = nl2br($string);
echo $string;

See the manual for full details.

James

Coconut Ming [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi..
 Did you feel it is strange alignment when you output the same thing
 again in PHP...
  I mean the line break... For example I enter the following text and the
 order of text as below
  I
  AM
  A
 GUY

  so... I store it when I output it again.. It is display as I AM A
 GUY
  the line break or [enter] key just does not detected... Anyone know
 any  solution for this? thanks for helping.

  Sincerely
  Kok Ming




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: What's the difference between echo and print?

2001-08-06 Thread James, Yz

Hi Phil,

Print returns a boolean true / false value as functions do, as well as any
output, whereas echo doesn't.  Have a look through the archives.. This is
quite a popular question, and it wasn't long ago when it was last asked.

James.


Phil Latio [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 What's the difference between echo and print?

 I believed they were the same.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: getting an auto increment value immediately after insert

2001-08-06 Thread James, Yz

Hi Matt,

mysql_insert_id();

See the manual for more info.

James

Garman [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello:

 I'm inserting some information into a MySQL database via a PHP script.  A
 handful of various information is put into the database via the INSERT
 INTO... SQL command.  Each entry has a unique, auto increment field that
acts
 as an index number for that entry.  I can't seem to figure out a clean and
 simple way to get that index number immediately after an insert.

 Granted I have a lot of field information that I could use in a very
specific
 SELECT statement's WHERE clause.  And the chances of that information
being
 identical to another is virtually zero.  However, I would like something a
bit
 more elegant, i.e., a function like mysql_get_inserted_row ().

 If anyone has any suggestions, they would be sincerely appreciated!

 Thanks,
 Matt




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] another REGEX question

2001-08-02 Thread James, Yz

Hi Julian,

personally, I'd take out both tags, using something like:

$str = preg_replace(/\/?p.*?/i, , $str);

Which gets rid of:
p
p align=whatever
/p

Or any case insensitive matches.  That's probably just me though ;)

James.

Julian Simpson [EMAIL PROTECTED] wrote in message
news:20010802214051.BGVV22490.femail29.sdc1.sfba.home.com@cr37888-a...
 $str = eregi_replace('p[^]*', ' ', $str); worked!

 thanx guys

 Julian

 At 5:19 PM -0400 8/2/01, Jack Dempsey wrote:
 Try
 $str = preg_replace(p.*?,  ,$str);
 
 jack
 
 
 Or
  $str = eregi_replace('p[^]*', ' ', $str);
 
 This matches p (or P), followed by any character string that
 DOESN'T include a , then the trailing .
 
 Preg functions are faster, though. And, if you're interested in
 little speed tweaks, use single quotes - ' - rather than double
 quotes -  - here. With double quotes, PHP searches the quoted string
 for variables or escape characters to replace.
 
  -steve
 
 
 -Original Message-
 From: Julian Simpson [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, August 02, 2001 5:16 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] another REGEX question
 
 I have a string can look like either of the following:
 psome stuff/p
 p align = leftsome stuff/p
 
 I want to use eregi_replace to take out the first p tag whether it be
 p or p align.. with a space
 
 I assumed that $str = eregi_replace (p.*,  ,$str);
 but it matches the entire string and thus turns the whole string into
 one space.
 aparently regex will match the biggest possible match rather than the
 smallest
 my question is how do i get it to match the smallest.
 
 thanx in advance..
 
 Julian
 
 
 
 --
 +-- Factoid: Of the 100 largest economies in the world, 51
are --+
 | Steve Edberg   University of California, Davis
|
 | [EMAIL PROTECTED]   Computer Consultant
|
 | http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/
|
 +--- corporations --
http://www.ips-dc.org/reports/top200text.htm ---+
 






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Types of table....

2001-07-31 Thread James, Yz

Hello Steve,

well, you should have the table set, at the very least, something like this:

UserId - INT, Primary Key, Auto increment
RealFName - varchar(20)
RealLName
UserName - Varchar (20)
PassWord - Varchar (12)

The length of the fields is optional, and you should perform checks on the
username and password to confirm that they don't contain irregular
characters that might give you problems in the future.

I'd do something like this (on signup):

if (!preg_match(/^[[:alnum:]_]+$/, $username)) {
//error
}

-That'd check if the username contained alphanumeric characters and the
underscore (_) character.  I'd take out the underscore for the password.

Having the first and last name in separate columns will allow you to perform
more informal greets to the user when you use this - Hello $RealFName, how
are you?

Look up column types in the MySQL manual at mysql.com for more detailed info
;)

James.

Steve Wright [EMAIL PROTECTED] wrote in message
00a001c11a07$0d743f60$0615fea9@COM">news:00a001c11a07$0d743f60$0615fea9@COM...
HEy,

I am still a newbie, and have no idea how to use phpMyAdmin yet, and don't
really know much about MySQL databases and setting up tables.

My Question:What table type should i use for a users REAL NAME,
USERNAME, PASSWORD, how long should i set these to, and should i have
anything else clicked while in the process??


Thanks..

Steve




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: limiting lines

2001-07-29 Thread James, Yz

Hiya Dan,

If you're expecting new lines, you could do this:

$length = explode(\n, $message);

if (sizeof($length)  55) {
// error
}

And also limit the number of characters, using strlen()

James

Dan [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,

 I would like to run a variable of unlimited length through a filter that
 would limit its length to 55 lines (ie limiting it's length to less than 1
 printed page).  Does anyone know of an easy way to do this?

 thanks.

 Regards,

 Dan Barber
 Mojolin

 ---
 Mojolin: The Open Source/Linux Employment Site
 http://www.mojolin.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Why wont this work?

2001-07-23 Thread James, Yz

Hi Dan,

try changing:
$tempfile = fopen ($filedir . / . $filename . .html, r) or die
To:
$tempfile = fopen ($filedir . / . $filename . .html, r) or die

for starters ;)

James.

Dan Krumlauf [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 news_publish.php
 ***
 ?php
 function DoTemplate() {
 $filedir = func_get_arg(0);
 $filename = func_get_arg(1);
 $news = func_get_arg(2);
 $tempfile = fopen ($filedir . / . $filename . .html, r) or die
 (Failed to open template file $filename);
 while($templine=fgets($tempfile, 4096) ) {
  $templine = preg_replace(/(NEWS)(.*?)(\/NEWS)/i,\\1$news\\2,
 $templine));
  print ($templine);
  }
  fclose ($tempfile);
 }
 $template_dir=/php/work/boz;
 $template_filename=news;
 $news=SOME STUFF GOES HERE BUILD IT AS A VAR;
 DoTemplate($template_dir,$template_filename);
 ?
 **

 news.html
 ***
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN

 html
 head
  titleNo Title/title
 /head

 body

 NEWSThis is some text/NEWS

 /body
 /html
 

 Results in

 Parse error: parse error in /php/work/boz/news_publish.php on line 8




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple (??) control structure problem

2001-07-15 Thread James, Yz

Hi Christopher,

Why not use nl2br() and trim() ?

$string = trim($string); // Clear any unwanted white space (trailing and
leading);
$string = nl2br($string); // Add line breaks where necessary

echo $string; // Voila

James

Christopher Kaminski [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm trying to write a simple weblog script, but I've encountered a
 perplexing problem.  I'm sure I'm overlooking something simple.

 I'm trying to take textarea form input, parse it, and wrap it in p
tags.
 The problem is removing extra carriage returns.  I'm sure there's a
problem
 with the if ($sentence != ' '), but I don't know what the right
 conditional statement is.  No matter what I put in there, it keeps
 processing any extra blank lines and putting an extra pair of p/p
tags
 in.  Granted, this doesn't effect the way the page is displayed.  For
 correctness sake, I'd rather not have them in there.

 Here's the simple page I threw together to illustrate the problem:

 html
 body

 ?php
 if ($submit) {

 $funk = explode(\n, $paragraph);
 foreach ($funk as $key = $sentence) {
 if ($sentence != ' ')) {
 $funk[$key] = p . $sentence . /p\n;
 echo $funk[$key];
 }
 }

 } else {
 ?
 pform method=post action=?php echo $PHP_SELF?
 Text:textarea name=paragraph rows=10
cols=40/textareabr
 input type=submit name=submit value=Mangle This
 /form/p
 ?php
 }
 ?

 /body
 /html

 Thanks in advance,
 Chris





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Running PHP as a cron job....

2001-07-09 Thread James, Yz

Thanks for all of your help on this.  My host admin have informed me that
php is installed only for the web, and not as a cgi, so that's what was
going wrong (it wasn't down to my own naievity afterall.)

So, it's time to learn perl (or bash).

Thanks again for all your comments and help.

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: how to hide dbconnect file if its in published directory?

2001-07-09 Thread James, Yz

Hi Noah,

if you make the include file a .php file, then the browser will parse the
code as a blank page whether or not they choose to look at the file, or
try to fopen(etc) it.  Problem solved ;)  At least I think that's
safe-ish...

James.

Noah Spitzer-Williams [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hey guys,

 I come for advice once again. Say i have a file dbconnect.inc which
 connects to my database. Now if this file is located in a directory
 accessible for to the web is there anyway that if someone types in that
file
 i can detect it being accessed, instead of included, and redirect them
 elsewhere?

 Thanks guys!

 - Noah





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: get a screen resolution

2001-07-08 Thread James, Yz

Hi Marc,

This is one for JavaScript, methinks.

html
head
titleScreen detection/title
SCRIPT LANGUAGE=JavaScript
!--

 function GetSW() {
  var sw = screen.width;

  return sw;
 }

 function GetSH() {
  var sh = screen.height;

  return sh;
 }

//--
/SCRIPT
/head
body

Your browser resolution is

SCRIPT LANGUAGE=JavaScript
!--

 document.write(GetSW() + ' by ' + GetSH());

//--
/SCRIPT

 pixels, so it's therefore recommended you view the site using this
resolution (or whatever's closes to it).

/body
/html

Marc van Duivenvoorde [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm trying to make a small browser and screen resolution script for my
 site, the browser part isn't a problem, but I can't find a function for
 screen resolutions, does anyone know whether such a function exists.

 Thanks,

 Marc van Duivenvoorde




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Running PHP as a cron job....

2001-07-08 Thread James, Yz

Hi all,

This is probably going to sound incoherant, but

Do I have to do anything (other than change the permissions of a php file)
to get it to run as part of a cron job?  I created an extremely simple file
that should just send a blank email to me (using mail()).  I got an email
from the cron daemon saying, bad token, or something like that, yet when
executed through a browser, the script behaves as it should.

Do I have to write the php scripts differently to how I would if they were
to be displayed in a browser?

Neeed...Slp ;)

Cheers,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Running PHP as a cron job....

2001-07-08 Thread James, Yz

Hi Ben,

When running it as a normal PHP file, I get the cron daemon emailing me
stuff like:

automation/mail.php: ?: No such file or directory
automation/mail.php: =: command not found
automation/mail.php: =: command not found
automation/mail.php: line 7: syntax error near unexpected token
`mail(emailaddress@takenout,'
automation/mail.php: line 7: `mail(emailaddress@takenout, mail test,
$mailcontent, $sender);'


When running it with the Perl style line at the top (as you suggested) I
get, no such file or directory.

The script is Chmodded to 755 in both cases.  And I saved it as a .php and
.cgi file (with the root to bin/php in it).  God knows what I'm doing wrong
;)

James.

 How are you executing the script?  Does it come by and run 'php
 yourscript.php' or does the script have a shebang ('#!/usr/bin/php') in
 it?  I've found that works well... just put that as the first line, and
 it behaves as a shell script (after you make it executable, of course)

 Ben

 -Original Message-
 From: James, Yz [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, July 08, 2001 3:39 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Running PHP as a cron job

 Hi all,

 This is probably going to sound incoherant, but

 Do I have to do anything (other than change the permissions of a php
 file)
 to get it to run as part of a cron job?  I created an extremely simple
 file
 that should just send a blank email to me (using mail()).  I got an
 email
 from the cron daemon saying, bad token, or something like that, yet
 when
 executed through a browser, the script behaves as it should.

 Do I have to write the php scripts differently to how I would if they
 were
 to be displayed in a browser?

 Neeed...Slp ;)

 Cheers,
 James.



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] include and include-virtual

2001-05-23 Thread James, Yz

Christian,

Those are SSI calls (Server Side Includes, for use with .shtml files).

Try:

include(/path/to/filename);
require(/path/to/filename);

I've never used these, but in PHP4 there are also:

include_once(/path/to/filename);
and
require_once(/path/to/filename);
(double check that I have gotten those function names right).

If you REALLY need to use something like exec cgi, I guess you could create
an shtml file with the command in, then include() or require() the shtml
file.

James.

Christian Dechery [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 What is the main difference between:
 !--#include ...
 !--#include virtual ...
 !--#exec cgi...

 the only one that seems to work for PHP files is 'include virtual'.
 'exec cgi' as well as 'include' gives me that message 'an error ocurred
 while processing this directive'...


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Uploading files

2001-05-20 Thread James, Yz

Hello Diego,

You need to use copy()


If the form input is like this: file: input name=userfile type=file
input type=submit

Then PHP will assign a few variables automatically to the file, which
include:

$file_name - actual name of the file (pic.jpg)
$file_size - size in bytes of the file
$file_type - MIME type of the file.

This:
input type=hidden name=MAX_FILE_SIZE value=1000Send this
Will only let you upload a file of less than 1kb if you program around that
(1024 bytes in a Kb). Setting to 102400 would give you a max upload size of
100 Kb.

So, simply:

?

if ($file_size  $MAX_FILE_SIZE) {
@copy($file, /path/to/dir/ . $file_name)
or die (Something's up.);
} else {
echo Sorry.  Your file was bigger than the allowed size of   .
round(($MAX_FILE_SIZE / 1024), 2) .Kb.  Please go back and try again.;
}

?

You can of course test whether the file being uploaded is a type you want,
like image/jpeg from the $file_type.

Hope this helps.

James.


Diego Pérez Rández [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 Hi to all:

 I don`t konw very well php. I do examples everyday and solve some
 problems. But in other i need help.

 Today i want to upload a file. I have the form that you can find in
 the php manual.

 form enctype=multipart/form-data action=_URL_ method=POST
   input type=hidden name=MAX_FILE_SIZE value=1000Send this
   file: input name=userfile type=file input type=submit
 value=Send File
 /form

 My problem is that i don´t know how to programe the php program that
 upload the file. I do a lot of examples, but not work.

 Can someone give me help.


 Thanks.


 Best regards, Diego


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Directory - exist or not ? :)

2001-05-15 Thread James, Yz

Hi There,

?

$dir_to_check = /this/dir;

if (!is_dir($dir_to_check)) {
echo No directory here;
} else {
echo Bingo.;
}

?

James.

Scream [EMAIL PROTECTED] wrote in message
9drq8v$ngb$[EMAIL PROTECTED]">news:9drq8v$ngb$[EMAIL PROTECTED]...
 Hi,

 I've got a one simple question. How I can check directory exist or not ?
 Plz, help me :) TIA !


 --
 regards, - scream - scream(at)w.pl
  ICQ#46072336 ||| GG#480681 
  Artificial Reins Productions 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] coding for 'no match found'

2001-05-15 Thread James, Yz

Or, try count() in the sql statement..

?

$sql = SELECT count(email) from table WHERE email = '$email';

$result = @mysql_query($sql);

if (mysql_result($result, 0, count(email)) == 0) {
echo No good.;
}

?

I think that's faster than:

?

$sql = SELECT email FROM table WHERE email = '$email';

$result = @mysql_query($sql);

if (mysql_num_rows($result) == 0) {
echo No good.;
}

?

Can't be sure where I read it, but still :)

Ack! 1.20am.  Bedtime.

James.

Johnson, Kirk [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 See http://www.php.net/manual/en/function.mysql-num-rows.php

 Kirk

  -Original Message-
  From: midget2000x [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, May 15, 2001 3:00 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] coding for 'no match found'
 
 
  This is a simple yet fundamental programming question I am
  hoping somebody will
  have the patience to explain...
 
  I have a mysql database with the email field as the key.
  Before inserting an
  new record to it I want to check if there is already a record
  with that e-mail.
   This I can do fine.  But this script needs to also handle
  delete requests,
  which I can also do fine, but I need to code for the instance
  that there is a
  delete request for an e-mail record that does not exist.  How
  can I figure out
  if after my 'while' loop is finished checking the database it
  has not found a
  match (so i can inform the requester as such)?
 
  Here's the code I have so far...
 
  $email_check_query = SELECT email FROM
  $tablename WHERE email = '$email';
  $email_check_result = mysql_query($email_check_query);
  while($email_query_data =
  mysql_fetch_array($email_check_result)) {
  $db_email = $email_query_data[email];
  //if match, it's an update or delete
   if ($email==$db_email) {
  if ($op==delete) {
  $action=del;
  echo delete
  requestbr;
  }
  else {
  $action = upd;
  echo update
  requestbr;
  }
  }
  } //end while loop
 
   ---
  providing the finest in midget technology
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail:
  [EMAIL PROTECTED]
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_trouble (check fast!)

2001-05-08 Thread James, Yz

Hi Fredrik,

Always check whether or not the required variables are there BEFORE querying
the database.  And make sure that the negatives are dealt with first.
That's my opinion.  I'd probably also check whether the original username /
password is in the database before proceeding.  Probably more work on the
db's part than needed, but still.  Gotta make sure everything's correct:

?

if (!is_set($new_password)) {
echo You haven't assigned a new password. Please go back.;
} else {
$sql_check = SELECT id FROM users WHERE username = '$username' AND
password = '$password';

$result_check = @mysql_query($sql_check, $connection)
or die (some graceful error);

if (mysql_num_rows($result_check) == 0) {
echo The username and original password you entered did not match
anything in the database. Please go back and try again.;
} else {
$sql_update = UPDATE users SET
password = '$new_password'
WHERE username = '$username';

$result_update = @mysql_query($sql_update, $connection)
or die(Another graceful error.);

echo Your new password has been saved.;
}
}

?

James.

FredrikAT [EMAIL PROTECTED] wrote in message
9d9jll$fic$[EMAIL PROTECTED]">news:9d9jll$fic$[EMAIL PROTECTED]...
 $na_pw is the active password...
 ..if pw is blank or wrong i want to output a error message...
 ...iknow that I could do if (empty($na_pw) and $na_pw  $pw), but then I
 would have to send another query to MySQL..

 I thought that q_updateresult would say (when i echo) 0 when password is
 bad, but it echos 1.

 Any tips?

 CODE:
 $q_updatequery = UPDATE brukerinfo SET navn=\$ny_navn\,
tlf=\$ny_tlf\,
 pw=PASSWORD('$ny_pw') WHERE brukerID=\$id\ and pw=PASSWORD('$na_pw')\n;

 $q_updateresult = mysql_db_query ($db, $q_updatequery);

 -
 Fredrik A. Takle
 [EMAIL PROTECTED]




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] MySQL select rand() with weighting?

2001-05-03 Thread James, Yz

Hi Guys,

Does anyone know how to select one field randomnly from a MySQL table
against a weighting column in the same row the field is selected from?

For example, SELECT id, url, image FROM table ORDER BY rand() LIMIT 1.

And have a column like weighting where values between 1 and 100 are held -
The larger values making it more likely that they're going to get pulled
out.  So say I have three rows in the table, one weighing 100, the others
weighing 50, the one weighhing 100 stands a better chance of being selected
randomnly?

I know I've not explained this too well, but hopefully *someone* will know
what I'm rambling on about ;)

Thanks as always,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] String delimeters, arg!

2001-05-01 Thread James, Yz

Hi Nick,

to delete a cookie, simply use set_cookie(cookie_name); without appending
any values.

Possible solutions for the \t and \n :

For \n to br, use:
$string = nl2br($string);

Not sure whether or not there a similar function for \t, though you could
perhaps use some method to replace \t with nbsp; * 4.  I'm not sure
something like:

$string = ereg_replace(\t, nbsp;nbsp;nbsp;nbsp;, $string);

would be too clever, just in case someone typed \t rather than ereg_replace
/ preg_replace recognising it as a Tab.

It's getting too late to do any serious thinking. :)

James.

Nick [EMAIL PROTECTED] wrote in message
005601c0d275$bfc88510$4c8d7018@cr279859a">news:005601c0d275$bfc88510$4c8d7018@cr279859a...
Hello PHP'ers

I am having a problem with string delimiters. For some reason no matter what
I do I can not get them to process correctly!!
For example,

?
$area_entered = yes;
$date_entered = no;
echo $area_entered\t\t\t$date_enteredbr;
?

That outputs:
yes no

What am I doing wrong?! Is there something I need to set in the php.ini
file? I would like to be able to type \n instead of br repeatidly!

Also, when working with cookies, if I have a cookie that is set by,

if (!isset($cookies)) {
//Set Cookies
$cookie_user = setcookie (username, $row[user], time()+86400, /,
localhost);
$cookie_pass = setcookie (password, $row[pass], time()+86400, /,
localhost);
$cookie_step = setcookie (step, 1, time()+86400, /, localhost);
$cookies_set = setcookie (cookies, y, time()+86400, /, localhost);
}

Is there a way to unset the cookie? Perhaps by,
$cookie_set = setcookie (cookies,);
?

Thanks for your time,

Nick




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] simple querying mysql in a WML card problem :(

2001-04-25 Thread James, Yz

Hi Sandeep,

The br tag looks like this in wml: br/

Have you escaped the doublequotes correctly in your double quoted echo 's?

Make sure that the database doesn't contain ampersands, or dollar signs, or
some of the foreign lettering (like é), as they are illegal characters in
wml (well, the dollar sign is used for variables, like PHP, but WML can't
accept them as part of a string as PHP does).

Ways to work around:

$string = ereg_replace(, , $string);

or

$string = ereg_replace(, amp;, $string);

To get a dollar, use two dollars:

$string = ereg_replace($, $$, $string);

That's about as much I can suggest, without actually playing with the script
myself  And I am too tired for that. :)

James

Sandeep Hundal [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hi all!

 i'm trying to get simple 2 line results from mysql in a wml card, but
 i can't seem to manage it. here's my code:


 ?
 header(Content-type: text/vnd.wap.wml);
 header(Cache-Control: no-cache, must-revalidate);
 header(Pragma: no-cache);
 echo (?xml version='1.0'?);
 ?

 !DOCTYPE wml PUBLIC -//WAPFORUM//DTD WML 1.1//EN
 http://www.wapforum.org/DTD/wml_1.1.xml;;


 ?
 include (db.php);
 $query1 = SELECT club FROM table WHERE day='monday' ;

 echo 
 wml
 card id=card1 title=clubbing by day
 p;

 $result1 = mysql_query($query1);
 if ($result1) {
 echo  $day br;
 while ($r1 = mysql_fetch_array($result1)) {
 extract($r1);
 echo $clubdetails br;
 }
 }

 mysql_free_result($result1);

 echo  /p
 /card
 /wml;

 ?

 simple? yet all it seems to give m is :
 
 ; = mysql_query( if ( { echo 
 ; while ( = mysql_fetch_array( { extract( echo 
 ; } }mysql_free_result( 
 -

 in my emulator (WinWAP).

 Any help greatly appreciated!

 /sandeep

 
 Do You Yahoo!?
 Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
 or your free @yahoo.ie address at http://mail.yahoo.ie

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] SQL Query time?

2001-04-25 Thread James, Yz

Hi all,

I have seen a few pages that echo the time it's taken to execute an SQL
query, like The results in the database were returned in 0.3 seconds.
Anyone know if there's a built in function to display this, and if there is,
what it is?  My more-than-useless-ISP seems to have taken an aversion to
allowing me to surf tonight without disconnecting me.

Thanks.
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Incrementing dates

2001-04-21 Thread James, Yz

Hiya Martin.

You'd probably be better working around a database solution to your needs,
but I am a bit drunk (and probably can't sensibly attempt to answer your
question properly), but it got me thinking, so I decided to have a play with
date incrementations.  If anyone has any comments on this, I'd like to hear
them (there's probably a simpler way around what I have done).  Here's the
URL:

http://www.yorkshire-zone.co.uk/date_increment.php

And here's the code that powers it:

HTML
BODY

?

$date = date(2001-04-28);
list($year, $month, $day) = explode(-, $date);

$actual_date = mktime(0,0,0,$month,$day,$year);

$days_to_add = 7;

$x = 1;

while($x = $days_to_add) {

 $make_date = getdate($actual_date);

 echo Day $x: $make_date[mday] $make_date[month],
$make_date[year]BRBR;

 $actual_date = $actual_date + (3600 * 24);

 $x++;

}

?

/body
/html

Cheers,
James

- Original Message -
From: Martin Skjöldebrand [EMAIL PROTECTED]
Newsgroups: php.general
Sent: Saturday, April 21, 2001 11:06 PM
Subject: [PHP] Incrementing dates


 How do I increment dates past the turn of the month (or year)?
 Say I've got a booking of equipment A for the 28 April to 5 May and want
to
 add each instance to a calendar (mysql table).
 Can I increment the variable (format 2001-04-28) holding the date
 ($txtDate++) somehow so that it doesn't add the 31, 32 and 33 of April?

 Martin S.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] SQL Select Unique() ?

2001-04-19 Thread James, Yz

Hi Guys,

Is there a method of extracting rows from a MySQL table Uniquely (as in only
once) ?. For example, when a user performs a search, using two words,
it may return the same row twice if the search is spread over two or more
SQL "selections".  An example:

If hypothetical row 129 is a Public House, but the public house doubles up
as a restaurant, a search like this might return the same result twice.
Here is our hypothetical pub:

id = 129
name = The Blue Bell Inn
category = Public House
description = The Blue Bell Inn is a hypothetical pub, in the heart of rural
England.  Why not visit, have a drink and perhaps even dine in our fine
Restaurant area.

The user might perform the search, searching by "category" OR by
"description".  So if they typed "Public House / Restaurant" as the query,
the following would occur:

$sql = "SELECT * FROM table WHERE category LIKE 'Public House / Restaurant'
OR description LIKE 'Public House / Restaurant'";

Surely that would bring the same row back twice.  Is there any way of
selecting from the table just once, without having to restrict the search
facility to something like:

"SELECT * FROM table WHERE category LIKE '%$searchtext%'";

as opposed to having the "OR" in as well?

Thanks, as always,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] SQL - Select rand() ?

2001-04-17 Thread James, Yz

Hi Guys,

If I wanted to retrieve just one field randomly from a MySQL table, would I
just use something like:

"SELECT RAND(id) FROM table  LIMIT 0,1" ?

I suppose the best thing for me to do would be to try it, but I am fast
losing the will to stay awake ;)

Thanks, as always,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problems with string replacement

2001-03-11 Thread James, Yz

Hello all,

Well, I'm having problems again.  This time with string replacement.  I'd
like people to be able to write notes on one of the site's I'm helping with,
and would like them to be able to use Bold, Italic, Underline and a href
tags.  I tried using striptags(); but that would strip anything within
double quotes too.  So I've gotten around it by converting the message
string to htmlspecialchars and then using ereg_replace around the tags I'd
like to allow, ie:

$message = ereg_replace("lt;ugt;","u", $message);

Where I'm struggling is with the a href tags, though.  I've been using this:

$message = eregi_replace("(lt;a
href=quot;)(http://[^[:space:]]{1,})(quot;gt;)(.*)(lt;\/agt;)", "a
href=\"\\2\" target=\"_blank\"\\4/a", $message);

which would change a string containing:
a href="http://www.php.net"PHP!/a
to:
a href="http://www.php.net" target="_blank"PHP!/a

Great.  But, there's a problem.  If someone uses:
a href="http://www.php.net" target="_blank"PHP!/aa
href="http://www.php.net" target="_blank"PHP Again!/a
it returns:
a href="http://www.php.net" target="_blank"PHP!/agt;lt;a
href=quot;http://www.php.netquot;PHP AGAIN!/a

Ouch!

Anyone got any ideas where it's going wrong?

Also, for the html that isn't allowed, it'd be nice to have some sort of
cleanup, so that something like this:

blahBLAH/blah

Would be returned as BLAH.  But not essential :)

Thanks in advance,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Problems with string replacement

2001-03-11 Thread James, Yz

 Well, I'm having problems again.  This time with string replacement.
 I'd like people to be able to write notes on one of the site's I'm
 helping with, and would like them to be able to use Bold, Italic,
 Underline and a href tags.  I tried using striptags(); but that would
 strip anything within double quotes too.  So I've gotten around it by

 huh? strip_tags works fine for me.

 echo strip_tags ('Hello a href="http://foo/"bar/a
 "world"bremthere/em', 'a br');

 creates

 'Hello a href="http://foo/"bar/a "world"brthere'

True, but then it doesn't:
-Open the link in a new window
it does:
-remove all content between "and".

Of course, I could replace quote marks with htmlspecialchars/entities or
using manual string replacement, but then it'd render all tags using quote
marks invalid.

See the problem? ;)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] while loop and modulus?

2001-02-27 Thread James, Yz

OK, using this code:

?

echo "table border=\"0\"\n";
echo "tr\n";

$photocount = 0;

while($row = mysql_fetch_array($result)) {
 $smallpic = $row['smallpic'];

 echo "td$smallpic/td\n";

 if (($photocount % 3) == 2) {
 echo "/tr\ntr\n";
 }
 $photocount++;

 }

echo "/tr\n";
echo "/table";

?

And 8 photos in the table, I'm getting this output:

table border="0"
tr
tdsm982438092.gif/td
tdsm982437452.gif/td
tdsm982439016.gif/td
/tr
tr
tdsm982529915.gif/td
tdsm983222652.gif/td
tdsm983222686.gif/td
/tr
tr
tdsm983222868.gif/td
tdsm983222919.gif/td
/tr
/table

Great, except it's missing an end cell, and after a few hours fiddling about
with code last night, I still didn't get any further in working out how I
was going to echo a table cell even if data's missing.  So, any help would
be appreciated.

Apologies for what're probably "easy" questions.  I slog away at work all
day, come back hoping to get something productive done on this, and the
ol'brain won't take it.  Frustrating, to say the least.

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Table looking odd as a result of while loop?

2001-02-26 Thread James, Yz

Hi all,  This is probably something dumb I'm missing, but I am using the
following code:

echo "table border=\"0\"\n";

echo "tr\n";
$photocount = 0;

while($row = mysql_fetch_array($result)) {
 $smallpic = $row['smallpic'];

 if (($photocount % 3) == 2) {
 echo "/tr\ntr\n";
 }

 echo "td$smallpic/td\n";
 $photocount++;

 }

echo "/tr\n";

echo "/table";

and it's outputting a table like this:

table border="0"
tr
tdsm982438092.gif/td
tdsm982437452.gif/td
/tr
tr
tdsm982439016.gif/td
tdsm982529915.gif/td
tdsm983222652.gif/td
/tr
tr
tdsm983222686.gif/td
tdsm983222868.gif/td
tdsm983222919.gif/td
/tr
/table

(There are currently 8 pics that have been uploaded).  As you can see that
the first row has returned just two columns.  I'd like the photos to be
displayed in rows of three, and if there are only 8 pictures (or any othe
number that's not directly divisible by three) to be displayed on the last
row.   At the moment it's doing it "upside down."  Any ideas?

And I know, I'm going to have to force an extra cell for it to display
correctly


Thanks as always,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Maximum queries from a database?

2001-02-25 Thread James, Yz

Hi all,

I'm a little concerned as to how many times some of the scripts I've been
working on are querying a database:  Some are making up to 4 or 5 queries
each.  Should this give me any cause for concern?

I've only ever been unable to connect to the database once (other than
through script error), and that's when I was using a persistent connection.
So, I guess my question is, is there a recommended maximum number of queries
I should be working around? (MySQL).

Thanks,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to delete session variables

2001-02-20 Thread James, Yz

I thought that session variables (unless set to cookie as well) WERE
destroyed at the end of a session?  As in when the user closes the browser?

Hrms.  Maybe not.

Anyway, don't know about when the window is closed, but you could have a
log-out page that uses session_destroy();

James.


 I would like the session variable to be deleted when the user closes their
 browser. Any ideas on how this is done.


 Ryan Conover

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Simple REGEX?

2001-02-17 Thread James, Yz

Hi guys,

I'd like to restrict the characters a client is inputting to a database.

I already have a system that'll exclude certain characters.  Alpha Numerics
are permitted, together with the underscore and spaces.  Is there a
collective expression for the following characters? :

!",.?@()

Because I'd like to allow those too.  And I'm useless with RegEx.

Thanks as always,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Finding the? in $REQUEST_URI?page=blah

2001-02-16 Thread James, Yz

I really wouldn't ask this if I wasn't completely exausted, but the last
thing I feel like doing just now is reading up on this when someone can
probably answer it in a matter of seconds.

OK, I've an error handling page.  Basically, I want to split (that might
even be one of the functions I'll have to use) this sort of url:

error.php?/pages/login.php?username=name

into:

/pages/login.php

I'm using :

header("location: error.php?page=$REQUEST_URI");

When echoing the request_uri back on the error page, it omits the error.php?
bit, so I get:

login.php?username=name

The reason I want to do this is so that I can use a re-login form that will
submit to the page the user has badly logged into, so if they logged in to
main.php, the request_uri would be something like:

/pages/main.php?username=name

Which I'd want to rebuild on the error page, into a form, like:

form method="post" action=? echo "$REQUEST_URI"; /* Minus the suffix the
page may include */ ?"
Username: input type="text" name="username"r
etc/form

Can anyone help?

Thankees :)

James.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] splitting up contents of a test box

2001-02-16 Thread James, Yz

If each of the scrolling lines is separated by something regular, like a
carriage return, or a line break, tab (etc), you could use explode(); and
have the values returned as an array.

James.

 I have a form that contains a scrolling text box.  When I display the
 contents of the text box, say in variable $form[mytextbox], it displays
 all on one line (or wraps at end of line).  As the ending character of
 each line will vary, does anyone know of away to split the lines up so
 that I can display the text box contents line by line?

 Thanks,
 Don


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] case sensitivity checking?

2001-02-15 Thread James, Yz

Hi Guys,

Just a quick question.  If I have a user database, with joe_bloggs as a
user, what would I need to do to make sure that his login details matched
the case sensitivity in a MySQL database?  Say if he logged in as
JOE_BLOGGS, could I return an error?  I'm guessing this is going to turn
into some complicated regex that mashes my brain.

Oh, another thing.  Anyone know of any tools like PHP MyAdmin for
PostGresSQL ?

Thanks,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] case sensitivity checking?

2001-02-15 Thread James, Yz

 make the login field BINARY.

Thanks! ;)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] returning multiple variables from a function?

2001-02-12 Thread James, Yz

Hrms.  Got a small problem.

I'm now using functions on a regular basis, but I've come to another
sticking point with them:  returning multiple variables from the function...

Here's a really quick example (nothing to do with what I intend to use the
functions for):

function CUP ($connection,$username,$password) {

if (($username)  ($password)) {
$sql = "SELECT username, password FROM table
WHERE username = '$username' AND password = '$password'";
$result = etc etc
$num = mysql_numrows($result);

if ($num != 0) {
$valid = "yes";
}

return $valid;

}



$correct_user = CUP ($connection,$username,$password);

Now, if the user is correct, I'd get a return of

$correct_user = "yes";

What if I wanted to "return" more than one variable from the function?  And
how would I assign it a name?  Like the actual variable, or is that just not
possible?

I've tried
return $var1,$var2;
But got an error.

As always, tia :)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting MIME-type of file

2001-02-08 Thread James, Yz

 Oops, I forgot to mention the most important part...
 I need to get the MIME-type (or something that can identify the
 file-extension) from a file ALREADY on the server, not posted through a
 form.
 I.e. How do I get the MIME-type of "tobias.zip" in my folder?

 I already know how to get the MIME-type from a form...
 Thanks for the nice snippets though. They might come in handy in the
future.

Just knocked this together.  It doesn't confirm whether or not the files are
actually valid MIME types (like .zip).  For instance, you could upload a
text files, rename it to .zip and it will list it (if you change the
following $required_types variable I've put in here:

__

html
head
titleLooking MIME types?/title
/head
body

Here is a listing of the directory I want to be looking in and all of the
files in it.  If the files are listed below, they're the ones I want to
know.

ul
?

$directory = "/path/to/directory/";
$dir = opendir($directory);

/* Change to the types you want */
$required_types = array(".gif",".jpg");

while($MIMEfile = readdir($dir)) {

$extension = strrchr($MIMEfile,'.');

 if(($MIMEfile != ".")  ($MIMEfile != "..") 
(in_array($extension,$required_types))) {
  $filetype = filetype($MIMEfile);
  echo "li$MIMEfile";
}

}

?
/ul
/body
/html



Note that this probably isn't the best way to go about things, but I've had
a quick root through the file() functions, and could find nothing (though I
didn't look too hard) quick and easy.

Have fun.
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] radiobutton

2001-02-08 Thread James, Yz

If someone's updating a form, and I want their last settings to appear in a
the correct radio button, I use this:

input type"Radio" name="I_like" ? if ($I_like == "PHP") { echo "CHECKED" }
?
input type"Radio" name="I_like" ? if ($I_like == "ASP") { echo "CHECKED" }
?

So, on a form with a Radio button asking which you prefer, the one that
they've voted for before is the default button to be checked.

Oh, and I know that's probably messy :)

If you want to get the results, you'd print

The user liked ? echo "$I_like"; ?!

James.



Hello,
I have sometging like this:
input type="Radio" name="radio1" value=? echo $opt1 ?"Opt1

how I know if some user choose some radiobutton???
I tried if($opt1) , but without success

T.Y.

Miguel Loureiro [EMAIL PROTECTED] 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] security help

2001-02-08 Thread James, Yz

Make sure that the .htpasswd file is BELOW the public files root.  That way,
it can't be accessed through a browser, unless the person who has written
the file to try and read the .htpasswd has uploaded their file to the server
it resides on, and has permission to access that low level directory.  They
can't read files in a directory route, unless they're in the directory:  So
a URL reference won't work.  If you've uploaded the .htpasswd to /www/admin
They could do an include for:

?
include(http://www.yoursite.com/admin/.htpasswd);
?

..So:

/home/myfiles/.htpasswd

Rather than

/home/myfiles/publicwwwfiles/.htpasswd

Hope that's of some use to you.
James.

""Thor M. Steindorsson"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Should this be possible?
 I know this isn't an issue with php, but since I used php to do this, I
 figured maybe someone here has encountered the same thing, and knows how
to
 help.
 Is this something that can be fixed by making some changes on the linux
 server?

 By using this:

 ?
 echo "pre";
 include("/home/someuser/www/admin/.htaccess");
 echo "/pre";
 ?

 I can see what .htpasswd file is used, and then I can simply change the
code
 to display that particular password file, then take the encrypted
password,
 and decrypt it to gain access to that protected area.

 I have a feeling this is a permissions issue on the Linux server...
 Can anyone point me in the right direction with this?


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] security help

2001-02-08 Thread James, Yz

In addition,

(if using .htaccess) They would only be able to read the .htpasswd from
public directory if they had first authorised themselves.  The browser will
prompt them to identify before it allows files from a protected directory to
be included.

J.

 Make sure that the .htpasswd file is BELOW the public files root.  That
way,
 it can't be accessed through a browser, unless the person who has written
 the file to try and read the .htpasswd has uploaded their file to the
server
 it resides on, and has permission to access that low level directory.
They
 can't read files in a directory route, unless they're in the directory:
So
 a URL reference won't work.  If you've uploaded the .htpasswd to
/www/admin
 They could do an include for:

 ?
 include(http://www.yoursite.com/admin/.htpasswd);
 ?

 ..So:

 /home/myfiles/.htpasswd

 Rather than

 /home/myfiles/publicwwwfiles/.htpasswd

 Hope that's of some use to you.
 James.

 ""Thor M. Steindorsson"" [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Should this be possible?
  I know this isn't an issue with php, but since I used php to do this, I
  figured maybe someone here has encountered the same thing, and knows how
 to
  help.
  Is this something that can be fixed by making some changes on the linux
  server?
 
  By using this:
 
  ?
  echo "pre";
  include("/home/someuser/www/admin/.htaccess");
  echo "/pre";
  ?
 
  I can see what .htpasswd file is used, and then I can simply change the
 code
  to display that particular password file, then take the encrypted
 password,
  and decrypt it to gain access to that protected area.
 
  I have a feeling this is a permissions issue on the Linux server...
  Can anyone point me in the right direction with this?
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] To The Hacker: CodeBoy

2001-02-08 Thread James, Yz

Many hackers now go about their business to notify (or even test)
administrators whether or not they've been up to no good.  It's possible
that you've mis-construed what he was up to.

Nevertheless, your complaints should really go to the correct authorities
(your server, the "hacker" and if necessary, beyond that), as opposed to
questions, which might include "I've got a security problem with PHP, what
can I do about it?"

James.

 The hackers name is Jonathan Sharp.  He is a
 regular member of this mailing list.  I do
 believe that people here would like to know they
 have a hacker on their hands, don't you think?
 It would appear the friendly Jonathan has another
 side to himself...

 Codeboy:
 Jonathan Sharp
 Director of Technology - Imprev Inc.
 Renwick Development Group - Flyerware
 [EMAIL PROTECTED]



 --- James Moore [EMAIL PROTECTED] wrote:
 
  
   Today I noticed an entry in my database with
  the
   username "codeboy" and the password "hacked"
  in
   one of the authorization tables I have
  created.
   I am shocked that someone could be so
  malicious
   and insensitive!  I am programming locally; I
   realize there may be some security
   vulnerabilities during this time, but when I
  go
   live with my network this will not be the
  case.
   If any further attempts are made to hack into
  my
   system I will clearly take the time to
  retaliate
   against you.  Let this be your only warning.
  
 
  This is not the place to take these issues up.
  Please email privatly and
  complain to the appropriate authrities, the
  PHP-General list is not the
  place for this.
 
  James
  --
  James Moore
  PHP QA Team
  [EMAIL PROTECTED]
 


 =
 =
  [ rswfire ]

   http://rswfire.swifte.net/
   http://profiles.yahoo.com/rswfire

 =

 __
 Do You Yahoo!?
 Get personalized email addresses from Yahoo! Mail - only $35
 a year!  http://personal.mail.yahoo.com/

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] [Newbie] PHP Variables

2001-02-08 Thread James, Yz

// Index.php file.

//  Page header

?

if ($contents == "HOME") {
include("home.inc");
} else {
include("someothercontent.inc");

?

// Page footer

...  Difficult to tell what's going wrong with just a url.

James.

 I thought you can pass variables in PHP as in CGI.

 http://www.xy.com/index.php?contents=HOME

 contents should be available as variable, but it does not seem to work.
Doe
 anyone has an idea why not?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] security help

2001-02-08 Thread James, Yz

  In addition,
 
  (if using .htaccess) They would only be able to read the .htpasswd from
  public directory if they had first authorised themselves.  The browser
will
  prompt them to identify before it allows files from a protected
directory to
  be included.
 

 James,

 are you sure about this? Afaik, no user authentication applies to PHP
 include() calls. This would require PHP to integrate much closer with
 Apache than I think it does (and makes sense).

Hi Ben,

I'm not positive, (btw, what does Afaik mean?), but I'd assume any request
to files that are inside a directory that has an htaccess file would be
ignored by anything until the username and password have been included (I've
used a PHP include on files before, which refer to files such as jpegs and
gifs that reside in a protected directory, and I've run into the problem of
having to authenticate before the images are displayed).

There's a good chance I'm wrong, but I'll be sure to double check tomorrow
morning.

On another note, I seem to have problems with opendir() and readdir() (which
one of the two I'm not sure).  A simple script I've written will list all
files in a directory I specify on one server, yet the same script (with the
document root changed accordingly) will return  nothing with the other.
Both servers are running the same version of PHP (4.02).  It's probably
something simple I've missed, though I'm sure that the CHMOD settings are
the same, and I'm getting no script errors.  Any ideas?

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ftp_fput

2001-02-08 Thread James, Yz

I've no idea what's wrong with this, and I'm a little tired to try and look
into it, but omit any username / password / server info from anything you
post anywhere that's accessible publicly! ;)

James.

""Marisol Díaz E."" [EMAIL PROTECTED] wrote in message
008301c09225$4ce07e80$[EMAIL PROTECTED]">news:008301c09225$4ce07e80$[EMAIL PROTECTED]...
Hi

Please help me

I don't knowk that is wrong, in this code, for ftp_fput
Don't copy the archive, when copy the archive , this has other extension,
and the size is 0kb.



?
$fp = ftp_connect('192.168.57.2', 21);

$con = ftp_login($fp, "mdiaz", "root1997");

$destino="public_html/abyayala/ftp/ftp";

$desti=ftp_chdir($fp,$destino);

$archivo="C:\\abm\\Abm.gdb";

$fpr = fopen ($archivo, "a+");

 $subir=ftp_fput($fp,$archivo,$fpr,FTP_BINARY);

fclose($fpr);

ftp_quit($fp);

?

Thanks.

Marisol Díaz E.




Marisol Díaz E.
Gerente de Aplicaciones Internet
Tecnopro Cía. Ltda. www.tecnopro.net
Pinta 236 y Rabida Edf. Alcatel of. 301
(593-2)508-722





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] To The Hacker: CodeBoy

2001-02-08 Thread James, Yz

  Whatever, James.

 Also, consider this word :

 sue

 As well as :

 defamation of character

 And also   :

 Libel and Slander

 And lastly :

 Spoof

 All should be considered before posting anything anywhere.  Especially a
 public mailing list.  It's important to be careful with this sort of
 thing, even if it's blindingly true ...

True, but none of which are applicable to me, as I've not slandered, defamed
or spoofed anything or anyone.  As far as hacking is concerned, I wouldn't
know my arse from my elbow :)

James



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] To The Hacker: CodeBoy

2001-02-08 Thread James, Yz

 Your momma pays full commission!

 (sorry, couldn't resist)

It's OK, I get referral fees :)



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ? for the Reg Ex people

2001-02-07 Thread James, Yz

look up eregi_replace and preg_replace

www.php.net/quickref.php

Gotta run

J

"Jason Bryner" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm making a small script that imports HTML pages and I need to do
 some string replacement. I need to replace add a url to all the 'HREF'
 links and images, but if someone could just give me an example of how
 to replace and append the HREF part, I think I can figure it out. It needs
to
 find all the variations of HREF, such as 'HREF = "', href="', 'href =',
etc.
 So it
 needs to be space and capitalization carefree. THANKS TO ANYONE
 WHO HELPS!!!

 Jason Bryner
 [EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Automating tasks in PHP?

2001-02-05 Thread James, Yz

Hi all.  This is, what might turn out to be a stupid question  But I'll
ask it anyway ;)

Is there any way of automating tasks in php scripts, WITHOUT having them
open?  Ie, having some method or other to send out an email automatically,
once a week, as a newsletter, based on data / criteria from a database?

Thanks for your patience,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] htaccess

2001-02-05 Thread James, Yz

This is a good one:

http://www.zend.com/zend/tut/authentication.php

James.

 there was a really good .htaccess tutorial posted to the list a while
 back...anyone remember the address?

 ~kurth


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP Hosting

2001-02-03 Thread James, Yz

I believe http://www.f2s.com allow you to use PHP and provide you with a
MySQL database.

James.

 Can anyone receommend free MySQL hosting with PHP. Or if you can find such
a
 hosting on NT, that would be nice.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Querying MySQL using 'AND' / 'OR'

2001-02-03 Thread James, Yz

Hi Guys,

Quick question..  I've managed to write a function (thanks to help from
people earlier in the week) which queries an admin table.

There are currently four fields in the table;  id, username, password, and
'site', where the 'site' means a subdirectory of my site that the particular
admin user is allowed acces to change things in

Now, each 'site' user is allowed access to only their site, but, being the
owner of all the 'sites', my field contains the word "all."  So, I used this
to determine whether the user (when logged in) is firstly an administrator,
and secondly what area of the site they're responsible for:

$sql = "SELECT * FROM table
WHERE username = '$username' AND password = '$password' AND site =
'theirsite' OR site = 'all'";

Now, as you can probably see, the table is querying whether the table has a
row with fields:

username, password, site OR

Just a row with the field containing "all."

So, without writing some if statements, is there any way of rewriting that
$sql check so that it checks whether the user is an admin of either the
individual subdirectory, or all of the sites?  Like

username: foo  password: bar site: all

or

username: foo  password: bar site: subdirectory

.  Hope that makes sense, and thanks in advance for any help :)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Retrieve HTML page

2001-02-01 Thread James, Yz

In addition to what's been mentioned, check out the :

readfile, fread and fgets functions...

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] void function();

2001-01-30 Thread James, Yz

Hi there all,

Very dumb question  I just read one of the quickref functions, and the
in-built function is referenced as being :

void function(integer);

What does the void mean?  And how would I use the function?  I just get a
parse error when I use the function with the "void" in it and the "called to
undefined function" (even with an integer) when I omit the "void."

I'm not completely brain dead as to not understand what  the word "void"
means, but the more I'm reading through things, the more confused and sorry
for myself I'm getting ;)  I just guess I could do with having it explained
to me in plain English.

Thanks in advance,

James.







-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Importing MS Access into MySQL?

2001-01-29 Thread James, Yz

Hey all,

I heard somewhere (I think) that it's possible to import a Microsoft Access
file (when saved as a delimited text file) into a MySQL table  Just
wondering whether or not this is true, and if it is, where I might find a
tutorial / some literature on how I might go about doing it.

Thanks, as always, in advance :)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Outputting specific HTML for table tag.

2001-01-22 Thread James, Yz

Hey all.  well, here's (probably) an easy question from me again (surprise
surprise).

Here goes:  I'm putting together a photo gallery for some friends of mine
who own a nightclub, and who want to update photos themselves. I know
there are scripts available to do the job, but I'd like to have a go at my
own.

Most of the stuff I can handle, but I just need to know what code I might
use for returning table cells correctly.  Let's say, for example, there are
5 photos that need returning to one of the photo pages, and I have the
photos in rows of three;  Obviously, there'd be an empty table cell.  And
I'm not sure exactly how I get the results back into rows correctly
anyway...  Bullet points and whole table rows are fine, but table cells?
Hrms.

Anyway, here's how I might've started writing the code, if I hadn't realised
I should ask for help first ;) :

?

//  Connection code

$table = "table border=\"0\" /* Yadda Yadda */ ";

while($row = mysql_fetch_array($result)) {

$row = $photo['photo'];

$table .= "trtd$photo/td"
$table .= "td$photo/td/tr";

}

$table .= "/table";

//  End Crap programming.

?

So.  Any takers?  :)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Basic SQL syntax

2001-01-15 Thread James, Yz

OK, I got a simple search page working (thanks to all of you who helped me).

Another simple question for you.  If I had a search  and the data to be
searched needs to be determined by check boxes, How would I write the sql?
Like this?

$sql = "SELECT * FROM table
  WHERE town LIKE '%$search_data%' OR street LIKE '%$search_data%' ";

Is "OR" even the correct syntax?  Here's how I tried it, which didn't give
any results.

(Where reference is the id number (or map reference) and search_data is the
text field for users to tpye the query.

if ($reference != "")
$search_reference = "OR id LIKE '%$reference%'";
}

$sql = "SELECT * FROM table
  WHERE town LIKE '%$search_data%' $search_reference";

$result = @mysql_query($sql,$connection)
 or die (mysql_error());

$num = mysql_num_rows($result);


TIA,
James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Basic SQL syntax

2001-01-15 Thread James, Yz


""Johannes Janson"" [EMAIL PROTECTED] wrote in message
93vs9u$osj$[EMAIL PROTECTED]">news:93vs9u$osj$[EMAIL PROTECTED]...
 try this:
 $sql = "SELECT * FROM table
   WHERE town LIKE '%$search_data%' ";

 if ($reference != "")
   $sql .= "OR whatever";


Ah, so you can constantiate (right word?) the query?

Cool, Thanks ;)

James.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Basic SQL syntax

2001-01-15 Thread James, Yz

  Ah, so you can constantiate (right word?) the query?

 I don't know what you mean by 'constantiate', but glad to hear it worked

It did, thank you ;)

Someone pointed out where I'd gone wrong with the word privately:

 Ah, so you can constantiate (right word?) the query?

 concatenate :)




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Two little questions

2001-01-14 Thread James, Yz

OK, this will be laughably easy for you guys.

I want to write a function (until now, I have been heavily repeating code,
but it's time to trim everything down.)

The function basically needs to check that username and password have been
entered, and then check them against mysql data.  All I am unsure of is the
format for the function...  is it like this:

function CUP (
if ((!$alias) || (!$password)) {
header("Location: login.php");
exit;
}
);

And reference it later with CUP(); ?  Don't worry about the MySQL side of
things, I just need to know how to lay out the function.  Oh and if I can
put anything I want in the function.

Also, if I wanted to perform a search of a column in a mysql table for
"places", would the Syntax be something like this:

$sql = " SELECT * FROM table_name
WHERE place = LIKE \"$searched_word\" ";

?

Thanks in Advance,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Searching a MySQL database?

2001-01-14 Thread James, Yz

Can anyone tell me what I would use to query a MySQL database in a search?

If the search field, was for example, a variable like "town", would the
results page use something like this? :

$sql = " SELECT * FROM table_name
WHERE towns = \"$town\" ";

I remember seeing someone post something like this:

$sql = " SELECT * FROM table_name
WHERE towns LIKE \"$town\" ";

so if the search word is not EXACTLY like a row in the database, it may
return results to partial words.

Thanks in advance,

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Another q, this time eregi_replace

2001-01-14 Thread James, Yz

I'd like to be able to trim out some html tags, but only certain ones.  I've
used eregi_replace before and have some replacements running on some
scripts...

Some of the help pages and user notes on the quick reference functions have
given me good examples of how to go about it.  One thing I'm interested in,
though, is the syntax that's used to determine what the link URL is and the
link name...  I think I saw it as:

//0 for the URL and then //1 for the link.  Like this (poor code, I
dunno whether I've even got the right delimiters):

eregi_replace("/a href=\"//0\"///1///a/\","//1",$string);

I'd like to strip out everything but the link name, so if someone inputs:

a href="http://www.php.net"PHP!/a

It replaces it with:

PHP!

Thanks, again.  I seem to be asking a lot of questions today, hehe ;)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Searching a MySQL database?

2001-01-14 Thread James, Yz

 You've basically got it... the advantage of LIKE is that you can add
 wildcards to specify what can be different...

 towns = '$town'
 ...and...
 towns LIKE '$town'

 ...are essentially the same without the % wildcard character. Thus,

 towns = '$town'
 ...is much different than...
 towns LIKE '%$town%'

How different are they?  I'm not even sure what a wildcard is?

And thanks ;)

James.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Another q, this time eregi_replace

2001-01-14 Thread James, Yz

Sweet!  Thanks ;)

  I'd like to strip out everything but the link name, so if someone
inputs:
 
  a href="http://www.php.net"PHP!/a
 
  It replaces it with:
 
  PHP!
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Searching a MySQL database?

2001-01-14 Thread James, Yz

 Here are some queries of the above table with their results
 bases='Ft. Worth' returns record 1
 bases LIKE '%Worth%' returns record 1
 bases LIKE '%Ft.%' returns 1  2
 bases LIKE '%' returns all records (in this case, 1  2)

 See?

That makes perfect sense.  Thank you!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]