php-general Digest 23 May 2009 09:44:07 -0000 Issue 6136

Topics (messages 292990 through 293009):

Re: Rogue 'if - elseif' code
        292990 by: Nathan Rixham

An effective stress remedy
        292991 by: Tabby Hatfield

Re: urgent CSS question
        292992 by: Benjamin Hawkes-Lewis
        292996 by: PJ

A Rich Ajax Application Frameowrk for PHP
        292993 by: Raymond Irving

Re: Forms validation and creation- easier solution?
        292994 by: Manuel Lemos
        292995 by: phphelp -- kbk

Re: apache user cannot execute useradd via sudo :(
        292997 by: vuthecuong
        292998 by: Michael A. Peters

How to assign eval() to variable?
        292999 by: Afan Pasalic
        293000 by: oorza2k5.gmail.com
        293001 by: Afan Pasalic

fgets function for very large files
        293002 by: shahrzad khorrami
        293004 by: Ashley Sheridan
        293005 by: Eddie Drapkin
        293006 by: shahrzad khorrami
        293007 by: shahrzad khorrami
        293008 by: Michael A. Peters
        293009 by: Ashley Sheridan

Re: IE can't download, FF can: SSL ? Need special headers?
        293003 by: Ashley Sheridan

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 ---
Andre Dubuc wrote:
Hi,

I'm having problems with a chunk of 'rogue' code that does not perform as expected (it does not pass the expected date, but an empty value). Most of the time, it works - so I'm wondering whether it might be a browser issue. (The latest failure occurred with Firfeox 3.0 browser on an NT 5.1 OS.) The code is stored on an Unix server, running PHP 5.x. I've isolated it down to multiple if - elseif statements that check long dates for completeness, "day" "month" and "year". The code then applies it results printing one of following: the full date - 22 May 2009, month-year - May 2009, or just the year, 2009. My question is whether the ORDER of checking is important, i.e, whether checking for the null sets BEFORE full sets or AFTER. I've added debugging code to be able to get the raw POST values so I can manually enter it into the db, but I would really appreciate some help here. The code is old -- I wrote it seven years ago, and had worked well until I modified it, but I no longer have the original working code. [The first conditional line of the code checks whether the user has entered the birth date, then it checks for the death date. The $_SESSION stuff is debugging code.]


<?php


        $yd = $_POST['death'];
        $yb =  $_POST['birth']; 


if ($_POST['bday'] == "Day" && $_POST['bmonth'] == "Month" && $_POST['birth'] == "Year") {
        
                
if ($_POST['dday'] != "Day" && $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = ("{$_POST['dday']} {$_POST['dmonth']} 
{$_POST['death']}");
                        $_SESSION['ALL1rdod'] = $_POST['rdod'];
        
                }
        
                
elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] == "Month" && $_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = $_POST['death'];
                        $_SESSION['YEAR1rdod'] = $_POST['rdod'];
        
                }
        
                
elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
                                        
                        $_POST['rdod'] = ("{$_POST['dmonth']} 
{$_POST['death']}");
                        $_SESSION['MONTHYEAR1rdod'] = $_POST['rdod'];
        
                }


$_SESSION['Sdebugdod1'] = "{$_POST['dday']} {$_POST['dmonth']} {$_POST['death']}";
                        
        }
        
        
                else {
                
                
                        if ($yd > $yb) {
                                
                
if ($_POST['bday'] != "Day" && $_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {
                
$_POST['rdob'] = ("{$_POST['bday']} {$_POST['bmonth']} {$_POST['birth']}");
        
                                }
        
                
elseif ($_POST['bday'] == "Day" && $_POST['bmonth'] == "Month" && $_POST['birth'] != "Year") {
                                        
                                        $_POST['rdob'] = $_POST['birth'];
        
                                }
        
                
elseif ($_POST['bday'] == "Day" && $_POST['bmonth'] != "Month" && $_POST['birth'] != "Year") {
                                        
                                        $_POST['rdob'] = ("{$_POST['bmonth']} 
{$_POST['birth']}");
        
                                }
                                
                
                
if ($_POST['dday'] != "Day" && $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
                                        
$_POST['rdod'] = ("{$_POST['dday']} {$_POST['dmonth']} {$_POST['death']}");
                                        $_SESSION['ALL2rdod'] = $_POST['rdod'];
        
                                }
        
                
elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] == "Month" && $_POST['death'] != "Year") {
                                        
                                        $_POST['rdod'] = $_POST['death'];
                                        $_SESSION['YEAR2rdod'] = $_POST['rdod'];

                                }
        
                
elseif ($_POST['dday'] == "Day" && $_POST['dmonth'] != "Month" && $_POST['death'] != "Year") {
                                        
                                        $_POST['rdod'] = ("{$_POST['dmonth']} 
{$_POST['death']}");
                                        $_SESSION['MONTHYEAR2rdod'] = 
$_POST['rdod'];
        
                                }


$_SESSION['Sdebugdod2'] = "{$_POST['dday']} {$_POST['dmonth']} {$_POST['death']}";

                                
        
                        }


?>

Any help or pointers would be greatly appreciated!

Tia,
Andre


makes no sense at all to me without some decent variable names "rdod"? - would also need the form to be honest, and a description of the functionality needed.

one thing i can say is that you have a closing bracket missing at the end and your $_SESSION['Sdebugdod2'] appears to be in the wrong place
(to solve both these try sticking a } before $_SESSION['Sdebugdod2']

really though, change the names in the form to something more descriptive

--- End Message ---
--- Begin Message ---
Not getting sleep is horrible. The tossing and turning and the feelings of 
grogginess the next day are horrible. But possibly the worst part of not 
sleeping is the feeling that your body is not working the way it should be! 
Nothing feels more unnatural than staying up all night when all you want to do 
is sleep.

Melatrol is a blend of natural products, which have been in use for centuries, 
and is designed to help regain a natural sleep pattern. It does this by aiding 
the natural sleep process by promoting relaxation and sleep. This can have a 
positive effect on stress levels as well.

All you have to do is to confirm your interest at 
[email protected] and we'll send You the necessary information.

Best regards,
Sleep Solutions Marketing











------------------------------------------------------------------
This email has been written and proved to be in compliance with the recently 
established can-spam act law in US. We are not provoking or forcing any person 
in any way to participate in our programs. To participate is your own decision 
and you carry the responsibility of taking further part in this promotion. 
Anyway, if you don't want to receive more good offers from us, you can simply 
Unsubscribe by sending us a notification email to [email protected] 
with a mail-subject and text "Unsubscribe me", and we will get your email out 
of our list within 10 days.

This message is STRICTLY CONFIDENTIAL and is solely for the individual or 
organisation to whom it is addressed. It may contain PRIVILEGED and 
CONFIDENTIAL information. If you are not the intended recipient, you are hereby 
notified that any dissemination, distribution or copying of this communication 
and its contents is strictly prohibited. If you are not the intended recipient 
you should not read, copy, distribute, disclose or otherwise use the 
information in this email. Email may be susceptible to data corruption, 
interception and unauthorised amendment, and we do not accept liability for any 
such corruption, interception or amendment or the consequences thereof or your 
reliance on any information contained therein if you are not the intended 
recipient. If you are not interested in the offered promotions, please just 
don't answer. If you think you have received this message and its contents in 
error, please delete it from your computer, or follow the unsubscribing 
procedure shown above.
------------------------------------------------------------------
                

--- End Message ---
--- Begin Message ---
On 22/5/09 20:31, PJ wrote:
They may have different names, but does that change their functionality?

Potentially, yes!

A selector including #frame will no longer match if "id" is changed to "frame1", and vice versa.

They are identical except for the "1" in the title of the id. So, if I
change the one id to the other in the same code, I don't understand why
the formatting would change?

These descriptions are still far too vague and ambiguous. Please link to two test cases:

1) Effectively showing "frame1".

2) Effectively showing "frame".

that illustrate the problem you're talking about.

Obviously, the parents and the children
have not changed unless there's some weird hanky-panky going on.

Without seeing test cases, nothing is obvious.

> Or do I have to make a new css file for every page

Only if you're doing it wrong. :)

And to follow the logic here, if I create a different id and in the
end it turns out to be identical to the original "frame" except for the
name, shouldn't it function the same.

That depends on:

1) The contents of your CSS file, which I can't see.
2) Whether you've made any errors when modifying your HTML, which I can't see either.

If you provided test cases, I could see these things and answer your questions.

Trying to describe the problem rather than /showing/ the problem is very inefficient.

--
Benjamin Hawkes-Lewis

--- End Message ---
--- Begin Message ---
Benjamin Hawkes-Lewis wrote:
> On 22/5/09 20:31, PJ wrote:
>> They may have different names, but does that change their functionality?
>
> Potentially, yes!
>
> A selector including #frame will no longer match if "id" is changed to
> "frame1", and vice versa.
>
>> They are identical except for the "1" in the title of the id. So, if I
>> change the one id to the other in the same code, I don't understand why
>> the formatting would change?
>
> These descriptions are still far too vague and ambiguous. Please link
> to two test cases:
>
> 1) Effectively showing "frame1".
>
> 2) Effectively showing "frame".
>
> that illustrate the problem you're talking about.
>
>> Obviously, the parents and the children
>> have not changed unless there's some weird hanky-panky going on.
>
> Without seeing test cases, nothing is obvious.
>
> > Or do I have to make a new css file for every page
>
> Only if you're doing it wrong. :)
>
>> And to follow the logic here, if I create a different id and in the
>> end it turns out to be identical to the original "frame" except for the
>> name, shouldn't it function the same.
>
> That depends on:
>
> 1) The contents of your CSS file, which I can't see.
> 2) Whether you've made any errors when modifying your HTML, which I
> can't see either.
>
> If you provided test cases, I could see these things and answer your
> questions.
>
> Trying to describe the problem rather than /showing/ the problem is
> very inefficient.
>
> -- 
> Benjamin Hawkes-Lewis
>
Ok, I'm glad the there are some people out there  who want to get down
to the bottom of things.
I can attach or maybe put up a link on a website where you can look at
the code and the css.
But regardless of any test caste, nothing changes the fact that whatever
the html code, whatever the php code, these are sonstant and nothing is
changed. Switch between id frame and id frame1 and things change.
nothnig, I meant, nothing is changed in between. The difference is in
the css, and nothing else.
I'll post the location later tonight or , more likely, tomorrow am.
zzzzzzzzz

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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

I would like to introduce you to a new framework called Raxan PDI that I've 
being working on for the past couple of months. 

Raxan PDI is an Open Source PHP Framework that seamlessly blends the
unique features of modern web application development into one seamless
interface.

Today we have release Beta 1 with the following new features:

* New XML Support
* Mobile Web Application Support
* Template Binder
* Data Pagination
* Ajax Event Binding Options
* and lots more...

PDI provides a consistent set of APIs for handling HTML, WML and XML documents.

To see it in action or learn more about the framework, please visit 
http://raxanpdi.com/

PS. If you would like to contribute to this project, please feel free to drop 
me a line or join our online community forum at http://raxanpdi.com/forum.


Best regards,
__
Raymond Irving


--- End Message ---
--- Begin Message ---
Viva,

on 05/22/2009 10:36 AM Paul M Foster said the following:
>> IMHO, creating forms by hand is by no means simpler, especially if you
>> want to include browser side (Javascript) validation.
>>
>> I mean, I am not masochist to create something that will give me more
>> work in the end to develop PHP forms based applications than if I would
>> type HTML manually.
>>
>> Furthermore, the plug-ins that come with the package dramatically reduce
>> the amount of code you need to type to achieve the same generating
>> common HTML inputs manually.
>>
>> Anyone can judge by yourself by going here and see several example forms
>> and the actual code that it takes to generate them:
>>
>> http://www.meta-language.net/forms-examples.html
>>
>> For instance this scaffolding plug-in generates CRUD forms that you
>> often need to manage data stored for instance in databases.
>>
>> http://www.meta-language.net/forms-examples.html?example=test_scaffolding_input
>>
>> For those interested to check it out, the actual class package can be
>> downloaded from here:
>>
>> http://www.phpclasses.org/formsgeneration
>>
>> Here you may watch an extensive tutorial video that covers practically
>> all features:
>>
>> http://www.phpclasses.org/browse/video/1/package/1.html
>>
> 
> 
> Here's what I was talking about. Assuming you simply type out your form
> fields like this:
> 
> <input type="text" name="address" size="30" value="123 Main St."/>
> 
> Now, if you do it with a class like yours:
> 
> $arr = array('type' => 'text',
>             'name' => 'address',
>             'size' => 30,
>             'value' => '123 Main St.');
> 
> $form->AddInput($arr);
> 
> (I haven't looked at your class in a while, so I may have invoked it
> slightly incorrectly.)
> 
> If you compare the typing involved in the first case with the typing
> involved in the second case, you can see that it's more in the second
> case.

That is because you are just thinking about the typing of the generated
HTML. To generate and validate forms, you also have to consider the code
you write to validate and process the forms because the HTML forms do
not process by themselves.

You need to think about the security of your application, so you also
need to validate submitted values, discard invalid values, escape
outputted values, and so on. All that is done with a couple of calls to
the forms class.


> Yes, your forms generation class includes a tremendous amount of proven
> code, including a bunch of Javascript validation, all of which the
> programmer doesn't have to develop himself.
> 
> The only real complaint I have about your class is that the class file
> itself (forms.php) is 158+ K bytes, which must be loaded every time you
> surf to a page for the first time.

That used to be an issue in the 20th century in the PHP 3 days. Since
PHP 4, the PHP code is no longer interpreted. The Zend engine compiles
the PHP code in Zend op codes in the first stage. In the second stage
the op codes are executed. If you use a cache extension like APC, Turck
MMCache, XCache, etc.. the first step is skipped after the first
execution and the size of the original code is not relevant because it
is already compiled in shared memory.

Anyway, the class has all that code because it is necessary to implement
all it supports.

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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

On May 20, 2009, at 2:03 AM, Angelo Zanetti wrote:

We have done quite a few projects and we are looking to find better ways to
implementing forms.

This is fairly simple to roll-your-own.

I do it from metadata. I check MySQL metadata for data types, lengths, and defaults. In addition, my metadata tables contain:
 -- field captions
-- field-use descriptions and business rules (generates CSS pop-up help)
 -- the type of control used
-- the source of data for controls (I call system codes: like the lists of choices for comboboxes and radio buttons -- I keep almost all of these in a single table.)
 -- whether data in a field is required
-- whether the data in a field are visible, editable, or new-record- only editable -- whether the data are encrypted (core data class handles the encryption/decryption)
 -- data entry order
 -- any non-standard user rights to the data.
-- Simple business rules (like maximums, minimums and ranges of acceptable values) -- easy validation categories: birthdates, eMail formatting, USA phone numbers & postal codes, US social security #'s, credit card format, and the like.

The last two can generate JavaScript, too (still working on that).

-- I also am working on more complex validation being automatic: across fields or tables, dependent on other variables, etc.

By standardizing the format of metadata and the means of storing system code values, plus core CSS class names, you can use this across projects.

Ken

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


Michael A. Peters wrote:
> 
> vuthecuong wrote:
>> 
>> Hi all
>> My server is centos 5.1 with php 5.1.6.
>> In my app I want apache to add user through sudo.
>> 
>> My sudoers file is:
>> %apache ALL=(ALL) NOPASSWD: ALL
>> %tony ALL=(ALL) NOPASSWD: ALL
>> 
>> My test.php í:
>> <?php
>> $username="hixhix";
>> system("/usr/bin/sudo /usr/sbin/useradd -s /sbin/nologin -M
>> $username",$returnvalue);
>> echo "return value: $returnvalue";
>> However, user 'hixhix' not created by apache at all, it always returned
>> 1.
>> how can I make my apache tu add user using sudo?
>> Please help me. I need your help.
>> Thanks and regards.
> 
> That's not a very secure sudoers file.
> 
> But you probably don't want to use sudo to this anyway.
> 
> What you probably should do is write a shell script (IE w/ perl) that is 
> suid root and executable by apache that adds the user to your system.
> 
> I don't know what your sudo error is, but have you looked at your sudo 
> log file?
> 
> Make damn sure you validate the $username variable whatever solution you 
> end up using.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 
Yeah I know my script don't care at all about security. I'm keeping it fot
the sake of simplicity.
After making it 'work', I will take a look seriously about security.
So, why it not create user for me?
thanks and regards
-- 
View this message in context: 
http://www.nabble.com/apache-user-cannot-execute-useradd-via-sudo-%3A%28-tp23668764p23680766.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
vuthecuong wrote:



Yeah I know my script don't care at all about security. I'm keeping it fot
the sake of simplicity.
After making it 'work', I will take a look seriously about security.
So, why it not create user for me?
thanks and regards

I'm not that familiar with sudo, but I suspect it may have to do with the fact apache is a user without a shell.

look in the sudo log file.
If you don't see anything, look in /var/log/secure and /var/log/messages and /var/log/httpd/error_log

If you don't see the problem, log into a root shell. Then run

su apache

to become the apache user and try the command and see what happens.

Really though, this isn't a job for sudo.
It's a job for a suid root shell script (I'd suggest perl or python or maybe tcl/expect).
--- End Message ---
--- Begin Message ---
hi,
I have on one website boxes with information, pulled from mysql. the content can be string, php code, url of other website or url to specific file etc.

currently, I have something like this:

// connect to db
// mysql_query() to get box content and content_type

switch($content_type)
{
  case 'string':
     echo $content;
     break;

  case 'php_code':
     eval($content);
     break;

  case 'website':
     echo '<iframe>'.$content.'</iframe>;
     break;

  case 'file'
     require_once($file);
     echo $file_content;

  // etc.
}

but, now I have to change the code to assign content to variable and the variable will be printed later. I tried something like this:


switch($content_type)
{
  case 'string':
     $record = $content;
     break;

  case 'php_code':
     $record = eval($content);
     break;

  case 'website':
     $record = '<iframe>'.$content.'</iframe>;
     break;

  case 'file'
     require_once($file);
     $record = $file_content;

  // etc.
}

and it works - except eval() part. cant do $record = eval($content); ?!?!?!?

thanks


afan







--- End Message ---
--- Begin Message --- short hack, assuming your eval echo's out to the browser (which I can't see how else you'd expect something to 'return' from an eval'd statement
ob_start();
eval($foo);
$result = ob_get_clean();

On May 23, 2009 1:46am, Afan Pasalic <[email protected]> wrote:
hi,

I have on one website boxes with information, pulled from mysql. the content can be string, php code, url of other website or url to specific file etc.



currently, I have something like this:



// connect to db

// mysql_query() to get box content and content_type



switch($content_type)

{

case 'string':

echo $content;

break;



case 'php_code':

eval($content);

break;



case 'website':

echo ''.$content.';

break;



case 'file'

require_once($file);

echo $file_content;



// etc.

}



but, now I have to change the code to assign content to variable and the variable will be printed later. I tried something like this:





switch($content_type)

{

case 'string':

$record = $content;

break;



case 'php_code':

$record = eval($content);

break;



case 'website':

$record = ''.$content.';

break;



case 'file'

require_once($file);

$record = $file_content;



// etc.

}



and it works - except eval() part. cant do $record = eval($content); ?!?!?!?



thanks





afan















--

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--- End Message ---
--- Begin Message ---
short hack works like a charm!
:-)

thanks!

afan




[email protected] wrote:
short hack, assuming your eval echo's out to the browser (which I can't see how else you'd expect something to 'return' from an eval'd statement
ob_start();
eval($foo);
$result = ob_get_clean();

On May 23, 2009 1:46am, Afan Pasalic <[email protected]> wrote:
> hi,
>
> I have on one website boxes with information, pulled from mysql. the content can be string, php code, url of other website or url to specific file etc.
>
>
>
> currently, I have something like this:
>
>
>
> // connect to db
>
> // mysql_query() to get box content and content_type
>
>
>
> switch($content_type)
>
> {
>
>  case 'string':
>
>     echo $content;
>
>     break;
>
>
>
>  case 'php_code':
>
>     eval($content);
>
>     break;
>
>
>
>  case 'website':
>
>     echo ''.$content.';
>
>     break;
>
>
>
>  case 'file'
>
>     require_once($file);
>
>     echo $file_content;
>
>
>
>  // etc.
>
> }
>
>
>
> but, now I have to change the code to assign content to variable and the variable will be printed later. I tried something like this:
>
>
>
>
>
> switch($content_type)
>
> {
>
>  case 'string':
>
>     $record = $content;
>
>     break;
>
>
>
>  case 'php_code':
>
>     $record = eval($content);
>
>     break;
>
>
>
>  case 'website':
>
>     $record = ''.$content.';
>
>     break;
>
>
>
>  case 'file'
>
>     require_once($file);
>
>     $record = $file_content;
>
>
>
>  // etc.
>
> }
>
>
>
> and it works - except eval() part. cant do $record = eval($content); ?!?!?!?
>
>
>
> thanks
>
>
>
>
>
> afan
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
>
> PHP General Mailing List (http://www.php.net/)
>
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--- End Message ---
--- Begin Message ---
hi all,

I have a csv file with more than 100,000 lines. I want to insert each line
as a record in a
database. but for the reason of very number of lines,
I put a button with caption Next,  when we click on it, 1000 line will
insert into db and then again click next button
and insert next 1000 line and....
 is this good way? what do you recommend? and how can I do that?


Thanks in advance,
shahrzad

--- End Message ---
--- Begin Message ---
On Sat, 2009-05-23 at 10:41 +0430, shahrzad khorrami wrote:
> hi all,
> 
> I have a csv file with more than 100,000 lines. I want to insert each line
> as a record in a
> database. but for the reason of very number of lines,
> I put a button with caption Next,  when we click on it, 1000 line will
> insert into db and then again click next button
> and insert next 1000 line and....
>  is this good way? what do you recommend? and how can I do that?
> 
> 
> Thanks in advance,
> shahrzad

If it's a CSV, I'd recommend using phpMyAdmin directly to import it into
the database, assuming you are using a MySQL database that is. It's
using tried and tested code for large files like that.


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Sat, May 23, 2009 at 2:58 AM, Ashley Sheridan
<[email protected]>wrote:

>
> If it's a CSV, I'd recommend using phpMyAdmin directly to import it into
> the database, assuming you are using a MySQL database that is. It's
> using tried and tested code for large files like that.
>
>
Tried and true to be what, exactly? Full of security holes and exploits and
promoting bad habits?

Really, if all you need to do for the database is import hte .csv, import it
directly into mysql, from mysql:

http://www.tech-recipes.com/rx/2345/import_csv_file_directly_into_mysql/

And on a related note, you should never, ever use PMA on a production
machine as it's so easy to exploit and hack.  Furthermore, if you use it on
your dev server, you'll get used to managing your database with it and have
trouble using it on the production server.  Take the time to use a real DB
administration app (like SQLyog of the one that comes with KDE) or an IDE
with integrated SQL management (like PDT or Zend Studio or Aptana I think
too).

Bottom line is if you said you used PMA in an interview I had any say in,
I'd never hire you and I'd never work with a developer who was that
uncomfortable with SQL.

--- End Message ---
--- Begin Message ---
Thanks for repply :)

It must be automatically, it means that there is a form that an operator
browse a csv with large size(more than 2-3 GB)
and in next step(page) first 1000 line insert into db then by clicking on
next button, next 1000 line....
operator don't know any thing about phpmyadmin and programming just browse
the csv file and everything will do automatically
in my code all of lines inserted correctly with @set_time_limit(600) but
it's too slow and bad way...
no use of phpmyadmin and any splitter csv installer program..

Thanks,
shahrzad

--- End Message ---
--- Begin Message ---
one thing!  I need four fields of  7 fields in each line,
in my code from original csv file first four of fields choose(mappping these
fields with columns of table in db)
for example:
a line in csv file:
"a","b","c","d","e","f","g"

in table of database 4 column : name,ext,tel,date
that 4 field of csv file must map to these column

then I can't directly import my csv file into db. some process must do to
insert  just my selected fields of csv file...

Thanks,
Shahrzad

--- End Message ---
--- Begin Message ---
shahrzad khorrami wrote:
one thing!  I need four fields of  7 fields in each line,
in my code from original csv file first four of fields choose(mappping these
fields with columns of table in db)
for example:
a line in csv file:
"a","b","c","d","e","f","g"

in table of database 4 column : name,ext,tel,date
that 4 field of csv file must map to these column

then I can't directly import my csv file into db. some process must do to
insert  just my selected fields of csv file...

use awk to read the file and create a .sql file with the specified fields you want.
--- End Message ---
--- Begin Message ---
On Sat, 2009-05-23 at 02:59 -0400, Eddie Drapkin wrote:
> On Sat, May 23, 2009 at 2:58 AM, Ashley Sheridan
> <[email protected]>wrote:
> 
> >
> > If it's a CSV, I'd recommend using phpMyAdmin directly to import it into
> > the database, assuming you are using a MySQL database that is. It's
> > using tried and tested code for large files like that.
> >
> >
> Tried and true to be what, exactly? Full of security holes and exploits and
> promoting bad habits?
> 
> Really, if all you need to do for the database is import hte .csv, import it
> directly into mysql, from mysql:
> 
> http://www.tech-recipes.com/rx/2345/import_csv_file_directly_into_mysql/
> 
> And on a related note, you should never, ever use PMA on a production
> machine as it's so easy to exploit and hack.  Furthermore, if you use it on
> your dev server, you'll get used to managing your database with it and have
> trouble using it on the production server.  Take the time to use a real DB
> administration app (like SQLyog of the one that comes with KDE) or an IDE
> with integrated SQL management (like PDT or Zend Studio or Aptana I think
> too).
> 
> Bottom line is if you said you used PMA in an interview I had any say in,
> I'd never hire you and I'd never work with a developer who was that
> uncomfortable with SQL.
I guess I don't get the job then! :p


Ash
www.ashleysheridan.co.uk


--- End Message ---
--- Begin Message ---
On Fri, 2009-05-22 at 14:41 -0500, Dee Ayy wrote:
> That's what I had in my first post.  What are the rest of your headers?
> 
> This is what is now deployed and I consider this issue resolved, but
> allowing spaces in the filename across IE, FF, and Safari browsers
> would be the real solution.  It's untested on other browsers:
> 
> header('Content-Description: File Transfer');
> header('Content-Type: '.$type);
> header('Content-Disposition: attachment;
> filename='.basename(str_replace(' ', '_', $name)));
> header('Content-Transfer-Encoding: binary');
> header('Expires: 0');
> header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
> header('Pragma: public');
> header('Content-Length: '.$size);
> echo $data;

Nope, you missed out the quotes on the particular heading I was drawing
attention to hence my not printing the other headings.


Ash
www.ashleysheridan.co.uk


--- End Message ---

Reply via email to