php-general Digest 15 Nov 2008 09:10:44 -0000 Issue 5791

Topics (messages 283308 through 283318):

user access/roles/privs functionality
        283308 by: bruce

Re: mySQL query question
        283309 by: Jim Lucas
        283310 by: Michael S. Dunsavage
        283311 by: Jim Lucas
        283312 by: Jim Lucas
        283317 by: Michael S. Dunsavage

RegEx to check for non-Latin characters
        283313 by: Behzad
        283318 by: Richard Heyes

$60 Reward, 1 Hour Eclipse Project
        283314 by: johny why

Variable Argument List
        283315 by: Daniel Kolbo
        283316 by: Daniel Kolbo

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi list...

I need a way of managing users/teams/etc.. implementing roles/access
rights/privs,etc...

I'd like a way of being able to have users "report to" the resource above
them, ie, the ability to have a hierarchical kind of tree approach would be
good as wel, as this would allow different user/mgr/teams to be moved
up/down in the tree as required.

If I can find the right process, I'll implement it in my targeted app. I'd
prefer something that's fairly well compartmentalized.. but if need be, I'm
willing to rip the right system out of it's parent app if you can show me
one that's good!!!

thanks!





--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> [EMAIL PROTECTED] wrote:
>>> Ok, so just that I am clear, you are SELECTing and pulling all the data 
>>> that you are submitting in the above INSERT statement from the DB 
>>> initially,
>>> then you are only modifying the confirm_number value and then re-
>>> submitting all the values, as they originally were,
>> Well, actually when all is said and done, a new record will be created with 
>> new information (Name, phone, email, etc) and the confirm_number is the 
>> previous+1
>>
>>
>> This whole thing is a contact form.
>>
> 
> Well, in that case, you might be able to do something along the lines of this.
> 
> I tested this on my server:
>       Server version: 5.0.51a-log
>       MySQL client version: 5.0.51a
>       using phpMyAdmin - 2.11.1.2
> 
> I have modified an example from this page:
>       http://dev.mysql.com/doc/refman/5.0/en/user-variables.html
> 
> <?php
> #
> # Setup database stuff, process input, get everything ready to do the insert.
> #
> 
> # Now prepare your statement
> $SQL = "
> SET @confirm_number=(SELECT (MAX(confirm_number)+1) FROM `contacts`);
> INSERT INTO `contacts` (
>                       `first_name`,
>                       `last_name`,
>                       `email`,
>                       `phn_number`,
>                       `address`,
>                       `city`,
>                       `state`,
>                       `zip`,
>                       `dates`,
>                       `comments`,
>                       `confirm_number`
>                       ) VALUES (
>                       '{$FirstName}',
>                       '{$LastName}',
>                       '{$Email}',
>                       '{$Phone}',
>                       '{$Address}',
>                       '{$City}',
>                       '{$selected_state}',
>                       '{$Zip}',
>                       '{$newdate}',
>                       '{$Comments}',
>                       @confirm_number
>                       )

The above should be this instead

@confirm_number
);


> SELECT @confirm_number AS confirm_number;
> ";
> $confirm_number = NULL;
> # Run it and get confirm_number to work with now.
> if ( ($result = @mysql_query($SQL)) !== FALSE ) {
>     list($confirm_number) = mysql_fetch_row($result);
> }
> 
> if ( is_null($confirm_number) ) {
>     echo 'Failed to get number';
> }
> 
> ?>
> 
> Obviously, I can't test this without your schema.  So, I hope it works.
> 
> In the end, you should have a result set that gets returned that contains the 
> 'confirm_number' of the newly created entry.
> 
> This should also, pretty much, eliminate any chance of a race condition.  
> Since everything is happening within mysql, it should be very hard to end up
> with a condition that you start stomping on records.
> 
> Let the list know if it works for you.
> 


-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
On Fri, 2008-11-14 at 13:31 -0800, Jim Lucas wrote:
> >                       '{$Comments}',
> >                       @confirm_number
> >                       )
> 
> The above should be this instead
> 
> @confirm_number
> );

Even after fixing that, nothing gets inserted into the database. I've
been all over the variables and column names and the naming is correct. 
-- 
Michael S. Dunsavage


--- End Message ---
--- Begin Message ---
Michael S. Dunsavage wrote:
> On Fri, 2008-11-14 at 13:31 -0800, Jim Lucas wrote:
>>>                       '{$Comments}',
>>>                       @confirm_number
>>>                       )
>> The above should be this instead
>>
>> @confirm_number
>> );
> 
> Even after fixing that, nothing gets inserted into the database. I've
> been all over the variables and column names and the naming is correct. 

Take the @ off the mysql_query() and also check into mysql_error() function.

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Michael S. Dunsavage wrote:
>> On Fri, 2008-11-14 at 13:31 -0800, Jim Lucas wrote:
>>>>                       '{$Comments}',
>>>>                       @confirm_number
>>>>                       )
>>> The above should be this instead
>>>
>>> @confirm_number
>>> );
>> Even after fixing that, nothing gets inserted into the database. I've
>> been all over the variables and column names and the naming is correct. 
> 
> Take the @ off the mysql_query() and also check into mysql_error() function.
> 

also, try it with a striped down version of the insert, just inserting the 
confirm_number

INSERT INTO contacts (confirm_number) VALUES (@confirm_number);

and see if that creates a new record.

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
On Fri, 2008-11-14 at 12:46 -0800, Jim Lucas wrote:
> SELECT @confirm_number AS confirm_number;

Are we not SELECTING the column value here? should we be selecting
confirm_number as confirm_number? 

-- 
Michael S. Dunsavage


--- End Message ---
--- Begin Message ---
Dear List,

For a Form Validation process, I need a function to avoid Latin characters
to be provided as the first or last name. Since we expect our users to
enter their personal info in Persian.

Do you know any regular expression to provide this functionality?
1) Regex to check whether there are Latin and Numerical characters in a
string.
2) Regex to check whether the string only consists of certain characters.

Thanks you very much in adnvace,
Kind regards,
-behzad

--- End Message ---
--- Begin Message ---
> For a Form Validation process, I need a function to avoid Latin characters
> to be provided as the first or last name. Since we expect our users to
> enter their personal info in Persian.
>
> Do you know any regular expression to provide this functionality?
> 1) Regex to check whether there are Latin and Numerical characters in a
> string.
> 2) Regex to check whether the string only consists of certain characters.

In a PCRE regex, [\x80-\xFF] will find all extended ASCII chars. Or,
if you wanted all ASCII chars, you could use: [\x00-\xFF] That would
catch space and punctuation as well though. Or you could amend it to
suit. It's in hexadecimal (ie FF == 255)

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)

--- End Message ---
--- Begin Message ---
- Tasks

$60 reward to walk me through a successful Eclipse PHP debug session of doProject on my IIS server.

The only task here is to get a debug session going.

There will not be any IIS support or PHP programming involved.

Should only be some basic config settings in Eclipse.


- Time Frame

Payment will only be made if this task is achieved within 2 hours. I think should be under an hour total for someone who knows this stuff well.


- Method

You will watch my desktop remotely, and talk me through all steps, by phone or chat or voice chat.

No hands-on work involved, just need to talk me through it.

Please do not send pre-written Eclipse instructions - remote walk-through only.


- Environment

I am running IIS 6, PHP 4.4.6, Windows 2000 server, Zend debugger (ok to use xdebug if you prefer)

Eclipse All-In-One PDT is already installed on my server. Zend debug extension is also installed. The php.ini has the Zend debug settings.

Unfortunately, I do not have the luxury to switch to Apache.


--- End Message ---
--- Begin Message ---
Hello,

I am trying to do something like the following:

<?php

function hello($var1 = 'default1', $var2 = 'default2') {
   echo "$var1:$var2";
}

$func= "hello";
$args = "'yo','bob'";
$func($args);

?>

I understand why this outputs:
'yo','bob':default2
However, I want it to output:
yo:bob

Is this possible? I tried using different combinations of {}, but I cannot seem to get it to happen. I need some kind of "preprocessor" feature perhaps.

Thanks,
dK

--- End Message ---
--- Begin Message ---


Daniel Kolbo wrote:
Hello,

I am trying to do something like the following:

<?php

function hello($var1 = 'default1', $var2 = 'default2') {
   echo "$var1:$var2";
}

$func= "hello";
$args = "'yo','bob'";
$func($args);

?>

I understand why this outputs:
'yo','bob':default2
However, I want it to output:
yo:bob

Is this possible? I tried using different combinations of {}, but I cannot seem to get it to happen. I need some kind of "preprocessor" feature perhaps.

Thanks,
dK

answered my own question:
call_user_func_array($func, array("yo","bob"));
will do the trick for me.
thanks,
dK

--- End Message ---

Reply via email to