[PHP] Re: help avoid multiple login

2005-11-30 Thread Mark Rees
 the normal way of doing session 'closing' is by way of 'garbage
collection'
 - every now and then a script/process/function is run that 'closes' any
 sessions which are (according to your criteria) inactive. php has stuff
 built it that will do this for you to a degree.
 -

 Is there a way I can access sessions from other users on a script?
 If yes I could store the session id on a table and later check if isset.

You could write the session id into a table when the session is started,
along with the start time.
Something like

sessionid CHAR|starttime DATETIME|lastvisittime DATETIME

You could then update this table each time the user visits a page, and
delete it if the interval between starttime and lastvisittime is longer than
you want. A cron job/scheduled task could be used to clean this table up
periodically

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



[PHP] Re: Autodeleting news when it has become yesterdays news

2005-11-23 Thread Mark Rees
I have a news-script on a webpage. Or an eventscript you might call it.
This lists up events thats gonna happen on a given day. ie concerts and
sportsevents.
To get this deleted without having to log on to the adminpage when the event
is over would have been a great relief.

1. Is it just as simple as writing a query that executes and removes news
with yesterdays date?
-
Even simpler, why don't you keep the data instead of deleting it and write a
query for the homepage which only displays events whcih occur in the future?

2. And how should I set it to execute if so?

If you do want to execute a regular PHP script to delete data for some
reason, look into cron (*nix) or task scheduler (windows)

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



[PHP] Re: undefined index and php

2005-11-10 Thread Mark Rees
 I tried this to set the value...

 if (!isset($_POST['heading'])) {
 $_POST ['heading'] = ;
 }

 because the following line give the notice 'undefined index'  BEFORE  the
 submit button has been pressed..

 ? $heading_insert= stripslashes($_POST['heading']);?


What everyone else said, but also:

It's not good practice (in fact I don't even know if it's possible) to
modify the contents $_POST programmatically. It contains, as you no doubt
know, all of the variables POSTed to the script, generally by the submission
of a form with method=POST.

It would be better for you to assign the contents of $_POST to local
variables.  Firstly, you will be able to do any necessary checks and
modifications (length, variable type, presence of illegal characters and so
on) at the point when you create the variable. This will save you time if
you need to use the value multiple times on the same page.

example:

 $heading='';
 if (isset($_POST['heading'])) {
 $heading=$_POST ['heading'];
 }

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



[PHP] Re: PHP and files Upload

2005-10-19 Thread Mark Rees

 the script always says it was sucessful to upload the file, but the
destination
 directory was always empty...
 even when checking the $_FILES global

 $_FILES['var_name']['tmp_name'] and
 $_FILES['var_name']['name'] and
 $_FILES['var_name']['size'], the vars alwyas return empty values...

 is there any issue with php5 about files uploads ?

I have it working on Windows, Apache, PHP5

A few checks you could make:

Are you sure that var_name is the name of the file upload field in your
form?
Have you set the form enctype to multipart/form-data?
Have you set the maxfilesize attribute, and does the file you are trying to
upload exceed that size?

Good luck

Mark

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



[PHP] Re: Help needed / failed to open stream: Permission denied

2005-10-19 Thread Mark Rees
 
  This is line 57 $file_handle = fopen(./ . $file_name, r);

 It seems that the user your web server runs as may not have permission to
 open that file. Also, you might want to double check that ./$ile_name is a
 valid path.

And if you're planning to write to the file, you need to specify that. r
means open for reading only. Read up on the possibilities here:

http://uk2.php.net/fopen

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



Re: [PHP] Uploaded CSV - database

2005-10-18 Thread Mark Rees
This discussion is starting to go over my head, but fgetscv works with
uploaded files (in PHP5 anyway). Here's some sample code:

if(isset($_FILES['userfile']['tmp_name'])){
 $csvfile=fopen($_FILES['userfile']['tmp_name'],rb);
 if($csvfile==FALSE){die('error opening file');};
 while(($aryData=fgetcsv($csvfile))!==FALSE){
//etc
}

 Actually I think fgetcsv will work with any valid file pointer and at
 least in PHP 5, the streams implementation will allow you to use a variety
 of protocols to create the stream.

 http://us2.php.net/manual/en/wrappers.php

 I understand that it isn't even too teribbly difficult to implement your
 own stream if one isn't already to your liking, but I'm afraid I haven't
 found need to go beyond the simple read-a-file-from disk style operation.

 Ben

 On Mon, 17 Oct 2005 11:45:04 -0400, Jim Moseby [EMAIL PROTECTED]
 wrote:

  -Original Message-
  From: Brian Dunning [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 17, 2005 11:39 AM
  To: php-general@lists.php.net
  Subject: Re: [PHP] Uploaded CSV - database
 
 
  It looks like all of those tips will easily cover me for the latter
  half of the operation. Any tips on how to get the uploaded CSV file
  into memory in order to attack it with fgetcsv()? I'd rather
  not ever
  have to actually write the file to the server's disk.
 
  Thanks!
 
 
  If you are using the standard file upload facilities, your file is
  being
  written to disk when it is being uploaded.  As far as I can tell,
  fgetcsv()
  will only read a file from disk:
 
  ?php // from the manual
  $row = 1;
  $handle = fopen (test.csv,r);
  while ($data = fgetcsv ($handle, 1000, ,)) {
  $num = count ($data);
  print p $num fields in line $row: br\n;
  $row++;
  for ($c=0; $c  $num; $c++) {
  print $data[$c] . br\n;
  }
  }
  fclose ($handle);
  ?
 
  If you are instead using a socket connection to receive the file in a
  stream
  from the client, you could assign it to a string variable, and use
  explode().
 
  These are fairly uncharted territories for me, so others will likely
have
  better answers.

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



[PHP] Re: a couple of problems with PHP form

2005-10-17 Thread Mark Rees
-
sorry, my editor has not indented again
-
also, I want the field to appear hilighted when there is no
information so I am doing this:

input class=? if($error_msg){ echo error; } ELSE { echo
normal; } id=firstname name=firstname type=text
value={$_POST['firstname']}? /

and I have an error class set up in my CSS, such as

 .error {border: 1px solid red;}

this is not doinf anything either.
-
Assuming that your test for $error_msg is working correctly, change the css
definition to
input.error
-

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



Re: [PHP] Uploaded CSV - database

2005-10-17 Thread Mark Rees
  -Original Message-
  From: Jim Moseby [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 17, 2005 10:41 AM
  To: 'Brian Dunning'; php-general@lists.php.net
  Subject: RE: [PHP] Uploaded CSV - database
 
 
   -Original Message-
   From: Brian Dunning [mailto:[EMAIL PROTECTED]
   Sent: Monday, October 17, 2005 10:37 AM
   To: php-general@lists.php.net
   Subject: [PHP] Uploaded CSV - database
  
  
   Does anyone have an example of code to process a CSV file
  submitted
   via a file upload and parse it out in order to write its
   records to a
   db?
  
 
 
  With MYSQL (assuming permissions and such are in order) You
  would simply:
 
  $sql=load data local infile '/path/to/csv' into table
  tablename fields
  terminated by ',';
 

 I should amend this to say that the columns in your CSV file, and in the
 table must match for this to work.

 If you wanted to parse through it line by line and do it all manually,
check
 out the fread() and explode() functions in the PHP manual.

and don't forget fgetcsv()

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



[PHP] Re: Connecting to MySQL Sever using PHP5

2005-10-13 Thread Mark Rees
 I have just installed PHP5. I am using Windows XP and have already
installed
 MySQL.

 When I try and make a connection to a database on MySQL via Dreamweaver I
 get the following error message: An unidentified error has occurred.

 What could be wrong

Have a look at this:
http://uk2.php.net/mysql_error

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



Fw: [PHP] Re: Connecting to MySQL Sever using PHP5

2005-10-13 Thread Mark Rees
Back to the list - please use reply-all
- Original Message -
From: Andreja Simovic [EMAIL PROTECTED]
To: Mark Rees [EMAIL PROTECTED]
Sent: Thursday, October 13, 2005 9:58 AM
Subject: Re: [PHP] Re: Connecting to MySQL Sever using PHP5


 Sometimes this error may ocure
 if you do not place trailing slash in define sites url
 http://localhost/mysite1/
 from my expirience

 - Original Message -
 From: Mark Rees [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Thursday, October 13, 2005 10:43 AM
 Subject: [PHP] Re: Connecting to MySQL Sever using PHP5


  I have just installed PHP5. I am using Windows XP and have already
  installed
  MySQL.
 
  When I try and make a connection to a database on MySQL via Dreamweaver
I
  get the following error message: An unidentified error has occurred.
 
  What could be wrong
 
  Have a look at this:
  http://uk2.php.net/mysql_error
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  __ NOD32 1.1251 (20051012) Information __
 
  This message was checked by NOD32 antivirus system.
  http://www.eset.com
 
 



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



[PHP] Re: Userlogin system seems to override the if statement....

2005-10-12 Thread Mark Rees
-
sorry my mail reader didn't indent. comments in --


I'm new to this. So I used a tutorial to write this. But it shows Login ok.
Welcome at once when the page loads. Here is the tutorial:
http://www.ss32.x10hosting.com/ss32/files/PHP-logins.pdf
?php
include (DBconnection);
session_start();
$err = 0;
echo $err; //just to check. Shows 0
$sql_login = sprintf(SELECT 'name', 'pass' FROM DB

-
This is going to return
name pass
If you take the quotation marks away, you will select the actual field
values
-

WHERE 'name'='%s' AND 'pass'='%s', @$_GET['name'],@md5($_GET['pass']));

-

Never send user input directly into the database. Read up on sql injection
to find out why
-

$login = mysql_query($sql_login) or die(mysql_error());
if (mysql_num_rows($login) == 0) {
$GLOBALS['MM_username'] == @$_GET['name'];
echo $err; //just to check. Shows 0
session_register(MM_username);
echo $err; //just to check. Shows 0
$err = 1;


}

echo $err; //just to check. Shows 1

!-- Form --
?php
if ($err != 1) {
if ($err == 2) { ?
There was an error processing your login.
?php } ?
}else{
?
Login ok. Welcome ?php
echo meta http-equiv=Refresh content=3;url=1stpage.php;


you will end up here if $err==1
Since you set $err=1; just before the if block begins, this is as expected.
You might find the section on if statements in the PHP manual has some
useful examples which might make things clearer:

http://uk2.php.net/if


The tutorial you are following is a bit ropey to be honest if this is the
dtandard of the code in it.


}
?

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



Re: [PHP] How do I POST data with headers make the browser follow?

2005-10-10 Thread Mark Rees
 basically what I am working on is integrating a step inbetween the
checkout
 and the payment gateway processing.

 The cardholder information is checked for enrolment in the first step, if
 the cardholder is enrolled he will need to authenticate himself by
password
 (this is where the 2nd page comes in) if the authentication is successfull
 he is forwarded to the 3rd page where the payment gateway processing takes
 place.

 It's like any other online payment integration i have done before but this
 time there is this extra step required due to Visa's and Mastercards new
 security feature.

 I didn't see an issue with passing this information along since it's
already
 used in the verification of the cardholder which also requires
 the card number.

 I do require the payment info again on page 3 to pass it along to the
 payment gateway, but didn't want to store it on my end for that.

 What I gather from Richards answer earlier that the difference between
 $_POST, $_GET or $_COOKIE, $_SESSION is almost irrelevant, I might
 as well store the detail in a session to be able to use them on page
 3 it seems.

Are you storing people's credit card numbers locally - if so, why? It seems
like you are using them to identify users? (if that's what I am to infer
from

 I didn't see an issue with passing this information along since it's
already  used in the verification of the cardholder which also requires  the
card number.

If you are, consider using email addresses instead.

If you need to check whether someone already has an account with you or
whatever, do it before you take their payment details and save yourself this
bother.

Or are you using 3d secure or similar, when the user has to enter their
password/security code on the payment provider's website? That means you
have to make 2 requests with the payment data, to different websites, is
that right? One way around this might be to ask for the security code anyway
at the first step, otherwise you are stuck with persisting the information
locally.

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



Re: [PHP] Testing a String for 'most' Capitalised

2005-10-10 Thread Mark Rees
  Image that there could be a string
  fred
  Fred
  FRED

It isn't hard to do.

  First of all I need to know that these are same which I can do with
  strtolower

Also note strcasecmp for this task -
http://uk2.php.net/manual/en/function.strcasecmp.php

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



Re: [PHP] How do I POST data with headers make the browser follow?

2005-10-07 Thread Mark Rees
 The information that comes in from the first page is a creditcard form
 with the standard values (CCnumber, Expiry Date, Cardholder name etc).

 On page 2 an XMLrequest is done with a verification gateway (in this case
to
 check for enrolment in 3D-Secure), the result for that I get back on the
 same page and no redirection needs to be done.

 However AFTER the enrolment check with the gateway I need to send the user
 along to the 3rd page, which is a URL that is provided by the verification
 process.
 So to get there, as I need to pass a heap of data to that 3rd page I can
 either use GET or POST, but since the amount of data is fairly big the
only
 real option for this part seems POST.

 So it's not really about keeping the data persistent, it's more about the
 fact on how to push the user along correctly.

Is this what happens:

1. User enters payment data
2. XML check that payment data is OK
3. redirection to a page (on another site?), where for some reason the
payment data is required again (why?).

This sounds like a mixture of two ways of implementing online payments.
Forgive me if I'm telling you what you already know, but in general I
believe things work as follows:

1 The whole process from payment to verification takes place on the payment
provider's server
or
2.  the whole thing takes place on your server, with some inline (XML in
this case) communication with your payment provider to verify the card
details.

You seem to be doing a bit of both, or have I misunderstood?
Why do you need the payment details on the third page? If you don't actually
need them, then the security problem goes away, and you can use the session
object or whatever to persist the customer data.

Does this help?

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



[PHP] Re: mail() with port authentication

2005-10-06 Thread Mark Rees
 Do I need to use Pear to specify port 587 and authentication when
 sending mail? I could not find any way to do it using mail().


Windows or Unix? On Windows you can set the port by setting smtp_port in
php.ini. Unix doesn't appear to have a direct equivalent, but you might be
able to do something with sendmail_path?

As for SMTP authentication, when I wanted to do this on Windows I went for
phpmailer
http://phpmailer.sourceforge.net/

Hope this is of some help

Mark

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



Re: [PHP] How do I POST data with headers make the browser follow?

2005-10-06 Thread Mark Rees

 1. Take POST data from a form (no problem)
 2. Do whatever i need to on the target page (no problem)
 3. Pass some other data on to a 3rd page as a POST
request.
 4. Get the browser to follow to said 3rd page.


 All this is happening via SSL.

What the other people said about HTTP. It's time to look at this from
another angle. Why do you need to process this data twice? What are you
trying to do?

Are you, perhaps, trying to make an online payment where you store the data
locally (page 2), then perform some kind of credit check (page 3)?

If so, would something like the following work?

Page 1 - form post to page 2
Page 2: process form inputs, write to DB or whatever, communicate with page
3 as necessary (possibly using curl) and finally send a redirection header
to the browser sending it to a success/failure page based on what page 3
told you

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



[PHP] Re: PHP and Active Directory

2005-10-03 Thread Mark Rees
How do I connect a php script running on linux with Active Directory on
a windows machine? I would like to have my php script autmotatically
read email addresses from the AD server. Can this be done? I've found a
bunch of ldap functions for php but they seem to require ldap to be
installed on linux. I'm confused. Thanks in advance for your help.

---

Have you seen this?
http://uk2.php.net/ldap

I've managed to do it from Windows, after a lot of trial and error, but in
the end it wasn't that complicated.  Have you got any specific questions,
based on following the steps in the manual?

Mark

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



[PHP] Re: Array Select from database

2005-09-28 Thread Mark Rees
 Array ( [count] = 1 [0] = Array ( [clientaccountmanager] = Array (
[count] = 2 [0] = 210 [1] = 149 )

I've got the following Query=select * from client WHERE
clientaccountmanager='$value of array1' OR '$2nd value of array 1'
So that the query loops through the whole array...

-
No indenting for some reason, sorry


You should construct your query like this:

SELECT x FROM y where Z IN (value1,value2,value3)

For looping on arrays, have a look at foreach:

http://uk2.php.net/manual/en/control-structures.foreach.php

Hope this helps

Mark

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



[PHP] is_dir paths

2005-09-26 Thread Mark Rees
Hello

I am having trouble with is_dir

I am trying to check whether /lists/admin/temp exists (which it does).

However, I cannot get the function to work by specifying the path as above -
it only works if I do it relative to the current working directory. So:

var_dump (is_dir(getcwd()));
var_dump (is_dir('temp'));
#temp is one level below the working directory
var_dump (is_dir(/lists/admin/temp));

returns
bool(true)
bool(true)
bool(false)

Thanks in advance

Mark
--
www.itsagoodprice.com - top-brand electronics for less.

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



[PHP] is_dir paths

2005-09-26 Thread Mark Rees
Hello

I am having trouble with is_dir

I am trying to check whether /lists/admin/temp exists (which it does).

However, I cannot get the function to work by specifying the path as above -
it only works if I do it relative to the current working directory. So:


--
www.itsagoodprice.com - top-brand electronics for less.

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



Re: [PHP] is_dir paths

2005-09-26 Thread Mark Rees
  what does the following output:
 
  var_dump (getcwd());

This outputs a fully qualified path to the current working directory
(/lists/admin)

Not sure about the permissions. I'm using windows 2000, and the 'temp'
directory has the same user permissions as the rest of the htdocs foler


 I have better question:

 what does the following output:

 var_dump (realpath(getcwd()));
 var_dump (realpath('temp'));
 var_dump (realpath(/lists/admin/temp));

That outputs (paths trimmed)

 string(56) C:\...\htdocs\lists\admin
string(61) C:\...\htdocs\lists\admin\temp
bool(false)

Does that help?

Thanks

Mark

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



Re: [PHP] is_dir paths

2005-09-26 Thread Mark Rees
   what does the following output:
  
   var_dump (getcwd());

Sorry, this wasn't clear. I mean it outputs c:\...\htdocs\lists\admin

 Not sure about the permissions. I'm using windows 2000, and the 'temp'
 directory has the same user permissions as the rest of the htdocs folder

  what does the following output:
 
  var_dump (realpath(getcwd()));
  var_dump (realpath('temp'));
  var_dump (realpath(/lists/admin/temp));


 That outputs (paths trimmed)

  string(56) C:\...\htdocs\lists\admin
 string(61) C:\...\htdocs\lists\admin\temp
 bool(false)

var_dump (realpath(../../lists/admin/temp));

this outputs the same as

var_dump (realpath('temp'));

Does that help?

 Thanks

 Mark

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



Re: [PHP] is_dir paths

2005-09-26 Thread Mark Rees
  var_dump (realpath('temp'));
   I am trying to check whether /lists/admin/temp exists (which it does).

 This dir doesn't exists. The '/' at the beginning of path means: path is
 from root (unix) or from e.g. c:\ (windows)

 Outputs from

 var_dump(realpath(../../lists/admin/temp))
 var_dump(realpath('temp'));

 are same and thus you working directory is 'C:\...\htdocs\lists\admin'.
 If you need check existence of dir 'temp' in your current working
 directory you can try one of:

 is_dir('temp');
 is_dir('./temp');
 is_dir('C:\...\htdocs\lists\admin\temp');


I see. I thought this function would work with paths relative to the
webroot. Thanks for pointing out my mistake.

Does such a function exist?

The problem I have is that this path is set in the config section of a 3rd
party tool I'm using, and called from various pages within the site. I don't
want to hack the code, as that will make upgrades more difficult to apply.
Hard-coding the path from c: won't work well either, as that path is
different in the development and live environments.

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



Re: [PHP] is_dir paths

2005-09-26 Thread Mark Rees

 echo 'pre', var_dump( $_SERVER ), '/pre';

 for instance I cut/paste the following from an application of my,
 the code lives in a centrally included file:

 /* define a webroot basepath for the datasyncer module */
 define('DS_WEBROOT', realpath(dirname(__FILE__).'/..'));


dirname! That's the easiest way.

$tmpdir=dirname(__FILE__).\\temp;

Thanks for your help

  The problem I have is that this path is set in the config section of a
3rd
  party tool I'm using, and called from various pages within the site. I
don't
  want to hack the code, as that will make upgrades more difficult to
apply.
  Hard-coding the path from c: won't work well either, as that path is
  different in the development and live environments.

 if the path is set in the third party tool whats the problem? sorry don't
mean to
 rude - I really don't quite follow the last part of your post!



No, it doesn't make much sense, does it? One more try: the 3rd party app has
a config script (config.php), where this path is set. It will be accessed
from scripts in various different directories, so the path needs to be
absolute. And therefore, it needs to be set dynamically so it can work on
different machines.

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



[PHP] Re: curl version and PHP docs

2005-09-19 Thread Mark Rees
To put the question more simply, is there any way of finding out what
versions of the PHP modules ship with each/the latest release, short of
installing that version of PHP? Some release notes, for example?

Thanks in advance

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



[PHP] Re: REGEX Help Please

2005-09-19 Thread Mark Rees
 I am trying to implement a regular expression so that I have a number
 between 0.00 and 1.00. the following works except I can go up to 1.99

 $regexp = /^[0-1]{1}.[0-9]{2}/;


You could always do this, unless you are set on using a regular expression:

if($num=0  $num=1.01){
 echo number_format($num,2);
}

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



[PHP] Re: Problem with mysql_connect(...)

2005-09-19 Thread Mark Rees

I'm trying to connect to my MySQL server with mysql_connect(...). The server
is up and running, and I'm running Apache with PHP properly installed. :

---
But have you got the mysql extension? put this in a script

?php
 phpinfo();
?

and view the output to check

The code
$hleServer = mysql_connect($host, $user, $password)
 or die(Error: Database. Error code: 1. Contact the web master!);

$host, $user, and $password are set to correct values (checked and double
checked). The funny thing is that not only does the function call fail, but
I'm not even getting the text defined by die(...). It seems that the
function call is more or less a black hole. Of course the rest of the script
doesn't execute either, I'm just left with a blank page.

I didn't use to have this problem before (using PHP 5 now instead of 4).

Thanks for any input on this problem...


Arthur

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



[PHP] curl version and PHP docs

2005-09-16 Thread Mark Rees
Hello

I need version 7.14 of curl, as it contains a bug fix for my environment
(behind an ISA proxy server).  phpinfo tells me that my current version is
7.11.2, and I'm running PHP 5.0.4

As I am running Windows, and have neither the software nor the skills to
compile my own dlls (the suggested solution to the problem on
http://curl.haxx.se), this is quite a problem.

I have spent a couple of months on and off trying to solve this, and in
desperation am willing to try installing the latest release of php, if that
has the right version of curl in it. However I can't find any documentation
on www.php.net explaining what is in which release.
Short of downloading and installing the latest release, is there any way of
knowing what version of curl it ships with?

Thanks in advance

Mark
--
www.itsagoodprice.com - top-brand electronics for less.

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



Re: [PHP] mysql query

2005-09-15 Thread Mark Rees
On Wednesday 14 September 2005 07:36 pm, Jesús Alain Rodríguez Santos wrote:
 I have a table colum in mysql with two fields: day and month. I
 would like to know if it's possible to make a query where I can
 determine if exist days before to a selected day, for example:
 if I have in my table:
 day 19 - month 05, I wish to know if there are previous days
 inserted at the 19, the days they are not inserted in the table,
 they are inserted according your selection, what I want to get is
 that every time that you insert a day, I want to check if there
 are days previous to the one already inserted in the table in the
 same month, in case that there are not them then they owe you
 to insert together with the one selected,

I haven't tried this, but the logic should work according to the manual:

You don't have to check, you can just insert all the data. If the row
already exists, the data will not be inserted. This assumes that you have a
constraint on the table which prevents duplicate values!

$day=19;
$month=5;
for($i=1;i=$day;i++){
$result=mysql_query(INSERT INTO table (month,day) VALUES (5,$i));
}




If you don't have a constraint, then you will have to loop over the data for
that month and insert the rows where they don't already exist.


 I wait they understand me what I want:
 I work php/mysql.
create table tableA (
 day int,
 month int
);



select * from tableA where month=5 and day  19;

This will select everything from the 5th month and before the 19th day of
the
5th month.

Is that what you were going for?



 sorry for my english i'm cuban
 Thank you and excuse the nuisances



 --
 Este mensaje ha sido analizado por MailScanner
 en busca de virus y otros contenidos peligrosos,
 y se considera que está limpio.

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



Re: [PHP] Re: PHP 5, LDAP/Active Directory

2005-09-14 Thread Mark Rees
  On my server I'm running:
  Fedora Core 4
  Apache 2
  PHP 5 compiled with OpenLDAP

  To shed more light on the topic, bug #30670 [ http://bugs.php.net/
  bug.php?id=30670edit=0 ] seems to fit my situation perfectly. As
  some of the posts on that bug suggest, I've tried using
  ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION,3);
  ldap_set_option($ldap, LDAP_OPT_REFERRALS,0);
  between ldap_connect and ldap_bind but I still get the Operations
  error message. Everyone seems to be able to get this to work as long
  as they are running PHP4, but I have yet to see (or realize I've
  seen) a solution from someone using PHP5. I've also found where
  blizzards at libero dot it has posted When querying a windows
  2000/2003 AD you MUST use only SASL and not TLS (non supported).
  - Is this true?
 ?php
 $ds = ldap_connect('ad.server.com');

make sure this is working by doing this:

if($ds){


 $lb = ldap_bind($ds, 'username', 'password');

 then this:
 echo Bind result is  . $lb . br /;

(should show 1)

 // At this point the bind looks successful
 // so we'll try a query

 $res = ldap_search($ds, 'o=My Company,c=US','sn=S*');

Are you certain that this is the correct distinguished name? This is the bit
I struggled with. It will be the name at the very top of your active
directory (or the bit you are trying to search). To find this, I went onto
the windows box in question, and opened the active directory users and
computers. The top level entry, which the Groups and Users are directly
beneath, is what you are looking for. In my case, it was mydomain.com, so my
distinguished name looked like this:
DC=mycompany, DC=com

If I tried anything else here, it gave me an operations error

 So since you've got it working with PHP5 can you verify that SASL is/
 is not needed to communicate to an AD 2003 server from linux? I keep
 leaning towards the possibility that I need that, but can't seem to
 find any way to tell for sure since the ldap_sasl_bind()  function
 isn't documented yet.


No, I'm using windows 200, can't help with that I'm afraid

Good luck

Mark

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



Re: [PHP] whats wrong in this program.

2005-09-14 Thread Mark Rees

 I tried to use the final array values in a insert statement, but the
values are not inserted.
 the code is

 foreach ($final as $subnum){
  $res = $db-query(INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u
ltrasonic,duration,cdate,ctime,comment)

VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du
ration,'$cdate','$sctime','$comment'));
 if(!$res){
  echo insert failed;
  }
 }
 the values of array ($subnum)are not inserted , can you tell me where the
problem is.

the problem is probably in this line:

echo (INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u
ltrasonic,duration,cdate,ctime,comment)

VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du
ration,'$cdate','$sctime','$comment'));

and the problem is that you haven't done this to see what is wrong with the
SQL.

The next problem is that this line is also missing:

echo mysql_error();





 Jordan Miller [EMAIL PROTECTED] wrote:
 I think I finally understand what you are trying to do. I don't see
 any reason why you need to use the token functions, and I would
 recommend using array functions instead (also, it is exceedingly easy
 to sort the elements of an array... see the end).

 I believe this will do what you are trying to do:
 //Tokenizer for Babu
 $str = '10,12,14-18';
 $commas = explode(',', $str); // $commas will be an array of three
 items in this case

 // Final Values will go into the $final array
 $final = array();
 foreach ($commas as $value) {
 // If one of the $commas elements contains a dash, we need to
 get the range between them!
 if (strstr($value, '-')) {
 // Explode based on the dash. This code assumes there will
 only be a single dash
 $rangeValues = explode('-', $value);
 foreach (range($rangeValues[0], $rangeValues[1]) as $number) {
 $final[] = $number;
 }
 } else {
 // If $value does not contain a dash, add it directly to the
 $final array
 $final[] = $value;
 }
 }
 echo All your values in the range $str are .implode(' ', $final);
 // Prints All your values in the range 10,12,14-18 are 10 12 14 15
 16 17 18


 In your last email, you had some of the values given out of order:
 1. 20,21-24
 2. 21-24,20
 3. 10,20,21-24,25,26,30

 To make sure the $final values are always ascending, just do this at
 the end:
 sort($final);

 Done!!

 Jordan




 On Sep 13, 2005, at 7:16 PM, babu wrote:

  $str=10,12,14-18;
 
  $tok = strtok($str, ',');
  while ($tok !== false) {
  $toks[] = $tok;
  $tok = strtok(',');
  }
 
  foreach ($toks as $token){
  if (strpos($token,'-')){
  stringtokenize($token);
  }else{
  $finaltokens[]= $token;
  }
  }
 
  function stringtokenize($nstr){
  $ntok1= strtok($nstr,'-');
  $ntok2=strtok('-');
  for($i=$ntok1;$i=$ntok2;$i++){
  $finaltokens[]= $i;
  }
  }
 
  foreach ($finaltokens as $ftoken){
  echo $ftoken;
  echo 
 ;
  }
 
  the ouput prints only 10,12 but not 14,15,16,17,18. where is the
  problem.
 
 
 
  -
  To help you stay safe and secure online, we've developed the all
  new Yahoo! Security Centre.

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



 -
 How much free photo storage do you get? Store your holiday snaps for FREE
with Yahoo! Photos. Get Yahoo! Photos

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



[PHP] Re: PHP 5, LDAP/Active Directory

2005-09-13 Thread Mark Rees
 I've looked through php.net and scoured Google for a solution to an
 issue I'm having with PHP and LDAP but have so far found nothing. I'm
 trying to build an intranet site that uses the company LDAP (Active
 Directory really) service but I can't seem to get around the
 Operations error and other such messages when trying to bind.

 On my server I'm running:
 Fedora Core 4
 Apache 2
 PHP 5 compiled with OpenLDAP

I have this working with PHP5, Apache2 and Windows 2000


 I must confess that I'm very new to LDAP so it is likely that my
 problem is inexperience, but it seems that this issue has been
 resolved by others so I'm trying to figure out what I'm doing wrong.

Same here!


 To shed more light on the topic, bug #30670 [ http://bugs.php.net/
 bug.php?id=30670edit=0 ] seems to fit my situation perfectly. As
 some of the posts on that bug suggest, I've tried using
 ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION,3);
 ldap_set_option($ldap, LDAP_OPT_REFERRALS,0);
 between ldap_connect and ldap_bind but I still get the Operations
 error message. Everyone seems to be able to get this to work as long
 as they are running PHP4, but I have yet to see (or realize I've
 seen) a solution from someone using PHP5. I've also found where
 blizzards at libero dot it has posted When querying a windows
 2000/2003 AD you MUST use only SASL and not TLS (non supported).
 - Is this true?

Are you doing an anonymous bind? If you are supplying login credentials, be
sure that you are supplying them correctly. This was the problem I had. If
this doesn't help, how about supplying some code?

I found this to be a very useful resouce
http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.
htm

 Another thing worth mentioning here is that the company I work for
 has allowed us to build our own intranet system for our Dept and
 offers little to no support for server specs and settings, but I will
 try to get any information to the list that might be helpful.

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



[PHP] Re: Round with ONE-decimal... always...

2005-09-12 Thread Mark Rees

 I want to adjust the round() -function a little...

 If I put round(6,0) there will be an output of 6
 If I put round(6,32) there will be an output of 6,3

 I want it to have 6,0 instead of just 6... I guess there is an easy
solution
 to this? Suggestions?

Have a look at this.

http://uk2.php.net/manual/en/function.number-format.php






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



[PHP] Re: Best way to mass mail

2005-09-12 Thread Mark Rees
Ryan A [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,
 My client has a dating site and now he wants to mail all his members,
 he does not want to use any of the already installed mailing lists but
wants
 us to make one
 for him, he's on a dedicated server.

 Presently he does not have too many members, just a few thousand (around
3k
 i guess),
 I remember reading sometime back on the list that using the mail() may not
 be the best
 option...not sure if thats still true.

 The thing that bothers me the most is if the program times out..., how do
I
 start again from
 the ones that have not been sent?

phplist handles this well

www.phplist.com

Even if you decide not to use it, the code will probably help you out


 eg:
 (10 members)
 mail gets sent to first 4 members then times out
 we re-click on the send button and it starts again from one...again times
 out
 (this happens 5 times)

 that means members 1-4 will get the same email 5 times

 Doing this the hard way would be to connect to the db after each
successful
 mail and mark
 each member with todays date or something...but I would like to avoid so
 many calls to the
 DB if possible...esp if the site grows.

 Ideas/suggestions?

 Thanks in advance,
 Ryan

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



Re: [PHP] Inserting records question

2005-09-09 Thread Mark Rees
  Still learning, so sorry if this sounds really simply noobish.  But as I
  understand things currently this should work.  But doesn't.  I've been
  looking over tutorials but just don't see whatever the problem is.
 
  I created a simple table with the following fields (in order)
  tc_id (auto nmbr)
  lname
  fname
  machine_name
  email_addr
  problem
  date_time_submitted (timestamp)
 
  And I'm trying to run this insert from form input.
 
  $username=somename;
  $password=somepass;
  $database=somedb;
  $table=sometable;
  mysql_connect(localhost,$username,$password);
  @mysql_select_db($database) or die(Unable to Connect to DB);
  $tc_query = INSERT INTO $tablel VALUES(NULL, $lname, $fname,
$machine_name,
  $email_addr, $problem, NULL);
  $result = mysql_query($tc_query);
  mysql_close();
 
  So what exactly do I seem to be missing here?

As well as what other posters have said (and pay special attention to the
suggestions on using mysql_error and single quotes), you are trying to
insert a NULL into an autonumber field. You don't need to insert anything
here, as the name suggests, it will be populated automatically.

You may find it helps you in the future to specify the fields you are
inserting. For example, if you add columns to the table, you may see
unexpected behaviour.

INSERT INTO mytable (
firstname,
surname,
address,
city
)
VALUES(
'Guus',
'Hiddink',
'National Stadium',
'Sydney'
)

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



Re: [PHP] regular expression for integer range

2005-09-08 Thread Mark Rees
Murray @ PlanetThoughtful [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  Hi all,
 
 
  I want to write regular expression for checking the string format
entered
  by user.
 
  the allowed formats are
 
  examples:
  10
  10,
  10,12-10
  12-10
 
  that is the valid strings are:
  1. only integer
  2. an integer, range of integers example 3
 
  and no other characters must be allowed.

You could simplify the matter by replacing all - and , with, say, 0 and
then using the simple \d+ (I think) regexp.


 Hi babu,

 As you've pointed out, you have 4 distinct scenarios to deal with, and it
 may be very difficult, without a great deal of tuning and tweaking, to
 define a regular expression that can effectively match all 4 scenarios
 without including false matches as well.

 One way of dealing with this is to build more specialized and exact
regular
 expressions for each possible scenario and group them together in an if
 statement.

 Eg.

 if (preg_match('/^\d+$/',$subject) || preg_match('/^\d+,$/',$subject) ||
 preg_match('/^\d+,\d+-\d+$/', $subject) || etc etc){

 // code for successful match of valid data in $subject

 } else {

 // code for invalid data in $subject

 }

 Basically, the if/else statement is testing each distinct possible pattern
 and executing code if any of those distinct possible patterns match.

 It may not ultimately be the most graceful way of dealing with the
 situation, but having spent many hours attempting to tweak complex regular
 expressions looking for the magic combination, I've learned that breaking
 scenarios down this way can save a lot of development time and
frustration.
 This doesn't mean there isn't a benefit to finding the perfect regular
 expression for your needs, just that it can often be difficult to
guarantee
 your code won't be plagued by false matches or false exclusions as your
 expression becomes more and more complex.

 Hope this helps a little.

 Much warmth,

 Murray
 ---
 Lost in thought...
 http://www.planetthoughtful.org

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



Re: [PHP] Sessions , expiry times and different time zones

2005-09-07 Thread Mark Rees
Dan Rossi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 client cookie expires hence no more session ...

 On 07/09/2005, at 1:57 AM, Jordan Miller wrote:

  Hi  Dan,
 
  Couldn't you store an expiration time directly in the $_SESSION
  variable, rather than relying on cookie expiration (if I  understand
  your question correctly)?  Each time a page is loaded, update the
  expiration time in this variable to +24hr from the current time (all
  times relative to the server's time). Then, it shouldn't matter from
  which time zone the user is browsing.


Read what he said again. Instead of expiring the session itself, store the
time of session expiry in the session (with a longer expiry time than 1 day)
and check that.

When you say a day, do you mean 24 hours or a calendar day? Are you trying
to say:

Today is Tuesday, so expire this session at midnight on Tuesday?

If that's what you need to do, you need to use a client-side solution -
after all, only the client knows what time it is where the client is! Be
prepared for people who have their time zone set incorrectly.

 
  Jordan
 
 
 
  On Sep 6, 2005, at 10:37 AM, Dan Rossi wrote:
 
 
  hi there I have run into problems with sessions , cookies and expiryt
  times with different time zones. Ie our server is in the States
  however I am browsing from Koala land downunder. I have been trying
  to get the session to expire in a day, however for ppl in the states
  this is ok, but for me its already expired so i have been
  experiencing issues. How do i solve this ?
 
  --
  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] Re: calling PHP self with a text link

2005-09-02 Thread Mark Rees
 Ross wrote:
  a href=? echo $PHP_SELF,'?','action=something' ?do somehthing/a
 
  this seems to work but can someone explain the syntax to me what does a
'?'
  and a ',' do in PHP?
 
   I thought you joined strings with a full stop '.' (a period if you are
from
  the US).


There was a long thread on this only yesterday, under the heading String
format problem. The online archives will carry it shortly, if they don't
already, and it is well worth a read, especially the post by Satyam


 You are passing multiple parameters to the 'echo' language construct.
 The '?' is just a string, and is interpreted just like any other string
 in PHP. That will print out the value of $PHP_SELF followed by
 ?action=something

 By the way, you really shouldn't have register_globals turned on. And
 you also really shouldn't top-post.

 --
 Jasper Bryant-Greene
 Freelance web developer
 http://jasper.bryant-greene.name/

 If you find my advice useful, please consider donating to a poor
 student! You can choose whatever amount you think my advice was
 worth to you. http://tinyurl.com/7oa5s

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



[PHP] Re: 400 error

2005-09-02 Thread Mark Rees
Seth Rainsdon [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
when I try to access anything.php it tells me HTTP 400 bad request I have no
clue how to fix this
Seth

Nor do we, yet.

Which OS?
Which web server?
What have you tried so far?
Has it just broken, or did it never work?

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



Re: [PHP] String format problem

2005-09-01 Thread Mark Rees
 In fact, this is a poor example since the difference gets larger with
longer
 string and more arguments.  When you use dots, the interpreter has to
 actually concatenate the string, looking for memory to do so and freeing
it
 up afterwards.  This takes time.  With commas, each argument is sent to
the
 output stream as soon as it is found, no further processing is needed in
 between.


I have been wondering about this topic for a few months now, so thanks for
this fascinating explanation. Is this the only difference between using .
and , as concatenation operators


 Then the single vs. double quotes:

 echo 'uno ' , ' dos ' , ' tres ': 0.94
 echo uno  ,  dos  ,  tres : 6.76

 Notice that when variables are involved, the difference in between echoing
 with arguments separated with commas and separated with dots is more than
9
 times faster for the commas.Using double quotes with variable
expansion
 is almost 4 times slower than the commas, but is still faster than
 concatenating them externaly with dots.   Using heredoc-style strings is
not
 so bad compared to double quotes.

Never heard of heredoc before. What is it for? I have read
http://uk.php.net/types.string

and can only imagine that it is for laying out complex or long strings more
clearly


 So, if you are sending out the rule would be:
 Use echo, not print.   Separate arguments with commas.

 Now, if you are not using echo, for example, concatenating to a variable,
 the best is to use variable expansion inside double quoted or heredoc
 strings.   Concatenating with dots is more than twice as slow.

 Satyam

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



Re: [PHP] ID based on position?

2005-09-01 Thread Mark Rees
 Auugh!!  Why would you want to do this? You're flying in the face of
 relational database theory and practice. Position of a record in the table
 is, or should be irrelevant.

Agreed - position is a notional concept. The data is stored physically in
some sort of order, but what order that is is the database's business, not
yours. It could be subject to change when upgrading, and it is very likely
to differ on different platforms or RDBMSs.

You should also be aware that unless you use an order by clause in your
select statement, you don't have a guarantee that all RDBMSs will return the
records in the same row.

I don't know exactly what you want to do, perhaps you can provide more
details?


 What if you have twenty thousand records, or two hundred, and the 45th
 record in the table is deleted? Fetching an ID from anything beyond that
 record, based on the order of insertion (position), is instantly broken.

 Please rethink what you want to do, and if you are not familiar with
 relational databases read some of the excellent tutorials available on the
 'Net about them and their design. It's pretty straightforward, common
sense
 stuff -- but you can back yourself into an awkward corner.

 Regards - Miles


 At 07:54 PM 8/31/2005, Gustav Wiberg wrote:
 Hi there!
 
 Is there any function in PHP that gives an ID from a MySQL-db based on
 which position the record has in the table?
 
 
 Let's say, there's a table like this:
 
 1. Record1 ID 33
 2. Record2 ID 76
 3. Record3 ID 100
 
 
 If I know position 2, I want to get ID 76. Is the only way to loop
through
 the recordset?
 
 /G
 @varupiraten.se
 
 --
 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] Re: (Yet another) I'm blind ... post

2005-08-31 Thread Mark Rees
Martin S [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 In this code, I'm not getting the value of $list passed to the Mailman
page.
 I've checked this umpteen times by now, but fail to see the error. I've


$list is not to be found in this code sample. $lista is though.


 beaten myself suitably with a steel ruler -- but it didn't help. Nor does
 the cold I'm coming down with I suppose.

 Anyone see the error, and feel like pointing it out to me?

 Martin S

 ?php
 print H2BJoin the lists/b/H2;
 print FORM Method=POST
 ACTION='http://www.bollmora.org/mailman/subscribe/' . $lista . 'br';
 print Your E-mail address: INPUT type=\Text\ name=\email\
size=\30\
 value=\\br;
 print Your Name (optional): INPUT type=\Text\ name=\fullname\
 size=\30\ value=\\brbr;
 print Lista: select name=\lista\ /;
 print option value=\tvl_bollmora.org\Tävling/option;
 print option value=\jpg_bollmora.org\JGP/option;
 print option value=\styrelse_bollmora.org\Styrelse/option;
 print /selectbr;
 print You may enter a privacy password below. This provides only mild
 security, but shouldbr
  prevent others from messing with your subscription. bDo not use a
 valuable password/b as itbr
  will occasionally be emailed back to you in cleartext.brbr
  If you choose not to enter a password, one will be automatically
generated
 for you, and it willbr
  be sent to you once you've confirmed your subscription. You can always
 request a mail-backbr
  of your password when you edit your personal options.brbr;
  print Would you like to receive list mail batched in a daily digest?
(You
 may choose NoMail after you join.)BRbr;
  print input type=radio name=\digest\ value=\0\ CHECKED No input
 type=radio name=\digest\ value=\1\ Yesbrbr;
  print INPUT type=\Submit\ name=\email-button\
value=\Subscribe\;
  print /FORM;
  ?

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



[PHP] Re: upload file - clients path to file?

2005-08-30 Thread Mark Rees
 Hi all.

 I havent found an answer after looking at the manual. I'm trying to find
 out if it possible to find the path of the file on the clients pc once
 a  form has been submitted with the file upload form.


No, this would be a security risk. If  all your users are on an intranet,
you may be able to implement some kind of client-side scripting to discover
the location, then post it as part of the form. Even this will probably
involve amending local security settings on each machine.


 I know its possible to get the file name but I need the whole path.


What do you need it for? Perhaps there is another way to solve this problem?


 is this possible?
 thanks in advance.

 --

 Angelo Zanetti




 
 This message was sent using IMP, the Internet Messaging Program.

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



Re: [PHP] Re: upload file - clients path to file?

2005-08-30 Thread Mark Rees
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Thanks for the replies.

 Well basically i need it for an add products page and if the users
doesnt fill
 in all the fields correctly I display some error message as well as
populate the
 textfields and dropdown lists with the values they previously entered, so
if
 they entered/selected the file I want to display it again so they don't
have to
 upload the file again. I know that I could do it without the user knowing
 (backed) but then they might think they have to select the file again
because
 the upload field will be blank.



If that's the problem, you might find it easier to solve by going for two
separate forms - one to enter all the details, and the second just to upload
the file.



 Quoting Mark Rees [EMAIL PROTECTED]:

   Hi all.
  
   I havent found an answer after looking at the manual. I'm trying to
find
   out if it possible to find the path of the file on the clients pc once
   a  form has been submitted with the file upload form.
 
 
  No, this would be a security risk. If  all your users are on an
intranet,
  you may be able to implement some kind of client-side scripting to
discover
  the location, then post it as part of the form. Even this will probably
  involve amending local security settings on each machine.
 
 
   I know its possible to get the file name but I need the whole path.
 
 
  What do you need it for? Perhaps there is another way to solve this
problem?
 
 
   is this possible?
   thanks in advance.
  
   --
  
   Angelo Zanetti
  
  
  
  
   
   This message was sent using IMP, the Internet Messaging Program.
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 




 
 This message was sent using IMP, the Internet Messaging Program.

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



Re: [PHP] Re: php ldap

2005-08-26 Thread Mark Rees
Santosh Jambhlikar [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 then can i output the SMD5 of my password in php.


 Jeff Loiselle wrote:

  Santosh Jambhlikar wrote:
 
  Hi ,
 
  I  have a ldap server the user password are stored in that. my php
  ldasearch result says that the result is
  ldap user password : {SMD5}eRuT8dttD6M6N6tgMJF33/TNAvc=
  i want to compare this password with the user given password in other
  application (obviously php) but when i md5(passwordgiven) then it
  is showing different output.
  Any suggestions.

You could try to bind to the server using ldap_bind with the supplied
password. That will check if it is valid or not.

 
 
  MD5 and SMD5 are not the same type of encryption. md5() will not
  return the correct results.
 

 --
 Santosh Jambhlikar
 Linux Administrator
 Cash-Tech Solutions
 Pride Parmar Galaxy, Pune
 Maharashtra.
 Ph.
 O.:- 56052000
 ext. 2150

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



[PHP] Re: Help Needed

2005-08-26 Thread Mark Rees
?php

require(../passit.php);

$stmt = OCIParse(select UPI, ORG from WEB_DS where REC_VALUE =
'uczmdsk1');

OCIExecute($stmt);



According to the manual, this returns a boolean. I have never used oracle
with php but you need to find a function which actually returns a result set
in the same way that this function does, for example

http://uk2.php.net/manual/en/function.mssql-query.php

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



[PHP] Re: PHP open source newsletter software

2005-08-25 Thread Mark Rees
Angelo Zanetti [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi guys.

 Does anyone know of any open source software written in PHP to create
 HTML news letters (head, side and bottom graphics). as well as being
 able to send the newsletters.

PHPlist from www.tincan.co.uk


 thanks in advance.

 --

 Angelo Zanetti
 Z Logic
 www.zlogic.co.za
 [c] +27 72 441 3355
 [t] +27 21 469 1052

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



Re: [PHP] LDAP problem

2005-08-24 Thread Mark Rees
How long does it take to fail?
I get the answer immidiatly (0-1sec.)...

Are you sure you are connecting? As in, do you only try to bind if you have
a successful connection?

Have you checked ldap_error?

Are you doing an anonymous bind, or using a username and password? Try each
and see what happens

How about posting some code?

I have just spent several days trying on and off to work out LDAP, from a
starting position of what's LDAP?.

Good luck

Mark

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



Re: [PHP] PHP vs. ColdFusion

2005-08-24 Thread Mark Rees
  I'm betting you'll have the SAME ISSUE, and that the problem has
  NOTHING to do with PHP whatsoever.
 
  And you'd win that bet. I thought that would be the proof I'd need to
  show that it wasn't PHP, but management has some notion that PHP might
  have somehow tainted IIS.

 Gotta love a management group that doesn't listen to their IT guys and
 think they know the answer to all the IT problems even though they have
 no clue about IT.  I've been there done that and guess what?  I'm still
 doing it to this day.  I think it's one of those never ending things.
 What you should do is configure IIS to parse PHP with .asp extensions
 and just tell them that it's ASP.  Now that would be funny!

  PHP works fine with IIS and Windows.
 
  I've tried to tell the that there are Fortune 500 companies running
  PHP on Windows and IIS (there are, right?).

 Target, Tickmaster, Yahoo, Amazon, and the list goes on and on.

Not too sure about this:

http://uptime.netcraft.com/up/graph?site=amazon.com
http://uptime.netcraft.com/up/graph?site=ticketmaster.com

etc
PHP, possibly, but not on IIS and Windows.




 Or you could leave IIS on the Windows machine and install Apache on the
 same Windows box and run PHP using Apache on Windows and see if that
 solves your problem.  Then of course don't tell management that you are
 running Apache! ;-)


Class idea! I think you should do this!

Good luck

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



Re: [PHP] php solution to html problem

2005-08-24 Thread Mark Rees
Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
doesn't work CSS acts the same way with a long unbroken string.
[/snip]

Well, you have no way of determining how many pixels wide something can
be with PHP. You might have to use JavaScript to break up the string as
the table is rendered.

Just a thought, and probably not very relevant to the OP: can you use a
fixed width font, specify the size with CSS and then work out the width?
I've done something similar with ASP to determine the size of pop-up
windows, but it was a big pain in the backside although it kind of works
(good enough for a hobby site anyway).

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



Re: [PHP] Catching all errors and redirecting

2005-08-19 Thread Mark Rees
Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
Is it possible to catch all parser errors (notices), and as that happens
redirecting to a 'sorry-page-not-available-at-this-moment' page, whilst
storing the error (or notice) message somewhere else (e.g. emailing it
to
the developer).
[/snip]

Yes?


/subtle

What is the point of taking this attitude with a poster who (I'm guessing
from his name) is a non-native English speaker? He asks a perfectly polite,
intelligible and on-topic question. Even if he isn't a good proportion of
posters are non-native speakers, and I imagine they find this kind of thing
a little intimidating.

One strange thing I notice about this list: even the most off-topic and
misguided question (like how can I clear a user's browser cache with PHP,
how do I set up a mailserver) gets a few intemperate answers and then
(perhaps because people's attention is drawn to it) a series of useful
answers. This encourages posters to come back and ask again, as they keep
getting answers. A well-formulated question, on the other hand, will
sometimes just be ignored, perhaps because it is buried in the general
traffic. Witness the recent post by Richard Lynch on True Upload Max
Filesize, for example.

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



[PHP] Re: setting 'sendmail_from' on windows

2005-08-19 Thread Mark Rees
George Pitcher [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I am sending emails out from php using a variety of 'From addresses',
 depending on who is logged on. I would like bounced messages to go
directly
 to the sender, but they are not. I suspect that this is because in
php.ini,
 I have to set the 'sendmail_from' to a specific address.


I don't know if this will work, but try using ini_set  to change
sendmail_from as necessary

http://uk2.php.net/manual/en/function.ini-set.php

List of ini options here

http://uk2.php.net/manual/en/ini.php#ini.list


 Can anyone suggest an alternative, other than switching platforms?

 MTIA


 George

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



[PHP] Re: LDAP, PHP and MS Active Directory

2005-08-18 Thread Mark Rees
 Hello

 I am using PHP v5 to write an intranet. The site is hosted on a windows
2000
 server running Apache. I want to incorporate some form of Windows
 authentication to allow or deny access to given resources based on
usernames
 and group membership.

 I am trying to accomplish this using LDAP. I am able to connect and bind
to
 our Active Directory server (also Windows 2000) from PHP, but when I want
to
 perform a search, I need to know what the base record is. This is in the
 format o=my company, c=the country it is in.

 This is where the problem lies. How do I find out this information? Is
there
 some facility in Active Directory that allows me to see what the actual
 name-values are for all the records (like sn=rees)?


I found a useful utility to solve this problem called CSVDE built into
Windows 2000 and 2003. More information is available here
http://www.computerperformance.co.uk/Logon/LDAP_attributes_active_directory.
htm

I also found this page useful

http://www.developer.com/lang/php/article.php/3100951



 The line of code causing the problem is this: $ds is a bound connection to
 the LDAP server
 $sr=ldap_search($ds, o=company name, c=uk, sn=g*);

 It returns Operations error

 Thanks in advance

 Mark

 --
 www.itsagoodprice.com - top-brand electronics for less.

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



[PHP] Re: edit $variable online?

2005-08-17 Thread Mark Rees
Jesús Alain Rodríguez Santos [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi, I have in a php page one ($variable = 85), I woud like to change the
 value from this variable online, without any data base, for example ussing
 a form where I can put the new value and it change the value of the
 $variable.



Do you mean that you have a page like this, for example:

1.php
?php
$variable=85;
if( $variable85 ){
do things;
}
?

And you wish to permanently change the value of $variable to 86?

You could use file rewriting functions to do this. Look in the manual for
fputs, fread, fwrite and their friends.

If you wish to change the value temporarily for a single user visit
(session), use a session variable to store it. If you wish to change it for
a period of time, then perhaps consider using a class to retrieve the
variable.





 --
 Este mensaje ha sido analizado por MailScanner
 en busca de virus y otros contenidos peligrosos,
 y se considera que está limpio.


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



[PHP] Re: access multiple databases

2005-08-17 Thread Mark Rees
Bing Du [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I need to access both MySQL and SQL server 2000 in a PHP script on RHEL
 3.  In phpinfo(), I noticed 'supported databases' shows 'MySQL ODBC
 PostgreSQL Microsoft SQL Server FrontBase Oracle 8 (oci8)'.   And
 'Configure Command' has '--with-unixODBC=shared' included.  Do I need to
   install anything else, like iodbc?


Have you uncommented

extension=php_mssql.dll

in php.ini?

Are you having any specific problems or error messages?

 Would anybody give me some guidance how I should start from here?

 Thanks,

 Bing

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



[PHP] LDAP, PHP and MS Active Directory

2005-08-17 Thread Mark Rees
Apologies if this turns out to be a cross-post. I sent it to the list @
evolt, but have seen no traffic on that list for two days now.

---

Hello

I am using PHP v5 to write an intranet. The site is hosted on a windows 2000
server running Apache. I want to incorporate some form of Windows
authentication to allow or deny access to given resources based on usernames
and group membership.

I am trying to accomplish this using LDAP. I am able to connect and bind to
our Active Directory server (also Windows 2000) from PHP, but when I want to
perform a search, I need to know what the base record is. This is in the
format o=my company, c=the country it is in.

This is where the problem lies. How do I find out this information? Is there
some facility in Active Directory that allows me to see what the actual
name-values are for all the records (like sn=rees)?

The line of code causing the problem is this: $ds is a bound connection to
the LDAP server
$sr=ldap_search($ds, o=company name, c=uk, sn=g*);

It returns Operations error

Thanks in advance

Mark

--
www.itsagoodprice.com - top-brand electronics for less.

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



Re: [PHP] Advice sought on PHP site maintenance

2005-08-16 Thread Mark Rees
George Pitcher [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 John,

 Thanks for the input. I just knew I hadn't covered everything. My server
is
 currently set up as NT4/IIS. I suppose I could look to switching to Apache
 though.

Far be it from me to discrouage you from switching to Apache. However, on
IIS, you can store the include files and classes you wish to use across
several sites in a single location. You can then make this accessible to all
sites by adding the location in as a virtual directory. This basically
allows you to refer to it as if it were a directory within your webroot (if
I remember right, it's been a while).

There's a brief guide here:
http://www.mvps.org/marksxp/WindowsXP/IIS/iis3.php

Giood luck

Mark


 Cheers

 George

  -Original Message-
  From: John Nichel [mailto:[EMAIL PROTECTED]
  Sent: 16 August 2005 2:25 pm
  To: php-general@lists.php.net
  Subject: Re: [PHP] Advice sought on PHP site maintenance
 
 
  George Pitcher wrote:
   Hi,
  
   I manage several sites for my company. Some are running our own
  service to
   about 80 customers and others are running a service for some (5
  and growing)
   of our customers. Its the latter one that I need advice on.
  
   I have an application where each customer has a website on our
  service. The
   functionality and layout are almost identical throughout these
  sites and I
   am striving to move any differences into configuration files.
  However, when
   I make a change, I then need to make that change on each site.
  
   I would like, if possible to maintain a single set of web pages and
have
   that work for all sites. I currently use PEAR::DB and Smarty
  templating. The
   current url syntax is www.mysite.com/client/ and I would like
  to keep them
   thinking that they each have their own unique site.
  
   Can anyone suggest a structure for this?
 
  If I'm reading you right, you're looking to keep a group of
  scripts/classes in one place that all sites can draw from.  If this is
  the case, you could always set a global include directory (make it read
  only for the users of your service), and configure that path in Apache's
  httpd.conf or an .htaccess.  I do this on our box (all the sites are
  ours, but when I have to update Smarty/PEAR/custom scripts, I like to
  just do it in one place).
 
  VirtualHostDirectory
  -VirtualHost1
  -docs
  -VirtualHost2
  -docs
  -VirtualHost3
  -docs
  -VirtualHost4
  -docs
  -GlobalInclude
  -PEAR
  -Smarty
  -Custom
 
  So on, and so forth.

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



[PHP] Re: The Naming of Directories

2005-08-04 Thread Mark Rees
Tom Chubb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
This may be slightly OT, but I've modified a gallery script that I had
written for me which reads directories and echos the dir name as a
gallery.
Unfortunately, it doesn't look very nice with say picsofsomething so I
renamed the folder 'pics of something'
When this is read, the string inserts %20 for the spaces, which is
fine, but are there any reasons why I shouldn't be doing this?
Many thanks,

--

A while back, this would have been liable to cause problems in Netscape
(v3/4). I don't think it makes so much difference these days, but I just
avoid it out of habit. You can get a more readable effect wihout spaces by
using an underscore, say, in the directory name, and when you need to print
it to screen, replace the underscores with spaces
--
Tom

--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

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



[PHP] Re: Everything works...Unless they hit the back button...

2005-08-03 Thread Mark Rees
Jack Jackson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi all. This has been an interesting week.

 Now the form works, and I am able to error check, if no errors look into
 user answer table and delete from that all q_ids matching the ones just
 picked, insert this page of question/answer info (q_id/a_id) into the
 user answer db, and if successful advance the category by 1 and get more
 questions. It works.

 I must have a logic error though because for some reason even though I
 say to delete matching  q_ids and reinsert, then move on, if the user
 hits the back button, changes answers and hits submit again, the table
 does not update . .  . and the category does not increment. We get stuck
 on this page of questions/answers forever.

Do you want to allow people to go back and chnage things ?

If so, write a suitable UPDATE statement

Sample UPDATE syntax

UPDATE table
SET field=1
WHERE field2='x'

You will probably want to check whether the answers already exist, use a
select statement for this. Unsure if this works in mysql, but

IF NOT EXISTS
(select id from table where field=1)
UPDATE table
SET field=1
WHERE field2='x'

might do the trick, or something similar will at any rate.

If you want to stop people going  back, check the referer (sic)

 What DOES happen after BACK is that the answers they select get passed
 back to error check (eg if they select a select box to nothing, error
 checking reenters its value into $message) and those values get passed
 back to the display page (eg $_POST[$qname] == $aid) because the
 selected answers change. It's just the db call and category advance
 which get stuck.


 Any help will be greatly appreciated - Here's the code:

 ?php
 //Start the session
 session_start();
 //Error announcements
 echo POST:BR /;
 print_r($_POST);
 echo br /br /;
 echo required session:BR /;
 var_dump($_SESSION['required_fields']);

 echo br /\$ cat: . $cat . br /;
 echo \$message: ;
 var_dump($message);

 //error_reporting(E_ALL);


 /* A script to retrieve from database questions and answers,
   * create a multi-page HTML form, error check answers and
   * submit them to the database on a per-user basis.
   * August 2005
   */

 //Some basic vars
   if (!isset($cat)) { $cat = 1; }
 $error=0;
 $SUCCESS=0;


 if (!isset($message))
  {
  $message = array();
  }

 if (!isset($_SESSION['required_fields']))
  {
  $_SESSION['required_fields'] = array();
  }

 if(!sizeof($_POST))
 {
 include_once(QUESTIONS . 'q.inc');
  }

   //error checking

   reset($_SESSION['required_fields']);
foreach ($_SESSION['required_fields'] as $fieldname)
  {
 if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname]))
 {
  $message[$fieldname]=1;
 }

   }//error check
if (!empty($message))
{   $cat=$_POST['cat'];
include_once(QUESTIONS . 'q.inc');
}

 //No errors? Store what's been done so far

if ( ($_POST['action'] == 'process')  (!sizeof($message) ) )
{
foreach($_POST as $key=$val)
 {
 //find key/val sets within posts which are both
numeric
 if(is_numeric($key)  is_numeric($val))
 {
$nkey=$key;
//add keys to the qidlist
$qidlist[] .= $key;
//add these values ( q_id, a_id ) to sql statement
$qanda[] .= ('1' , ' . $nkey . ' , ' . $val .
 ');
 }
 //find key/val sets within sub-arrays of $_POST
 which are numeric
 if(is_array($val))
 {
 foreach ($val as $akey=$aval)
 {
 //add these values ( q_id, a_id ) to sql
 statement
 $qanda[] .= ('1' , ' . $key . ' , ' .
 $aval . ');
 var_dump($qanda);
 }
 }
 }


 $qidlist_sql=DELETE FROM $userAnswers WHERE q_id IN (
 . (implode(,,$qidlist)) . );;

 $q_a_sql=INSERT INTO $userAnswers (u_id, q_id, a_id )
  VALUES  . (implode(,,$qanda)) . ;;

   mysql_query($qidlist_sql);


if($q_a_result = mysql_query($q_a_sql))
  {
unset($_SESSION['required_fields']);
$cat = $_POST['cat']+1;
include_once(QUESTIONS . 'q.inc');
  }

  else
  {
  echo bA fatal MySQL error occured/b.\n
  br /Query:  . $q_a_sql . br /\nError: ( .
 mysql_error();
  die;
  }

}
 ?

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

Re: [PHP] returning info. from a form selection

2005-08-02 Thread Mark Rees
 
  can anyone give me an idea on how to return info. from a forl
  pulldown menu
 
  and return that to an email address.
 

 A most basic question begs a most basic answer:

 ?
 if (!$_POST['submit']){ // Display form
 ?
 html
 head
 titleDropdown Value to Email/title
 /head
 body

 form method=POST action=? echo $_SERVER['PHP_SELF'];?
 select name=loan_process
   option value=PurchasePurchase/option
   option value=ConstructConstruct Home/option
   /selectinput type=submit value=Submit name=submit
 /form
 /body
 /html

 ?
 }else{ // Mail form results
 if(mail('[EMAIL PROTECTED]','Dropdown
results',$_POST['loan_process'])){
   echo 'Mail sent!';}
 else {
   echo 'Mail NOT sent!';}

Even more basic, no php required (but not suitable for internet use as it
relies on your browser knowing what to do with a mailto link:

 html
 head
 titleDropdown Value to Email/title
 /head
 body
  form method=POST action=mailto:[EMAIL PROTECTED]
 select name=loan_process
   option value=PurchasePurchase/option
   option value=ConstructConstruct Home/option
   /selectinput type=submit value=Submit name=submit
 /form
 /body
 /html

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



[PHP] Re: dynamic two column table

2005-08-01 Thread Mark Rees
 i know how to break up db results into two tables but im having a hard
 problem with this:

 db structure

 ---
 | id | cid | title
 ---
 | 1  | 2  | hardware
 | 2  | 3  | software
 | 3  | 3  | software
 | 4  | 2  | hardware


 how can i have hardware on column 1 and software on column 2 using 1
 query? i thought a simple if statement on cid might do it but regardless
 it spreads the results on both columns.


Can you give an example of what you want the output to look like?



 thanx.


 --
 No virus found in this outgoing message.
 Checked by AVG Anti-Virus.
 Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

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



Re: [PHP] Re: error checking a null array

2005-08-01 Thread Mark Rees

 g.gill wrote:
 From what I understand the simplest solution here would be to check to
see
  if you have $_POST['cb'] in the first place.  That would indicate if
  checkbox was selected or not.  After, you have posted the form just do
the
  following test.
 
  $check_box_exits = ((isset($_POST['cb']))? true:false);


 That helped, sonu, thank you. The problem now is that, how can I pass
 through $_POST the names of each specific checkbox, whether filled in or
 not, and then parse each to see if they have any answer? I need to do
 that or else I can only tell the ones which *have* been filled in but
 not those which have not.


It's about this time that I usually say, forget the checkbox, let's use a
radio button instead :-)



 Thanks

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



Re: [PHP] Re: error checking a null array

2005-08-01 Thread Mark Rees
On 8/1/05, Jack Jackson [EMAIL PROTECTED] wrote:

 Jochem Maas wrote:
 snip
 
  wtf are you smoking Jack? every checkbox that was checked will exist in
the
  $_POST array set with the value you gave it (I alway set a chekcboxes
  value to 1
  because the values mere existance in the submitted data indicates it's
  chevckbox
   was checked), if a checkbox does not exist in the $_POST array it
  wasn't checked!!!

 Oh, how I wish I were smoking something :) !

  imagine you have 10 checkboxes named 'cb1' thru 'cb10' each with a value
  of '1',
  upon submitting the form they are in, your script sees the following in
  the $_POST
  array...
 
  $_POST = array('cb1' = '1', 'cb9' = '1', 'cb10' = '1');
 
  which tells you 3 checkboxes were checked... namely 'cb1', 'cb9' and
'cb10'
  now how hard is it to determine which we're not checked?
 

 Well, for me, it is - because I don't know the names of the other check
 boxes which were not checked because they were dynamically created, and
 I don't have the knowledge sufficient to pass the NAMES of all
 checkboxes through to $_POST so that I can search through and see which
 have been answered and which ones not.



  maybe I'm not seeing the problem but I get the impression that you are
  over complicating things regarding checkbox.

 As always this is hugely possible.


 JJ



You can pass those names in a hidden input field in the form,
something like this:
input type=hidden name=checkboxes value=one box, two box, three
box, four!

--

Yes, or you can make your life easier and use radio buttons instead - the
name:value is always passed without any need for the messing about which
checkboxes bring. However, if you wish to use checkboxes, Jochem and Dotan
are showing you the way.

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



[PHP] Re: Has anybody used amfphp? (open flash remoting + php)

2005-07-28 Thread Mark Rees
Taksam [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Anybody used OpenAMF+PHP? ( http://www.amfphp.org/ )

 It is an open-source Flash Remoting gateway. I already used it with Java
and works OK. Just wanted to know if somebody here used it with PHP and
would like to know if they recommend it or not.


Please don't cross-post on php.general and this list



 Tak

 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com

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



Re: [PHP] Multipage form redux

2005-07-28 Thread Mark Rees
Jack Jackson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Somehow my intent has been turned around here and I apologise.

 I do not want to use *any* client side validation. I only want to do
 server side validation and server side storage.

 My intent was to remove the client from as much as possible of this - if
 I didn't need their information I wouldn't even allow clients!! :)

 What I wanted to do was this:


 p. 1 : I send client page one, they send answers. SUBMIT sends to page 2
 script.

 p 2. Before displaying anything to the client, Page 2 script validates
 input from page 1. If there are problems, page 2 script redisplays page
 one questions with highlights around problems. Clicking submit then
 resubmits page one data to page 2 script.

 Once page 2 script validates all page 1 answers, page 2 script stores
 all those answers to a SESSION, then sends PAGE 2 QUESTIONS ONLY (no
 $_POST information) to client. Client answers page 2 questions and
 clicking submit submits PAGE 2 QUESTIONS to page 3 script.

 p 3. Before displaying anything to the client, Page 3 script validates
 input from page 2 questions. If there are problems, page 3 script
 redisplays page 2 questions with highlights around problems. Clicking
 submit resubmits page 2 data to page 3 script.

 Once page 3 script validates all page 2 answers, the script stores all
 those answers to a SESSION, then sends PAGE 3 QUESTIONS ONLY (no $_POST
 information) to client. Client answers page 3 questions and clicking
 submit submits PAGE 3 QUESTIONS to page 4 script.

 At this point, if the client goes off for a bite, or two weeks
 backpacking in the Anapurna region, I'm fine, because the information is
 stored in the session (I have a very small group taking this
 questionnaire, all have a vested interested in filling it in, so I am
 not too worried abou their going aaway from it for more than a couple
 days max).

 Once they complete the last set of questions, I say thanks much, get all
 the information out of their SESSION, insert it into the db, send
 confirmation emails all around and we're done.

Sessions are used to identify users on a single visit to a website. They are
not intended to track users who turn off their machines, then turn them on
again and visit the website again. There are various ways of doing this, and
for all I know it may be possible with sessions, but I don't recommend you
try.

Do as suggested previously by various posters, it is the simplest and most
robust solution to your problem:

1. have the user register their details first up. Store this in a db, and
use it to identify the user on any subsequent visit.
2. when each page is submitted, write the information into the db. This way
it will definitely be associated with the right user
3. Whenever a user revisits the questionnaire, make them log in, then take
them to wherever they were up to - you will be able to work this out from
the amount of data you have recorded against them.

e.g. database table

userid
question
question
question
question
question
question







 Is this possible? How?

 Thanks!



 Marcus Bointon wrote:
  On 27 Jul 2005, at 21:22, Jack Jackson wrote:
 
 
  Right. Except I would rather have it working in a session because I
  specifically do not want to have the form sending $_POST data back
  and forth to the browser six times for several reasons. SO I'd like to
 
  Page1 // User enters first batch of data, presses SUBMIT at bottom.
  Data is cleaned and written to SESSION, user passed to Page2
 
  repeat as necessary to last page. At last page, process and error
  check newest input, then commit it, plus all previously stored
  session info to db.
 
 
  As has also been said, Javascript can do this really nicely. The best
  example I've seen of this is in Mambo's (a popular PHP CMS) admin
  interface. It uses a tabbed multi-page form with client-side
  validation. It's really just one big page, so if the user has JS  turned
  off, they will get one big form with no client-side  validation, but it
  will still work. It's a really elegant way of  working. It doesn't
  require any server interaction between pages -  nothing is submitted
  until the form is complete.
 
  See here for a howto: http://www.devx.com/webdev/Article/10483/1763/
page/1
 
  Admittedly this approach doesn't easily allow to you abandon and  resume
  later (unless you get clever with JS and cookies).
 
  For keeping data in a session, you could combine this approach with
  Ajax: http://particletree.com/features/smart-validation-with-ajax
 
  Marcus

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



Re: [PHP] Multipage form redux

2005-07-28 Thread Mark Rees
Jack Jackson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Somehow my intent has been turned around here and I apologise.

 I do not want to use *any* client side validation. I only want to do
 server side validation and server side storage.

 My intent was to remove the client from as much as possible of this - if
 I didn't need their information I wouldn't even allow clients!! :)

 What I wanted to do was this:


 p. 1 : I send client page one, they send answers. SUBMIT sends to page 2
 script.

 p 2. Before displaying anything to the client, Page 2 script validates
 input from page 1. If there are problems, page 2 script redisplays page
 one questions with highlights around problems. Clicking submit then
 resubmits page one data to page 2 script.

 Once page 2 script validates all page 1 answers, page 2 script stores
 all those answers to a SESSION, then sends PAGE 2 QUESTIONS ONLY (no
 $_POST information) to client. Client answers page 2 questions and
 clicking submit submits PAGE 2 QUESTIONS to page 3 script.

 p 3. Before displaying anything to the client, Page 3 script validates
 input from page 2 questions. If there are problems, page 3 script
 redisplays page 2 questions with highlights around problems. Clicking
 submit resubmits page 2 data to page 3 script.

 Once page 3 script validates all page 2 answers, the script stores all
 those answers to a SESSION, then sends PAGE 3 QUESTIONS ONLY (no $_POST
 information) to client. Client answers page 3 questions and clicking
 submit submits PAGE 3 QUESTIONS to page 4 script.

 At this point, if the client goes off for a bite, or two weeks
 backpacking in the Anapurna region, I'm fine, because the information is
 stored in the session (I have a very small group taking this
 questionnaire, all have a vested interested in filling it in, so I am
 not too worried abou their going aaway from it for more than a couple
 days max).

 Once they complete the last set of questions, I say thanks much, get all
 the information out of their SESSION, insert it into the db, send
 confirmation emails all around and we're done.

Sessions are used to identify users on a single visit to a website. They are
not intended to track users who turn off their machines, then turn them on
again and visit the website again. There are various ways of doing this, and
for all I know it may be possible with sessions, but I don't recommend you
try.

Do as suggested previously by various posters, it is the simplest and most
robust solution to your problem:

1. have the user register their details first up. Store this in a db, and
use it to identify the user on any subsequent visit.
2. when each page is submitted, write the information into the db. This way
it will definitely be associated with the right user
3. Whenever a user revisits the questionnaire, make them log in, then take
them to wherever they were up to - you will be able to work this out from
the amount of data you have recorded against them.

e.g. database table

tbluser
userid
password

tblanswers
userid
question1
question2
question3
question4
question5
question6
etc

Scenario 1
A user logs into the questionnaire. No row is present in tbluser for this
user, so create one, and send the user to the first page of the
questionnaire

Scenario 2
A user logs into the questionnaire. There is a row in tbluser, and
tblanswers also has a row, with data in columns userid, question1 and
question2. Direct this user to the third page of the questionnaire

I hope this is clearer

Mark


 Is this possible? How?

 Thanks!



 Marcus Bointon wrote:
  On 27 Jul 2005, at 21:22, Jack Jackson wrote:
 
 
  Right. Except I would rather have it working in a session because I
  specifically do not want to have the form sending $_POST data back
  and forth to the browser six times for several reasons. SO I'd like to
 
  Page1 // User enters first batch of data, presses SUBMIT at bottom.
  Data is cleaned and written to SESSION, user passed to Page2
 
  repeat as necessary to last page. At last page, process and error
  check newest input, then commit it, plus all previously stored
  session info to db.
 
 
  As has also been said, Javascript can do this really nicely. The best
  example I've seen of this is in Mambo's (a popular PHP CMS) admin
  interface. It uses a tabbed multi-page form with client-side
  validation. It's really just one big page, so if the user has JS  turned
  off, they will get one big form with no client-side  validation, but it
  will still work. It's a really elegant way of  working. It doesn't
  require any server interaction between pages -  nothing is submitted
  until the form is complete.
 
  See here for a howto: http://www.devx.com/webdev/Article/10483/1763/
page/1
 
  Admittedly this approach doesn't easily allow to you abandon and  resume
  later (unless you get clever with JS and cookies).
 
  For keeping data in a session, you could combine this approach with
  Ajax: 

Re: [PHP] Multipage form redux

2005-07-28 Thread Mark Rees
Jack Jackson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Somehow my intent has been turned around here and I apologise.

 I do not want to use *any* client side validation. I only want to do
 server side validation and server side storage.

 My intent was to remove the client from as much as possible of this - if
 I didn't need their information I wouldn't even allow clients!! :)

 What I wanted to do was this:


 p. 1 : I send client page one, they send answers. SUBMIT sends to page 2
 script.

 p 2. Before displaying anything to the client, Page 2 script validates
 input from page 1. If there are problems, page 2 script redisplays page
 one questions with highlights around problems. Clicking submit then
 resubmits page one data to page 2 script.

 Once page 2 script validates all page 1 answers, page 2 script stores
 all those answers to a SESSION, then sends PAGE 2 QUESTIONS ONLY (no
 $_POST information) to client. Client answers page 2 questions and
 clicking submit submits PAGE 2 QUESTIONS to page 3 script.

 p 3. Before displaying anything to the client, Page 3 script validates
 input from page 2 questions. If there are problems, page 3 script
 redisplays page 2 questions with highlights around problems. Clicking
 submit resubmits page 2 data to page 3 script.

 Once page 3 script validates all page 2 answers, the script stores all
 those answers to a SESSION, then sends PAGE 3 QUESTIONS ONLY (no $_POST
 information) to client. Client answers page 3 questions and clicking
 submit submits PAGE 3 QUESTIONS to page 4 script.

 At this point, if the client goes off for a bite, or two weeks
 backpacking in the Anapurna region, I'm fine, because the information is
 stored in the session (I have a very small group taking this
 questionnaire, all have a vested interested in filling it in, so I am
 not too worried abou their going aaway from it for more than a couple
 days max).

 Once they complete the last set of questions, I say thanks much, get all
 the information out of their SESSION, insert it into the db, send
 confirmation emails all around and we're done.

Sessions are used to identify users on a single visit to a website. They are
not intended to track users who turn off their machines, then turn them on
again and visit the website again. There are various ways of doing this, and
for all I know it may be possible with sessions, but I don't recommend you
try.

Do as suggested previously by various posters, it is the simplest and most
robust solution to your problem:

1. have the user register their details first up. Store this in a db, and
use it to identify the user on any subsequent visit.
2. when each page is submitted, write the information into the db. This way
it will definitely be associated with the right user
3. Whenever a user revisits the questionnaire, make them log in, then take
them to wherever they were up to - you will be able to work this out from
the amount of data you have recorded against them.

e.g. database table

tbluser
userid
password

tblanswers
userid
question1
question2
question3
question4
question5
question6
etc

Scenario 1
A user logs into the questionnaire. No row is present in tbluser for this
user, so create one, and send the user to the first page of the
questionnaire

Scenario 2
A user logs into the questionnaire. There is a row in tbluser, and
tblanswers also has a row, with data in columns userid, question1 and
question2. Direct this user to the third page of the questionnaire

I hope this is clearer

Mark


 Is this possible? How?

 Thanks!



 Marcus Bointon wrote:
  On 27 Jul 2005, at 21:22, Jack Jackson wrote:
 
 
  Right. Except I would rather have it working in a session because I
  specifically do not want to have the form sending $_POST data back
  and forth to the browser six times for several reasons. SO I'd like to
 
  Page1 // User enters first batch of data, presses SUBMIT at bottom.
  Data is cleaned and written to SESSION, user passed to Page2
 
  repeat as necessary to last page. At last page, process and error
  check newest input, then commit it, plus all previously stored
  session info to db.
 
 
  As has also been said, Javascript can do this really nicely. The best
  example I've seen of this is in Mambo's (a popular PHP CMS) admin
  interface. It uses a tabbed multi-page form with client-side
  validation. It's really just one big page, so if the user has JS  turned
  off, they will get one big form with no client-side  validation, but it
  will still work. It's a really elegant way of  working. It doesn't
  require any server interaction between pages -  nothing is submitted
  until the form is complete.
 
  See here for a howto: http://www.devx.com/webdev/Article/10483/1763/
page/1
 
  Admittedly this approach doesn't easily allow to you abandon and  resume
  later (unless you get clever with JS and cookies).
 
  For keeping data in a session, you could combine this approach with
  Ajax: 

Re: [PHP] Multipage form redux

2005-07-28 Thread Mark Rees
André Medeiros [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 The point of sessions is that when you close your browser, you loose it.
 I'm affraid that if you want sessions that last two weeks, you'll have
 to make your own session handler :) but yeah, it's possible, and it
 beats the crap out of the fill form, store in db, fill form, store in
 db method.

Unless your user wishes to complete the form from a different machine, of
course.

I really don't understand the dogmatic antipathy to storing information in
the database. Sometimes it is a better solution - horses for courses.
Rolling your own session management tool, whilst undoubtedly fun and
satisfying, is hardly an appropriate solution to this type of enquiry, which
is apparently from someone taking their first steps in web development.

I should probably explain that I come from an ASP background and so have an
inherent mistrust of sessions, although I am coming to understand that PHP
sessions are much more reliable.

Sorry about the three posts before, my mistake.

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



Re: [PHP] php mySql question

2005-07-27 Thread Mark Rees
Yes, it is quite possible that you have more than one php.ini file. Check
this and delete as appropriate.
Shaw, Chris - Accenture [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
...

Have you tried doing a search for the text php5 in the php.ini file that
sits in your c:\windows folder?

C.

-Original Message-
From: Ned Kotter [mailto:[EMAIL PROTECTED]
Sent: 26 July 2005 04:03
To: php-general@lists.php.net
Subject: [PHP] php mySql question


I have installed php 5.0.4 on my windows 2000, IIS 6.0 server.  PHP works
but
when I try to connect to MySQL I get the Fatal error: Call to undefined
function mysql_connect().  I have uncommented the line in the php.ini file
that says 'extension=php_mysql.dll'.  I have path variables set for both
c:\php and c:\php\ext.  One very peculiar thing that I noticed when I ran
phpinfo() is that it shows the extension_dir is set to c:\php5 even though
in
my php.ini file it is set to c:\php.  I have a feeling that this is where
the
problem exists.  Any advice would be appreciated.

Thanks,
NK


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com




This message has been delivered to the Internet by the Revenue Internet
e-mail service

*

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



Re: [PHP] Multipage form redux

2005-07-27 Thread Mark Rees
André Medeiros [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Wed, 2005-07-27 at 07:51 -0400, Jack Jackson wrote:
  Hi,
  I have searched the archives and seen links to tutorials at phpclasses
  (which seem to be down) and not found an answer to my question:
  I have a long form I want to break into seven pages. Rather than pass
  values from page to page as hidden, I'd rather write the results to the
  db after each page then move on.
 
  Anyone know of any tutorials on this?
 
  Thanks in advance,
  JJ
 

 That's not a very good idea. Imagine the user gets to the fourth form
 and gets a cup of coffee, or goes out to lunch. By the time he gets to
 the computer he might have lost the session, thus having data on your DB
 that is wasting space.

 And what if the user closes the browser window? :)

 Bad bad idea.

What if the form takes ages to fill out, and the user has to go away and
find out other information, then wants to come back to the form and see it
pre-filled? For an insurance quote, say?

It could be a good idea under those circumstances. You can always delete all
incomplete data with a cron job every week or so if needs be.

Do you know how to write data to a db? The mechanics of what you want to do
are not especially complex.

page 1
form vars
page 2
request form vars, write to db, display form
etc

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



Re: [PHP] preg_match - help please

2005-07-27 Thread Mark Rees
André Medeiros [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Wed, 2005-07-27 at 15:27 +0100, Steve Turnbull wrote:
  Hi
 
  I want to see that a user is submiting a form field in the correct
manner.
  So I decided to use preg_match to verify their input.
 
  The pattern I am trying to match is;
 
  Firstname Secondname
 
  I am not bothered about character length just yet (but advise on this
would
  be appreciated if it can be done with a regular expression - saves extra
  checking code), but I would like case sensitity.
 
  The code I haev so far, which doesn't seem to work is;
 
  $un = $_REQUEST['name'];
  $exp = '/^\b[a-zA-Z] [a-zA-Z]$/';
 
  if (preg_match($exp, $un)) {
  //has this matched?
  echo h2matched/h2;
  }
 
  Help would be greatly appreciated
 
  Thanks
  Steve
 

 A reminder... sometimes First and Last name can contain three words.
 There are portuguese names, like Inês de Medeiros. Watch out for that
 too.

Or even four - like Rafael van der Vaart for example - so make sure that the
surname box matches spaces as well, and special characters like the ê, as
well as ' as in John O'Kane

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



Re: [PHP] MySQL + PHP question

2005-07-26 Thread Mark Rees
Are you familiar with Joe Celko's tree theory? It might help you understand
more about the problem.

http://www.intelligententerprise.com/001020/celko.jhtml?_requestid=235427

--

Hello,

Consider this:
tbl_project(id, name, parent)

1   6
   / \ / \
  2   3 7   8
/\
4  5

if tbl_project.parent = 0 then the project is the top parent.
Therefore, 1 and 6 have the field parent = 0.

So, say if you have project 5, do you want to find out its parent (2), or do
you want to find out all its parents including grandparents (2) and (1)?

What do you need to know?

C.
-Original Message-
From: André Medeiros [mailto:[EMAIL PROTECTED]
Sent: 26 July 2005 12:18
To: php-general@lists.php.net
Subject: [PHP] MySQL + PHP question

Hi guys.

I'm having some trouble here regarding a project. I have a table with
projects, wich can be recursive (ie. sub-projects) and it is related to
itself.

By making the following query

-8--
SELECT * FROM projects LEFT JOIN projects proj_parent ON
projects.project_parent = proj_parent.parent_id WHERE project_id = 1234
-8--

i need to be able to access to the parent project's fields, but I have a
slight problem here.

First off, I have to make the LEFT JOIN. I don't know if the project can
be parent (therefore not finding a project_id = 0 wouldn't show the row)
and I need to add some kind of prefix to the proj_parent's fields so
that I can access them (or that they can't overwrite the project i'm
getting info on.

Well... there is an obvious sollution here: use an associative array
instead of an object, and access the properties by doing $array[0],
$array[1], etc. By my experience, this is a nightmare, maintenence-wise,
so I'd only use it as a _LAST_ resource.

Does anyone have any experience with this? The answer should be pretty
obvious, but I can't seem to figure it out :(

Thanks in advance.

André

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



Re: [PHP] MySQL + PHP question

2005-07-26 Thread Mark Rees
André Medeiros [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 One thing I didn't quite explain myself well... I'm building this to
 register objects on a permission system.

 The SQL weight is heavy as it is, and I want to save queries as much as
 possible. Making two queries to extract information about a project and
 it's parent is not something I'd want to do. I know recursiveness, but
 thanks for the pointers and for the reply :)

 Best regards

I must admit I still don't really get what you are looking for. Does this
query help?

select c.field1 AS childfield1,
c.field2 AS childfield2,
(etc)
p.field1 AS parentfield1,
p.field2 AS parentfield2,
(etc)
FROM
child AS c
LEFT JOIN
parent AS p
ON c.parent=p.id

?

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



[PHP] Re: function MAX with WHERE

2005-07-25 Thread Mark Rees
Jesús Alain Rodríguez Santos [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have someting like this:

 $test = mysql_query(SELECT MAX(dato) AS datos FROM tabla WHERE campo_mes
 = '$mes');
 $test_m = mysql_fetch_array($test);
 $test_mes = $test_m['datos'];

 print $test_mes

 where $mes is a value
 I need to know if something its wrong, because I don't recive any error,
 but I see nothing

Try this, it will tell you if something is wrong

echo  mysql_error();

If nothing is wrong, then perhaps your query returns no rows? Test this by
removing the where clause (assuming there is some data in tabla).

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



[PHP] Re: still some problems with contact form

2005-07-21 Thread Mark Rees
Hello Mark

An alternative (and more user-friendly) approach is to have the form's
action as itself (i.e. the form on contact.php submits to contact.php). You
can then identify which fields are incomplete and highlight them in the
form. This will make it easier for users to see what they have done wrong
and make the necessary corrections.

in regards to this response on my contact form issues, how would I do
these which you mention.

currentlly the form is:

form method=post action=Thankyou.php class=info_request

and the Thankyou.php code consit of what I posted on the forum.

thanks for all of your help!!


A sample set up is as follows, with much room for improvement and
refinement, but it should give you the basic idea.

contact.php
?php
#check that the form has been posted
$email=isset($_POST['email'])?$_POST['email']:'';

$emailerror=false;
if($email!=''){
#basic validation passed, so redirect
header(Location: Thankyou.php);
}else{
$emailerror=true;
}?
emailbr
form method=post action=contact.php class=info_request
input type=text name=email value=?=$email;?
?
if($_POST){
#show the input with a red background if the form has been posted and
if($emailerror==true)print 'style=background-color:red;';
}
?
input type=submit value=submit
/form

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



[PHP] Re: still some problems with contact form

2005-07-20 Thread Mark Rees
An alternative (and more user-friendly) approach is to have the form's
action as itself (i.e. the form on contact.php submits to contact.php). You
can then identify which fields are incomplete and highlight them in the
form. This will make it easier for users to see what they have done wrong
and make the necessary corrections.

This is what print does
http://uk2.php.net/manual/en/function.print.php

echo
http://uk2.php.net/echo

and the difference is discussed here, although it probably won't concern you
too much for the moment.
http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40


Bruce Gilbert [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
thanks, makes some sense.

so now where I have echo, I should have print? or just leave as echo
and add the else and ||?

Could you provide some sample code based on the code I posted
previously by chance??

being new to PHP I am sure I will run into errors for a few days, as is...

that would help me out greatly.



thx,

On 7/19/05, James [EMAIL PROTECTED] wrote:
 This is what you have done

 if(something happens) {
 print error;
 }

 print thanks for sending the form!

 So basically you are printing the error and then thanking them. You need
to

 include an ELSE bracket. Like so..

 if(this error || that error || some other error) {
 print error;
 } else {
 //no errors, thank them!
print THANKS!
 }

 - Original Message -
 From: Bruce Gilbert [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Tuesday, July 19, 2005 5:52 PM
 Subject: [PHP] still some problems with contact form


 Hello,

 on my web site contact form:

 http://www.inspired-evolution.com/Contact.php

 I am still having a few problems with the return results after filling
 out the form. Basically I am wanted to return an error msg. when all
 of the required fields are not filled out (those with a red *), and an
 invalid email address will also return an error.

 filling out all of the information correctly will result in a
 thank-you paragraph, we have received your submission etc.

 Right now even if you don't fill out the required fields, you still
 get my thank-you message for filling out the form correctly (as well
 as getting the error msg.). If someone has a chance try out the form
 yourself and you will see what I mean.

 What I would really like to have is a thank-you page when the form is
 completed sucussfully and an oops! page when there is an error. SO we
 are talking two different pages, based upon the results of the form
 information...

 The PHP code I have for the return info. currenty is:

 ?php

 $firstname = $_POST['firstname'];
 $lastname = $_POST['lastname'];
 $company = $_POST['company'];
 $phone = $_POST['phone'];
 $email = $_POST['email'];
 $email2 = $_POST['email2'];
 $URL = $_POST['URL'];
 $Contact_Preference = $_POST['Contact_Preference'];
 $Contact_Time = $_POST['Contact_Time'];
 $message = $_POST['Message'];

 if ((!$firstname) || (!$Contact_Preference)) {

 echo'pstrongError!/strong Fields marked span class=red
 */span are required to continue./pbr /';
 echo'pPlease go back to the a href=Contact.phptitle=Contact
 MeContact Me/a page and try it again!/p';
 }

 if

(!eregi(^[a-z0-9]+([_\\.-][a-z0-9]+)*.@.([a-z0-9]+([\.-][a-z0-9]+)*)+.
\\.[a-z]{2,}.$,$email))
 {

 echo 'pInvalid email address entered./pbr /';
 echo 'pPlease go back to the a href=Contact.php title=Contact
 MeContact Me/a page and try it again!/p';



 }
 if (($email) != ($email2)) {

 echo 'strongError!/strong e-mail addresses dont match.br /';


 }

 $email_address = [EMAIL PROTECTED];
 $subject = There has been a disturbance in the force;

 $message = Request from: $firstname $lastname\n\n
 Company name: $company\n
 Phone Number:  $phone\n
 Email Address: $email\n
 URL: $URL\n
 Please Contact me via: $Contact_Preference\n
 The best time to reach me is: $Contact_Time\n
 I wish to request the following additional information: $Textarea;

 mail($email_address, $subject, $message, From: $email \nX-Mailer:
 PHP/ . phpversion());

 echo pHello, strong$firstname/strong.br /br /
 We have received your request for additional information, and will
 respond shortly.br /
 Thanks for visiting inspired-evolution.com and have a wonderful day!br
 /br /
 Regards,br /br /
 strongInspired Evolution/strong/p;

 ?

 any assistance/guidance is greatly appreciated. Thanks list!

 Bruce G.
 http://www.inspired-evolution.com

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




--
::Bruce::

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



Re: [PHP] problems with self referential sticky forms

2005-07-20 Thread Mark Rees

eoghan [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On 20 Jul 2005, at 02:22, Linda H wrote:

  fahreheit is here:
 
  ?
  $fahr = $_GET['fahrenheit'];
  if (is_null($fahr)){ echo 'fahr is null';}
  $
 
  The error was on the line: $fahr = $_GET['fahrenheit'];

 try:
 input name=fahrenheit type=text  value=?php echo $fahr; ? /

Do as previously suggested and check that

$fahr=isset($_GET['fahrenheit'])?$_GET['fahrenheit']:null;

(although since you are dealing with a string here, perhaps an empty string
''might be a better bet than null)
then your test is

if($fahr==''){echo 'fahr is empty');

note the semicolon at the end of each line, and your closing php tag should
be ?, not $

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



[PHP] Re: checking for internet connection

2005-07-20 Thread Mark Rees

Steven [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi

 I am looking for a simple way to check if the server is connected to the
 Internet, they use a dialup to get Internet connection, and I need to
 email reports out, but want to check to see if the user remembered to
 connect to the Internet first.  If anybody has a nice script, or just a
 suggestion on a php function I could use to test for an Internet
connection.


You could try curl or fsockopen to see if there is a connection. But really,
is this necessary? You don't test to see if the computer's plugged in, do
you? So why test for this? Surely your user will have enough nous to connet
to the internet forst, and if they don't, then it just won't work.


 Thanks
 steve

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



Re: [PHP] sytax errors

2005-07-19 Thread Mark Rees
John Nichel [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 babu wrote:
  Hi,
 
  could someone please check where the sytax error is in these statements.
 
  $sqlstmt= EXEC sp_addlogin .$adduser. , .$addpass;
  $sqlstmt1= EXEC sp_adduser  @loginame= .$adduser. , @name_in_db=
.$adduser;
  $sqlstmt2= GRANT CREATE TABLE TO .$adduser;
  $sql=mssql_query($sqlstmt);
  $sql1=mssql_query($sqlstmt1);
  $sql2=mssql_query($sqlstmt2);

 Didn't php give you a line number?

Is it a php or mysql syntax error? If the latter, please echo $sqlstmt etc
and show us the output

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



[PHP] Re: session data not recorded

2005-07-18 Thread Mark Rees
Alessandro Rosa [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have a problem to record session data and I would you
 help me. I suppose there's something I missed in the general
 configurations during the last install, but I can't realize it.

Review the settings in php.ini. In particular look at the one below, which
means that the session data is persisted by means of cookies.

; Whether to use cookies.
session.use_cookies = 1


 I arranged a couple of simple files handling sessions, to show you my
 problem.

 I have a file index.php :
 --
-
 ?php session_start();

 $_SESSION['user'] = User;
 $_SESSION['psw'] = Psw;


What happens if you try to echo these variables in index.php?

 ?

 a href=page2.phpGo!/a
 --
-

 and then the file page2.php :

 --
-
 ?php session_start();

 echo $_SESSION['user'];
 echo br/;
 echo $_SESSION['psw'];

 ?
 --
-

 But when page2.php is loaded, then a blank page is displayed.

 What's wrong with this?
 Thanks in advance.

 Alessandro

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



Re: [PHP] Re: Need help with PHP / MySQL connect problem

2005-07-18 Thread Mark Rees
Linda H [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I added the following to the top of my script:

 ?php
echo phpinfo();
 ?

 Got all sorts of environment and path info. Not anything about MySQL, but
I
 didn't see anything that looked obviously wrong, though I don't understand
 a lot of it.

 I ried reinstalling MySQL, Apache, and PHP. No change.

 Linda

What does php.ini have for this line

display_errors = On

If it's off, set it on.

Mark

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



[PHP] Re: Post URL ?

2005-07-18 Thread Mark Rees
Joey [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 OK I understand the difference between a get  a post but if I just have a
 URL/link which is calling a function like so:

 abc.com/display_information?customer_number=$value

 It passes to the display_information the customer number visably, is there
a
 way to do this where it's not visable?

 Thanks,

 Joey


What problem are you trying to solve here? Is it a matter of security? Are
you for example trying to stop people from seeing other users' details by
pasting in their customer number?

If so, you could require a password.
If it's important to hide the customer number, you can use a semantically
meaningless key to look it up in the db.

If you don't want it to appear in the url, make a POST request, store it in
a cookie or a session.

It all depends on what you actually want to do.

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



[PHP] Re: re-order a sql result

2005-07-18 Thread Mark Rees

Ross [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have a query

 $query = SELECT * FROM sheet1 WHERE '$filter' LIKE '$search_field%'


Simply requery the database for each search. For example, this orders the
results by surname from a-z

 $query = SELECT * FROM sheet1 WHERE '$filter' LIKE '$search_field%'
ORDER BY surname ASC;




 This prints out a table

  while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){

 // this just fills the empty cells

 if ($row['fname']==){
 $row['fname']=nbsp;;
 }
 if ($row['sname']==){
 $row['sname']=nbsp;;
 }
 if ($row['organisation']==){
 $row['organisation']=nbsp;;
 }

 ?

 td width=71 class=right_line  ?=$row['fname'];? /td
 td width=45 class=right_line?=$row['sname'];?/td
  td width=437 class=right_line?=$row['organisation'];?/td
  ? if (!$row['email']==){
  ?
 td width=165 class=end_cell  div align=lefta

href=view_details.php?id=?=$row['id'];?sname=?=$row['sname'];?detail
s/a
 | a
href=edit.php?id=?=$row['id'];?sname=?=$row['sname'];?edit/a
 | a
 href=delete.php?id=?=$row['id'];?sname=?=$row['sname'];?delete/a
I
 a href=mailto:?=$row['email']; ?email/a/div/td
  ?
  }
  else {
  ?
  td width=171 class=end_cell  div align=lefta

href=view_details.php?id=?=$row['id'];?sname=?=$row['sname'];?detail
s/a
 | a
href=edit.php?id=?=$row['id'];?sname=?=$row['sname'];?edit/a
 | a
 href=delete.php?id=?=$row['id'];?sname=?=$row['sname'];?delete/a
I
 a href=mailto:?=$row['email']; ?empty/a/div/td
  ?
  }
  ?



 /tr
  ?
  }
  }
  ?



 but I have the three headings  at the top which I want to use to re-order
 the results alphabetically. So when I click on surname it will re-reorder
 them aphebetically (z-a) and when I click on it again it will reverse it
 (a-z)

 td class=right_linestrongFirstname/a/strong/td
 td class=right_linestrongSurname/strong/td
 td class=right_linestrongOrganisation/strong/td


 hope this is clear.

 Ross

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



Re: [PHP] Re: Need help with PHP / MySQL connect problem

2005-07-18 Thread Mark Rees
Linda H [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 For those who didn't join this thread at the beginning, I'm running MySQL
 4.0.21, Apache 2.0.52 and PHP 5.0.2 on a Windows XP system.

 I installed in the sequence - MySQL, then Apache, then PHP. MySQL was
 running when the others were installed (which is what the book I am using
 seemed to indicate). Apache was not running when PHP was installed.

 What does php.ini have for this line
 display_errors = On

 Now we are getting somewhere. Even though error_reporting was set to
E_ALL,
 display_errors was Off. I set it On and now I'm getting an error.

 Fatal error: Call to undefined function mysql_connect() in C:\Program
 Files\Apache Group\Apache2\htdocs\example\test_connect.php on line 15

 the phpinfo() display doesn't reference MySQL at all. It does reference
 SQLite with the following info:

 SQLite supportenabled:
 PECL Module version 2.0-dev $Id: sqlite.c,v 1.146.2.2 2004/08/02 22:43:42
 iliaa Exp $
 SQLite Library: 2.8.14
 SQLite Encoding: iso8859

 Directive: sqlite_assoc_case, Local Value: 0, Master Value: 0

 So it looks like MySQL didn't get configured with PHP.

 In the PHP FAQ on database issues, I found the following:

 
 4. PHP 5 no longer bundles MySQL client libraries, what does this mean to
 me? Can I still use MySQL with PHP? I try to use MySQL and get function
 undefined errors, what gives?

 Yes. There will always be MySQL support in PHP of one kind or another. The
 only change in PHP 5 is that we are no longer bundling the client library
 itself. Some reasons in no particular order:
 * Most systems these days already have the client library installed.
 * Given the above, having multiple versions of the library can get
 messy. For example, if you link mod_auth_mysql against one version and PHP
 against another, and then enable both in Apache, you get a nice fat crash.
 Also, the bundled library didn't always play well with the installed
server
 version. The most obvious symptom of this being disagreement over where to
 find the mysql.socket Unix domain socket file.
 * Maintenance was somewhat lax and it was falling further and further
 behind the released version.
 * Future versions of the library are under the GPL and thus we don't
 have an upgrade path since we cannot bundle a GPL'ed library in a
 BSD/Apache-style licensed project. A clean break in PHP 5 seemed like the
 best option.

 This won't actually affect that many people. Unix users, at least the ones
 who know what they are doing, tend to always build PHP against their
 system's libmyqlclient library simply by adding the --with-mysql=/usr
 option when building PHP. Windows users may enable the extension
 php_mysql.dll inside php.ini. Also, be sure libmysql.dll is available to
 the systems PATH. For more details on how, read the FAQ on

http://www.php.net/manual/en/faq.installation.php#faq.installation.addtopat
hsetting
 up the Windows systems PATH. Because libmysql.dll (and many other PHP
 related files) exist in the PHP folder, you'll want to add the PHP folder
 to your systems PATH.

 I added my PHP folder (C:\php5\) to my system path and restarted
 (libmysql.ddl is in php5). Still get the error. I enabled the extension
 php_mysql.dll in php.ini and Apache startup says it can't find it
 (php_mysql.dll is in C:\php5\ext).

Make sure this is set as follows in php.ini, then restart apache

extension_dir = c:\php\ext


 So, should I move php_mysql.dll to c:\php5, change the system path, or
 what? And what about php.ini showing sqlite instead of MySQL? Do I need to
 get the MySQL client libraries (what are they called and where do I put
 them - I already have some mysql dll's in the PHP libraries.

 Linda

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



[PHP] Usability review - OT

2005-07-15 Thread Mark Rees
Hello

Sorry for the OT request.

Does anyone know of anywhere I can get my website picked apart from a
usability point of view? I'm thinking of general first impressions rather
than an in-depth review of functionality.

Thanks

Mark
--
www.itsagoodprice.com - top-brand electronics for less.



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



Re: [PHP] Refresh

2005-07-14 Thread Mark Rees
david forums [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 well I see two way.

 First is to make a php script without end, which will run continuously.

I don't recommend this way at all. Why take up all that energy


 second way is to add refresh html tag, in your page, or a js script to
 reload automaticaly.

Much better and simpler idea, you can use an http header to do this.

http://4umi.com/web/html/httpheaders.htm has a list of them

Third idea, which may be overkill, depending on how important this
information is, how many people will be accessing it, and whether people
_need_ to see it real time.

set up a cron job/scheduled task to read the db value every 30 seconds, say,
and write out a flat html page with the latest data in. This is only of
value if your db is getting hammered by requests.

I only really mention this as it's the Open Golf Championship this week, and
I used to work on their live scoring app, which pretty much worked as above.


 I'm not seeing other solution in php.

 regards

 Le Thu, 14 Jul 2005 02:27:47 +0200, Miguel Guirao
 [EMAIL PROTECTED] a écrit:

 
 
  Hello people,
 
  I need to have a web page (PHP) that displays a status about electric
  facilities, this status is read from a database (MySQL), the thing is
  that
  these status may change from time to time in the DB so I need to re read
  the
  DB and display the according status on the web page.
 
  So, Is there a way to refresh or reload the page every 10 minutes
  automatically?
 
  Regards,
 
  ---
  Miguel Guirao Aguilera
  Logistica R8 TELCEL
  Tel. (999) 960.7994
  Cel. 9931 600.
 
 
  Este mensaje es exclusivamente para el uso de la persona o entidad a
  quien esta dirigido; contiene informacion estrictamente confidencial y
  legalmente protegida, cuya divulgacion es sancionada por la ley. Si el
  lector de este mensaje no es a quien esta dirigido, ni se trata del
  empleado o agente responsable de esta informacion, se le notifica por
  medio del presente, que su reproduccion y distribucion, esta
  estrictamente prohibida. Si Usted recibio este comunicado por error,
  favor de notificarlo inmediatamente al remitente y destruir el mensaje.
  Todas las opiniones contenidas en este mail son propias del autor del
  mensaje y no necesariamente coinciden con las de Radiomovil Dipsa, S.A.
  de C.V. o alguna de sus empresas controladas, controladoras, afiliadas y
  subsidiarias. Este mensaje intencionalmente no contiene acentos.
 
  This message is for the sole use of the person or entity to whom it is
  being sent.  Therefore, it contains strictly confidential and legally
  protected material whose disclosure is subject to penalty by law.  If
  the person reading this message is not the one to whom it is being sent
  and/or is not an employee or the responsible agent for this information,
  this person is herein notified that any unauthorized dissemination,
  distribution or copying of the materials included in this facsimile is
  strictly prohibited.  If you received this document by mistake please
  notify  immediately to the subscriber and destroy the message. Any
  opinions contained in this e-mail are those of the author of the message
  and do not necessarily coincide with those of Radiomovil Dipsa, S.A. de
  C.V. or any of its control, controlled, affiliates and subsidiaries
  companies. No part of this message or attachments may be used or
  reproduced in any manner whatsoever.
 

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



[PHP] Re: gettext best practice

2005-07-14 Thread Mark Rees

Skippy [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 How do you people best deal with text meant for i18n via gettext, which is
 either large or contains HTML tags, or both?

 The GNU gettext manual, in section 3.2, recommends to split long texts at
 paragraph level, or in the case of long --help screens, in batches of 5-10
 lines at most. I can dig this, but I'd still appreciate some feedback.

 Formatting, however, is a slightly different issue. The manual seems to
have
 been written mainly for C users, and as such only deals with spaces, tabs
and
 newlines.

 Of course, structural HTML is a big no-no IMO (ie. the likes of p, li
or
 tables). But styling HTML is often needed (strong, em ...). Am I right
in
 assuming that a small set of pure style-related HTML should be allowed?
I'm
 thinking strong, em, del and ins. The alternative of replacing
them
 with %s instead and inserting them in the code on the fly looks like an
 attrocity to me.


Consider whether you will always display the information in a web browser.
If there is any possibility that another program may be used for display,
you don't want the HTML tags in the database.

 And allowing any tags still doesn't make me 100% happy; consider
borderline
 complications due to HTML vs XHTML, or the very principle of separating
 content from presentation, which seems to be breached.

 And how should br be dealt with? Allow it, or go with newlines instead,
and
 decide in the code if I want to apply a nl2br() or not?

 --
 Romanian Web Developers - http://ROWD.ORG

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



[PHP] Re: Win2000 easier than Win2003 ??

2005-07-14 Thread Mark Rees
Grosz, Steve (IPG IT) [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
..
Is setting up PHP easier on Windows 2000 server rather than Win2003?
I'm having nothing but problems getting PHP files to show up in IE on
the Win2003 server, I get nothing but 404 - file not found errors.

Can you install Apache? It's straightforward to set up. I've done it on
three different win2k boxes without any problems. Top tip is to stop IIS
before attempting to install Apache

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



[PHP] Re: Number of users

2005-07-12 Thread Mark Rees

[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Hello all,



I have some questions and I hope someone could answer them



1.   Is there a way to find out how many users currently browsing pages
at my web site?

2.   If I write down the IP of a user that log on my web site, can I
check later if the IP still browsing pages at my web site or if he had left
my website?

--
There are various ways to achieve this.  You could use session variables,
cookies or store the information in a database and pass the lookup value
around in a querystring. Which you choose will depend a little on how robust
you want it to be, and how your website is set up. You should probably start
off by reading up on sessions - there is plenty to dip into here:

http://www.google.co.uk/search?q=php+sessionsourceid=mozilla-searchstart=0
start=0ie=utf-8oe=utf-8client=firefox-arls=org.mozilla:en-GB:official

 

Thanks

yaron

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



[PHP] Re: Plz, help

2005-07-12 Thread Mark Rees
adolfas [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 I have a line:

 $sql=select u.*, p.name_lt as pareiga from nese_users u left join
 nese_pareigos p on p.id=u.pareiga order by data desc;

 As I understand there are 2 tables: nese_users and nese_pareigos
 I need to know what atributes belong to what table form that line.
 Thanks

I hope this is what you mean. Try this for further reading if so
http://www.w3schools.com/sql/default.asp

Breaking it down:

select
--retrieve the following fields
u.*,
--* means all fields from this table (u)
p.name_lt as pareiga
-- and name_lt (renamed to pareiga) from table (p)
from
nese_users u
--(this is table u, as in u.*)
left join
--retrieve all of the rows from table u, as well as all the rows in the next
table where the ON condition is true
 nese_pareigos p
--this is table p, as in p.name_lt
on
p.id=u.pareiga
--this restricts the rows retrieved from table p
order by data desc
--means that the rows returned are ordered in this way

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



Re: [PHP] error when trying to delete a record

2005-07-11 Thread Mark Rees
Jay Blanchard [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
[snip]
$query= DELETE FROM sheet1 WHERE id=$id;

You have an error in your SQL syntax; check the manual that corresponds
to
your MySQL server version for the right syntax to use near '' at line 1
[/snip]

try...

$query= DELETE FROM sheet1 WHERE id = '.$id.' ;

Note the single quotes around conditional data. Imagine if $id = 1 and
you did your original query, it would read...

$query= DELETE FROM sheet1 WHERE id=1;

Which is where id = TRUE. You could end up deleting all of the records
in the database.

---

Is the above statement true when the id field is numeric (which it surely is
in this case)? I get the expected results (in mySQL) when using statements
like

SELECT name FROM table WHERE id=1

with no single quotes round it. Putting quotes round integer values is
counter-intuitive - is it necessary in some cases?

---

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



Re: [PHP] Writing a PHP Web application

2005-07-01 Thread Mark Rees
Philip Hallstrom [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
  What are the options to get code to run on the server (every XX
  minutes), without any user interaction, etc.

 If you are running on a unix like system (linux, freebsd, solaris, etc.)
 cron can do this for you.  See this: http://en.wikipedia.org/wiki/Cron

 If on windows there are probably scheduling applications, but I don't know
 anything about them.

Start--Settings--Control Panel--Scheduled Tasks

You can use this to run scripts written in whatever language you like to
perform the sort of tasks you want to.


  Example 1: If I have a directory that contains files, can I write a
  script that will delete all files older that 5 days?

 Yes.  Write the script to do what you want it to do and then have cron
 execute it on the time period you define.

  Example 2: If I write an email web application, and the user wants to
  send an email to 50 people, can I write a script that will send emails
  individually XX seconds apart from each other, but have the progress
  interfaced with the web page the user is on so they can see the
  percentage progress of sent emails.

 Yes.  This is a bit trickier as you would need to coordinate with a
 backend process that looks for emails that are ready to send them, does
 the sending and also writes out some status info (either to a temp file or
 to a database, or to shared memory).  Then your web page would need to
 repeatedly check that status to update the user on the progress.

  Also,  back to the email example, is it possible that once an email is
  composed and sent, that the web application can scan the email for
  viruses, then show a message to the user if a virus was found in their
  email, if no virus found, the email is then sent to the users as above.

 Yes.  You could install a virus scanner such as ClamAV
 (http://www.clamav.net/) and have it scan the message prior to handing it
 off to the backend process that does the sending.

  How would I scan an email for viruses (or spam?)?

 Same idea, but use something like SpamAssassin
 (http://spamassassin.apache.org/)

  And, scan it only once so that system resources are not used to scan
  unnecessarily for every recipient?

 Sure. Just do it before handing it off to the script that actually does
 the mailing...

 -philip

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



[PHP] cUrl and proxies

2005-06-30 Thread Mark Rees
Hello

This code gives me a 407  Proxy Authentication Required message. Can anyone
see what is missing? The username and password are definitely correct, as
are the proxy IP and port.

Win2k. php 5.0.4

$ch=curl_init();
curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1');
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch,CURLOPT_PROXY,'10.0.0.8:8080');
curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123');
$ret = curl_exec($ch);

Thanks in advance

Mark

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



[PHP] Re: cUrl and proxies

2005-06-30 Thread Mark Rees
UPDATE: I think it is a bug in cURL, according to this link (I am using an
ISA proxy).

https://sourceforge.net/tracker/?func=detailatid=100976aid=1188280group_i
d=976

So all I need to do is install the latest version of cURL then. I am really
struggling with this - I don't have a good understanding of how PHP and cURL
interact. I already have the necessary dlls on my machine :

php_curl.dll
libeay.dll
ssleay.dll

But what can I download from

http://curl.haxx.se/download.html

I don't see any of those files there, and the windows package includes only
curl.exe - where does that fit in?

The readme files in the package I did download don't really help either:
http://curl.haxx.se/dlwiz/?type=*os=Win32flav=-ver=2000%2FXP

Please help if you can

Mark

Mark Rees [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello

 This code gives me a 407  Proxy Authentication Required message. Can
anyone
 see what is missing? The username and password are definitely correct, as
 are the proxy IP and port.

 Win2k. php 5.0.4

 $ch=curl_init();
 curl_setopt ($ch, CURLOPT_URL, 'http://www.google.com/');
 curl_setopt($ch, CURLOPT_HEADER, 1);
 curl_setopt($ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1');
 curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
 curl_setopt($ch,CURLOPT_PROXY,'10.0.0.8:8080');
 curl_setopt($ch,CURLOPT_PROXYUSERPWD,'abc:123');
 $ret = curl_exec($ch);

 Thanks in advance

 Mark

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



RE: [PHP] dynamic drop down

2005-06-02 Thread Mark Rees
The dropdown list is on the client (browser). Javascript runs on the
client. PHP runs on the server. 

You have 2 options 

- one is to do as Richard says and use javascript to change the contents
of one select box when an option is selected in another. 
- the other is to refresh the page when the option is selected and write
different data into the second select box based on the option selected.
This is a question of using echo and iterating through the data you wish
to output.


-Original Message-
From: Danny Brow [mailto:[EMAIL PROTECTED] 
Sent: 01 June 2005 07:08
To: PHP-Users
Subject: Re: [PHP] dynamic drop down


On Tue, 2005-05-31 at 22:08 -0700, Richard Lynch wrote:
 On Tue, May 31, 2005 8:48 pm, Danny Brow said:
  Could someone point me to an example with code for dynamic drop 
  downs in PHP? I would like to be able to have drop downs like 
  Select Country and another drop down show the states/provinces 
  based on the selected country.
 
 Well, the dynamic part of it isn't gonna be in PHP at all ; It's 
 gonna be JavaScript.

I thought I'd have to use JS, but was hoping someone knew a way to do it
with PHP.


 You can Google for JavaScript dynamic menus to find what you want.  
 Then you just need to use PHP to spew out the JavaScript you want to 
 spew out, but that's no different than spewing out the HTML you want 
 to spew out, really.

Tons on google, thanks,

Dan.

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND REGISTERED FOR 
ISO 9001:2000 CERTIFICATION

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] Php with mysql

2005-05-23 Thread Mark Rees
This is a beginner's guide to SQL syntax, please review it
http://www.webdevelopersnotes.com/tutorials/sql/mysql_guide_querying_mys
ql_tables.php3?PHPSESSID=fb6c7c7a548b6a271a75d623ce04cc9c

The answer to your question (which someone has already given in a
previous reply to you) is 

SELECT `User_name` , (replaces AND) `User_pass` FROM `user` 
WHERE `User_name` = '$_POST['user_id']' AND  '$_POST['user_id']'

-Original Message-
From: Rittwick Banerjee [mailto:[EMAIL PROTECTED] 
Sent: 23 May 2005 09:01
To: php-general@lists.php.net
Subject: [PHP] Php with mysql


Hi friends,

I am Rittwick Banerjee

Some one gave me an idea about that past php code that is :

$sql = SELECT `User_name` AND `User_pass` FROM
`user` 
WHERE `User_name` = '$_POST['user_id']' AND  '$_POST['user_id']' ;

but I found that it still not working ...
Plaese give me another code , by the way I am using Fedora 2(PCQ Linux
2004)

Thank you..

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] Php with mysql

2005-05-23 Thread Mark Rees
(posted again with another syntax error corrected)

This is a beginner's guide to SQL syntax, please review it
http://www.webdevelopersnotes.com/tutorials/sql/mysql_guide_querying_mys
ql_tables.php3?PHPSESSID=fb6c7c7a548b6a271a75d623ce04cc9c

The answer to your question (which someone has already given in a
previous reply to you) is 

SELECT `User_name` , (replaces AND) `User_pass` FROM `user` 
WHERE `User_name` = '$_POST['user_id']' AND (PASSWORD= ADDED HERE)
PASSWORD='$_POST['user_id']'

-Original Message-
From: Rittwick Banerjee [mailto:[EMAIL PROTECTED] 
Sent: 23 May 2005 09:01
To: php-general@lists.php.net
Subject: [PHP] Php with mysql


Hi friends,

I am Rittwick Banerjee

Some one gave me an idea about that past php code that is :

$sql = SELECT `User_name` AND `User_pass` FROM
`user` 
WHERE `User_name` = '$_POST['user_id']' AND  '$_POST['user_id']' ;

but I found that it still not working ...
Plaese give me another code , by the way I am using Fedora 2(PCQ Linux
2004)

Thank you..

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades,
D-Link, Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO
9001 2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not
the intended recipient, please notify the sender IMMEDIATELY; you should
not copy the email or use it for any purpose or disclose its contents to
any other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may
not necessarily reflect the view of Gamma Global (UK) Ltd. Be advised
that no content herein may be held binding upon Gamma Global (UK) Ltd or
any associated company unless confirmed by the issuance of a formal
contractual document or Purchase Order,  subject to our Terms and
Conditions available from http://www.gammaglobal.com

EOE

**
**


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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] OT - Table help needed~ PLEASE

2005-05-20 Thread Mark Rees
Something along these lines should get you started

Tclothes (holds all the possible variations of size, colour and style)
Id PK
Styleid FK to Tstyle
Sizeid FK to Tsize
Colourid FK to Tcolour

Tstyle
Styleid PK
StyleDescription VARCHAR

Tsize
Sizeid PK
SizeDescription VARCHAR

Tcolour
Colourid PK
ColourDescription VARCHAR

Mark
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 20 May 2005 00:12
To: php-general@lists.php.net
Subject: [PHP] OT - Table help needed~ PLEASE


Hi,

I am working on a program for a clothing manufacture and need some help
designing the tables for the database. I have to track the inventory
levels of each style by color and size and can not figure the tables
out. Here is the information I need to track.

Style number
Color
Size (can have from 1 to 10 different sizes)

Also need to track the transactions. Receipt Number for incoming
inventory and Invoice number for outgoing. 

Can anyone help me figure out how to setup the tables? Once that is
done, I think I can get the rest working.

Thanks!!!
Kevin

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] Class function calling another function in class

2005-05-19 Thread Mark Rees
You might find this interesting if you are working with hierarchies in
SQL

http://www.intelligententerprise.com/001020/celko.jhtml?_requestid=72430
3

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: 19 May 2005 07:35
To: Charles Kline
Cc: php-general@lists.php.net
Subject: Re: [PHP] Class function calling another function in class


On Wed, May 18, 2005 5:04 pm, Charles Kline said:
 I have an organization table in mySQL. Pretty standard. My first 
 function getDepts() is working as I intend and returning the tree just

 as I like it. The new piece I added in there that is not working now 
 is the call to getPositions() within the first function. What I am 
 trying to do is once I get a Department, I want to loop through the 
 Positions table and get the positions that are under that Department. 
 This code goes haywire and loops for ever printing a huge list to the 
 screen. Eventually I need to return this data not to the screen but 
 into an array. Anyone see what I might have wrong in my logic?

What is in the huge list?...

Actually...

If your organization and/or its budget positions is at all large, this
is an incredibly inefficient way to do it.

You're hammering your database with query after query, and you are using
PHP to do all the iteration and ordering.

SQL was *designed* to handle large amounts of data efficiently.

You would be better served with something not unlike:

$query = select boOrgId, boOrgName, bpPositionID ;
$query .=  from BudgetedOrganization, BudgetedPosition ; $query .= 
where BudgetedOrganization.boOrgID = BudgetedPosition.bp_boOrgID ;
$query .=  order by boSuperiorOrgID ; $rs =
$this-retrieveData($query); if ($rs){
  while ($row = mysql_fetch_array($rs)){
//Store $row in your array or whatever you want to do with it.
  }
}

 I have a class and it contains these two functions.

  function getDepts ( $parent = 0, $level = 1 ) {
  $sql = 'SELECT BudgetedOrganization.* ';
  $sql .= 'FROM BudgetedOrganization ';
  $sql .= 'WHERE BudgetedOrganization.boSuperiorOrgID = ' . 
 $parent;

  $rs = $this-retrieveData($sql);
  if ($rs)
  {
  while($row = mysql_fetch_array($rs)){
  $num = 1;

  while ($num = $level) {
  $this-str .= \t;
  $num++;
  }
  $this-str .= $row['boOrgID'] . ,  . $row 
 ['boOrgName'] . \n;

 // just added this and it ain't working
  $this-str .= $this-getPositions($row['boOrgID']);
  $this-getDepts($row['boOrgID'],$level+1);
  }
  }
  return($this-str);
  }

  function getPositions ( $org = 0 ) {
  $sql = 'SELECT BudgetedPosition.* ';
  $sql .= 'FROM BudgetedPosition ';
  $sql .= 'WHERE BudgetedPosition.bp_boOrgID = ' . $org;
  //echo $sql;
  $rs = $this-retrieveData($sql);
  if ($rs)
  {
  while($row = mysql_fetch_array($rs)){
  $this-str .=  -  . $row['bpPositionID'] . \n;
  }
  }
  return($this-str);
  }


 Later

 $depts = $org-getDepts();
 echo pre . $depts . /pre;


 Thanks,
 Charles

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




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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



RE: [PHP] Unknown column 'peterspeters' in 'where clause'

2005-05-18 Thread Mark Rees
I expect (indeed I sincerely hope) that customer_username  AND
customer_password columns are character datatypes. So it would be a good
idea to put single quotes around the values you are trying to select
from them.

-Original Message-
From: Mark Sargent [mailto:[EMAIL PROTECTED] 
Sent: 18 May 2005 07:28
To: php-general@lists.php.net
Subject: [PHP] Unknown column 'peterspeters' in 'where clause'


Hi All,

the below code generates this error,

Unknown column 'peterspeters' in 'where clause'

mysql_select_db(status, $db);
$username = $_POST[username];
$password = $_POST[password];
$result = mysql_query(SELECT customer_id FROM Customers WHERE 
customer_username = $username AND customer_password = $password) or die

(mysql_error());
$myrow = mysql_fetch_row($result);
$customer_id = $myrow[0];
$_SESSION['customer_id'] = $customer_id;
?
/head
body
?php
echo 'SQL Query: '.$result.'br';
echo CustomerID = $customer_id;
?

Cheers.

Mark Sargent.

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

Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, 
Cisco, Sun Microsystems, 3Com

GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001 
2000' REGISTERED COMPANY

**

CONFIDENTIALITY NOTICE:

This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.

GENERAL STATEMENT:

Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no 
content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order,  subject to our Terms and Conditions available from 
http://www.gammaglobal.com

EOE

**
**


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



  1   2   >