Re: [PHP] mySQL query question

2008-11-14 Thread Michael S. Dunsavage
On Fri, 2008-11-14 at 08:46 +0100, Jochem Maas wrote:
 1000 + 1 != 10001
 
 you might consider setting a default of 1000 or 1 or whatever on
 the given
 field so it's automatically populated with that number when a contact
 record is
 created.

Sorry. Hit the 0 one to few times.
-- 
Michael S. Dunsavage


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



Re: [PHP] Weird pdo-mysql behavior

2008-11-14 Thread Martijn Korse

I agree, add some checks in your testcase so you can track exactly what is
happening and see of what type your variables are.
Also, try what happens when you
- switch off persistent-connections (PDO::ATTR_PERSISTENT= false)
- pass the object by reference (getClientFullName($id,$dbh))


-
http://devshed.excudo.net http://devshed.excudo.net 
-- 
View this message in context: 
http://www.nabble.com/Weird-pdo-mysql-behavior-tp20478083p20496495.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Weird pdo-mysql behavior

2008-11-14 Thread Thodoris



I agree, add some checks in your testcase so you can track exactly what is
happening and see of what type your variables are.
Also, try what happens when you
- switch off persistent-connections (PDO::ATTR_PERSISTENT= false)
  


Tried that using both ways because I saw a similar error in another bug 
in PHP but still doesn't fetch the data.



- pass the object by reference (getClientFullName($id,$dbh))
  


Also did that without making any difference. I am wondering if this has 
to do with PHP itself or with the way my distro is distributing the package.


-
http://devshed.excudo.net http://devshed.excudo.net 
  


Thanks anyway though for the suggestions.

--
Thodoris


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



Re: [PHP] Weird pdo-mysql behavior

2008-11-14 Thread Thodoris



Perhaps when you try to make the connection you should check the return value 
and use whatever PDO error-checking methods exist to find out what went wrong, 
instead of blindly going forward assuming you have a database connection when 
you don't.
  


As a said before I have dumped the hander and all the params before 
passing them into the function and the object has been crated. As I said 
the exact same code works in the same system using a different 
(compiled) apache and a different (compiled) version of PHP without any 
problems. It also works in another system using a compiled apache and PHP.



Ditto for any result of -query()

What you are doing now is akin to turning the key in a car, not listening to 
see if it started, and asking a mechanic on the phone why the gas pedal doesn't 
work...

:-)


  


So I will have to assume that the rpm is not behaving as expected or 
that there is a bug in that specific version of PHP.


--
Thodoris


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



Re: [PHP] Weird Syntax Error

2008-11-14 Thread Thodoris



-Original Message-
From: Edgar da Silva (Fly2k) [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 13, 2008 9:39 AM
To: Kyle Terry
Cc: PHP General Mailing List
Subject: Re: [PHP] Weird Syntax Error

Try:

$insert = INSERT INTO release_file_upload (upl_file_name,
upl_file_type,
upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
('$filename',
'{$_SESSION['upload']['type']}', '{$_SESSION['upload']['size']}',
now(),
'$username', '$path', '$release_id');

2008/11/13 Kyle Terry [EMAIL PROTECTED]:


I keep getting this syntax error on the following string...

syntax error unexpected T_ENCAPSED_AND_WHITESPACE expecting T_STRING
  

or


T_VARIABLE or T_NUM_STRING

$insert = INSERT INTO release_file_upload (upl_file_name,
  

upl_file_type,


upl_file_size, upl_date, upl_by, upl_path, release_id) VALUES
  

('$filename',


'$_SESSION['upload']['type']', '$_SESSION['upload']['size']', now(),
'$username', '$path', '$release_id');
  


Yup... I was just about to say--you need to wrap your array references with curly braces {}. 
Otherwise, I believe PHP will look for a primitive variable named $_SESSION, not an array whose 
indices are upload and size.

HTH,


Todd Boyd
Web Programmer
  


You could also use the . operator instead and quote using the quote 
method if you are using PDO.


But this is a personal style I guess.

--
Thodoris



Re: [PHP] standard safe permissions for php scripts in web directory

2008-11-14 Thread Thodoris



Sounds like a weird question though :( what should be standard safe php
script/directory permissions under Apache.
  


This can vary in some cases. Generally speaking all scripts that ran by 
apache (using the php module) are using the rights of the user that 
apache is running as. So this user (that you may find who it is in your 
httpd.conf like for e.g. User apache) has to be able to at least read 
you scripts. In addition to that if you need to upload files you will 
have to give this user the right to be able to write in the directories 
you plan to upload the files and read rights to the above directories in 
order to see where they are.


You shouldn't though give the right to this user to write in other 
directories beside the ones you upload files for security reasons. This 
is because if someone compromises apache we could in some cases do 
whatever apache does (meaning that we can write where apache does). 
Moreover if your project has a flaw and someone can use that flaw he can 
write were apache writes as well (or perhaps where your script can).


So IMHO it is good to carefully define the rights but test if your 
scripts run and make the proper changes as needed. This of course 
probably needs changes to ownership as well.


--
Thodoris


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



Re: [PHP] mySQL query question

2008-11-14 Thread Thodoris



okay I want to pull an integer from a database called confirm_number,
add 1 and repost it back to the database


here's the code I'm using.


$queryconfirm=SELECT confirm_number from contacts ORDER BY contact DESC
LIMIT 1;
  


I assume that you are already aware that if you set the variable 
$queryconfirm to this SQL query that the query is not necessarily 
executed and returns the result into the variable. 

$confirmresult=$queryconfirm;
  


Now what you did is that $confirmresult is now:

SELECT confirm_number from contacts ORDER BY contact DESC LIMIT 1

as well as $queryconfirm. Why is that?
now here's the problem 


I want to add 1 to confirm_number:

$confirm_number=$confirmresult;
$confirm_number+=1;
  


I will also assume that you don't think that $confirm_number will 
magically contain the result.

Now all this does is set the confirm_number record to 1 in the database.
So I assume that $queryconfirm somehow is not being passed to
confirm_number?  But, while we're here the confirm_number is supposed to
be 5 digits long and the +1 should make it 10001, 10002, 10003 etc

how would I set the original number to 1000 to begin with? Or should I
just set that in the database record its self when I'm ready to use the
website?
  


If what I assume is right (I don't want to disappoint you) but you 
should start reading some PHP basics on how you make database connection 
in PHP. Use google to find some tutorial for e.g.


If I am wrong post us the code to see if someone can help.

--
Thodoris


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



[PHP] Comparative performance

2008-11-14 Thread Richard Heyes
Hi,

Can I get input on the following:

Uncompressed library: 15k
Compressed library, but using the PHP engine (ie ob_start()): 3.5k

Which would be better? Obviously from the client perspective
compressed would be better, but from the servers perspective...? An
increase in the amount of time to put the file on the pipe, or an
increase (no matter how small) in load because of the PHP engine and
compression.

Thanks.

-- 
Richard Heyes

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

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



Re: [PHP] Comparative performance

2008-11-14 Thread Rene Veerman

Richard Heyes wrote:

Hi,

Can I get input on the following:

Uncompressed library: 15k
Compressed library, but using the PHP engine (ie ob_start()): 3.5k

Which would be better? Obviously from the client perspective
compressed would be better, but from the servers perspective...? An
increase in the amount of time to put the file on the pipe, or an
increase (no matter how small) in load because of the PHP engine and
compression.

Thanks.

  

What do you mean by compressed lib? JS?
If you cache your compressed libs on disk, your total processing on the 
php end should go down..


--
--
Rene Veerman, creator of web2.5 CMS http://mediabeez.ws/ 



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



[PHP] Accessing mysql_fetch_object with variable names

2008-11-14 Thread Baniz Daymov
So, I have a newbie syntax question, sorry to bother you with noddy stuff.

I have fetched a set of results from a database quesry using
mysql_fetch_object. I want to iterate through a subset of the columns
from each result, as defined by a separate array. I don't seem to be
able to find the correct syntax for referencing the specific property
of the object with a variable name.

Here's my broken code:

$tabarray = array(bio, research, publications, supervision);
$staffdata = mysql_fetch_object( $result );

foreach ( $tabarray as $tab ) {

echo li$staffdata-$tab/li\n;

}

Hope that's clear what I'm trying to do. I know I could iterate
through every database column and discard any column not in tabarray
or use eval() to build a line of code that did the trick but I'm sure
there must be a more elegant way to get $staffdata-$tab to
interpolate to $staffdata-bio etc and I'm just too inexperienced to
know what it is.

Thanks in advance for your help folks.

-- 
BD

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



Re: [PHP] Comparative performance

2008-11-14 Thread Richard Heyes
 What do you mean by compressed lib? JS?

Javascript minification and HTTP gzip compression. Doing this got a
25k+ library down to 3.5k (!).

-- 
Richard Heyes

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

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



Re: [PHP] Comparative performance

2008-11-14 Thread Rene Veerman

Richard Heyes wrote:

What do you mean by compressed lib? JS?



Javascript minification and HTTP gzip compression. Doing this got a
25k+ library down to 3.5k (!).

  
then definately cache the result (on disk!) (both plaintext and gzip), 
output the cached result each time you can.

overhead will be reduced to a minimum.

--
--
Rene Veerman, creator of web2.5 CMS http://mediabeez.ws/ 



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



Re: [PHP] how to implement search on site

2008-11-14 Thread tedd

At 9:26 AM + 11/13/08, Jignesh Thummar wrote:

I have site of around 25 pages (pure HTML pages). I want to implement search
functionality? How can I? i want to avoid database. And Apache Lucene, i
dont't want to use it. Does any PHP framework provide search and indexing
functionality (Exception Zend_Lucene)?

Thanks,
Jignesh


Might consider this:

http://sperling.com/examples/search/

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: Accessing mysql_fetch_object with variable names

2008-11-14 Thread Matt Jones
I have been thumped with the clue bat and now have a solution.

Thanks for your time!

-- 
Matt

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



[PHP] Re: Accessing mysql_fetch_object with variable names

2008-11-14 Thread Baniz Daymov
I have been thumped with the clue bat and now have a solution.

Thanks for your time!

-- 
BD

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



RE: [PHP] how to implement search on site

2008-11-14 Thread tedd

At 8:24 AM -0600 11/13/08, Boyd, Todd M. wrote:

If you're mainly worried about indexing public pages, why not implement
a Google custom search? They do all the heavy lifting--you just worry
about maintaining your website. All the same SEO you do for Google will
then apply to your website internally...


Todd Boyd
Web Programmer



I considered that, but it looked like to me to put a Google search 
into your site, they require ad space.


So, I use this:

http://sperling.com/examples/search/

They don't and it works pretty good.

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] mySQL query question

2008-11-14 Thread Martijn Korse

I would create a separate table for this (confirmation_numbers or something)
with an autoincrement primary key. That way you can simply insert a new
record for you contact and then ask (using mysql_insert_id()) what the
confirmation number is.
This approach is much safer as you can be 100% sure the number is unique and
it's much less complicated. (of course you still need to check if the query
didn't fail)

-
http://devshed.excudo.net http://devshed.excudo.net 
-- 
View this message in context: 
http://www.nabble.com/mySQL-query-question-tp20495466p20501473.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



[PHP] mySQL query question

2008-11-14 Thread ceo

 okay I want to pull an integer from a database called confirm_number, 

 add 1 and repost it back to the database



No, you don't want to do that.

:-)



You are introducing a race condition between TWO users who hit the same page at 
the same time.



They each get, say, 42, and they each put back 43, but one of them should have 
been 44.



What you WANT to do is this:

update contacts set confirm_number = confirm_number + 1 order by contact desc 
limit 1



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



Re: [PHP] mySQL query question

2008-11-14 Thread Bastien Koert
On Fri, Nov 14, 2008 at 9:58 AM, [EMAIL PROTECTED] wrote:


  okay I want to pull an integer from a database called confirm_number,
  add 1 and repost it back to the database

 No, you don't want to do that.
 :-)

 You are introducing a race condition between TWO users who hit the same
 page at the same time.

 They each get, say, 42, and they each put back 43, but one of them should
 have been 44.

 What you WANT to do is this:
 update contacts set confirm_number = confirm_number + 1 order by contact
 desc limit 1


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


yep, our current app, designed by 'brighter minds' than mine, refused to
make these auto numbers and now we have problems caused by the race
condition.

-- 

Bastien

Cat, the other other white meat


Re: [PHP] mySQL query question

2008-11-14 Thread mikesd1

update contacts set confirm_number = confirm_number + 1 order by
contact

desc limit 1


Here is the php query I've been using to send the record in the first
place

$query=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'  );
[EMAIL PROTECTED] ($query);

(obviously in the script, it's all on one line)

Now, what I need to do, is somehow pull make confirm_number get
submitted as a new record, which will happen once they submit the form,
but I want it to be submitted +1. (12345 should now be 12346 but a new
record entirely)


I was trying this code before the submission query:

$confirmnumber=SELECT confirm_number from contacts ORDER BY contact
DESC LIMIT 1;
$confirm_number=$confirmnumber+1;

Now what this is doing for me so far, is just taking the first numeral
of the record, which happens to be 4 (I originally added the
confirm_number via the rand function, but have since taken that out) and
adding 1 to it and that is it.

So the new $confirm_number=5
So it sort of did the job, but not quite..


The question is how can I make a new record (I know the answer to that
part) BUT with a confirm_number of 1 greater than the previous record.



--
Michael S. Dunsavage

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



Re: [PHP] Comparative performance

2008-11-14 Thread Robert Cummings
On Fri, 2008-11-14 at 12:12 +, Richard Heyes wrote:
 Hi,
 
 Can I get input on the following:
 
 Uncompressed library: 15k
 Compressed library, but using the PHP engine (ie ob_start()): 3.5k
 
 Which would be better? Obviously from the client perspective
 compressed would be better, but from the servers perspective...? An
 increase in the amount of time to put the file on the pipe, or an
 increase (no matter how small) in load because of the PHP engine and
 compression.

Better to use compression. It frees up the webserver process faster to
handle other connections. The longer you have a request being served the
longer the resources allocated to serve the request are unavailable to
other requests. So what benefits the client, small download size, also
benefits the server. Also, if possible, use web server compression
(mod_gzip or mod_deflate) instead of PHP compression.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Re: how to implement search on site

2008-11-14 Thread Al



Jignesh Thummar wrote:

I have site of around 25 pages (pure HTML pages). I want to implement search
functionality? How can I? i want to avoid database. And Apache Lucene, i
dont't want to use it. Does any PHP framework provide search and indexing
functionality (Exception Zend_Lucene)?

Thanks,
Jignesh



Is your requirement for Users or as web designer's tool?

A few months ago I wrote a rather complete website search program that is great for techies, but not 
suitable for users.  You are welcome to a copy if your need is technical.


It uses regex matches, with wild cards, for directories, files and text. 
Requires php 5+

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



Re: [PHP] mySQL query question

2008-11-14 Thread Jim Lucas
[EMAIL PROTECTED] wrote:
 update contacts set confirm_number = confirm_number + 1 order by
 contact
 desc limit 1
 
 Here is the php query I've been using to send the record in the first
 place
 
 $query=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'  );
 [EMAIL PROTECTED] ($query);
 
 (obviously in the script, it's all on one line)
 
 Now, what I need to do, is somehow pull make confirm_number get
 submitted as a new record, which will happen once they submit the form,
 but I want it to be submitted +1. (12345 should now be 12346 but a new
 record entirely)
 
 
 I was trying this code before the submission query:
 
 $confirmnumber=SELECT confirm_number from contacts ORDER BY contact
 DESC LIMIT 1;
 $confirm_number=$confirmnumber+1;
 
 Now what this is doing for me so far, is just taking the first numeral
 of the record, which happens to be 4 (I originally added the
 confirm_number via the rand function, but have since taken that out) and
 adding 1 to it and that is it.
 
 So the new $confirm_number=5
 So it sort of did the job, but not quite..
 
 
 The question is how can I make a new record (I know the answer to that
 part) BUT with a confirm_number of 1 greater than the previous record.
 
 
 

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, back to the DB and creating a
copy of the original data.  The only difference being that the $confirm_number 
has been altered.  Correct?

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


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



Re: [PHP] mySQL query question

2008-11-14 Thread Bastien Koert
On Fri, Nov 14, 2008 at 1:22 PM, [EMAIL PROTECTED] wrote:

 update contacts set confirm_number = confirm_number + 1 order by
 contact

 desc limit 1


 Here is the php query I've been using to send the record in the first
 place

 $query=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'  );
 [EMAIL PROTECTED] ($query);

 (obviously in the script, it's all on one line)

 Now, what I need to do, is somehow pull make confirm_number get
 submitted as a new record, which will happen once they submit the form,
 but I want it to be submitted +1. (12345 should now be 12346 but a new
 record entirely)


 I was trying this code before the submission query:

 $confirmnumber=SELECT confirm_number from contacts ORDER BY contact
 DESC LIMIT 1;
 $confirm_number=$confirmnumber+1;

 Now what this is doing for me so far, is just taking the first numeral
 of the record, which happens to be 4 (I originally added the
 confirm_number via the rand function, but have since taken that out) and
 adding 1 to it and that is it.

 So the new $confirm_number=5
 So it sort of did the job, but not quite..


 The question is how can I make a new record (I know the answer to that
 part) BUT with a confirm_number of 1 greater than the previous record.



 --
 Michael S. Dunsavage

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


make that field an autonumber and let the database assign it. much much
cleaner and simple to get the number with mysql_last_insert()

-- 

Bastien

Cat, the other other white meat


Re: [PHP] mySQL query question

2008-11-14 Thread mikesd1
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.

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



Re: [PHP] mySQL query question

2008-11-14 Thread Jim Lucas
[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
  )
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


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



[PHP] user access/roles/privs functionality

2008-11-14 Thread bruce
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!





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



Re: [PHP] mySQL query question

2008-11-14 Thread Jim Lucas
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


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



Re: [PHP] mySQL query question

2008-11-14 Thread Michael S. Dunsavage
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


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



Re: [PHP] mySQL query question

2008-11-14 Thread Jim Lucas
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


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



Re: [PHP] mySQL query question

2008-11-14 Thread Jim Lucas
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


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



[PHP] RegEx to check for non-Latin characters

2008-11-14 Thread Behzad
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


[PHP] $60 Reward, 1 Hour Eclipse Project

2008-11-14 Thread johny why

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


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



[PHP] Variable Argument List

2008-11-14 Thread Daniel Kolbo

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


Re: [PHP] Variable Argument List

2008-11-14 Thread Daniel Kolbo



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


Re: [PHP] mySQL query question

2008-11-14 Thread Michael S. Dunsavage
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


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