Re: [PHP] MySQL Query Puzzle

2010-07-18 Thread Shafiq Rehman
On Mon, Jul 19, 2010 at 10:44 AM, Peter pet...@egrabber.com wrote:
 Hi All,

 I have a  table which contain's some duplicate rows. I just want to delete
 the duplicate records alone
 not original records.

 Assume my table as look as below

 column1 column2
 1
        a
 1
        a
 2
        b
 3
        c
 3
        c



 i want the above table need  to be as below, After executing the mysql
 query.

 column1
        column2
 1
        a
 2
        b
 3
        c




 Thanks in advance..

 Regards
 Peter


Create a table with similar structure and add UNIQUE INDEX on both
columns. Execute the following query:

INSERT IGNORE INTO NEW_TABLE (column1, column2) SELECT column1,
column2 FROM OLD_TABLE

This will give you distinct rows as required.

-- 
Keep Smiling :-)
Shafiq Rehman
Blog: http://shafiq.pk, Twitter: http://twitter.com/shafiq

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



Re: [PHP] PHP CURL

2007-11-20 Thread Shafiq Rehman
Hi Fahad,

May be you wil find something helpful  at
http://curl.haxx.se/mail/archive-2003-03/0137.html

-- 
Keep Smiling
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

On Nov 19, 2007 11:45 AM, Fahad Pervaiz [EMAIL PROTECTED] wrote:

 I am looking forward to write a script that can send invite to contacts in
 gmail,hotmail, yahoo and aol. I think it is possible to write it using php
 CURL. If yes can any one suggest how?
 and can any one help me write this script or join me to write this script?

 --
 Regards
 Fahad Pervaiz
 www.ecommerce-xperts.com
 (Shopping Cart System)



Re: [PHP] what is better way to write the query

2007-11-05 Thread Shafiq Rehman
Hi,

If possible, write your inserts queries in a text file and use LOAD DATA for
bulk inserts.

-- 
Keep Smiling
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

On 11/2/07, Andrew Ballard [EMAIL PROTECTED] wrote:

 On Nov 2, 2007 10:41 AM, afan pasalic [EMAIL PROTECTED] wrote:
  ...is there any suggestion for the process of inserting up to 5K records
 at
  the time ...

 Is it possible to save your data to a text file and then use one of
 MySQL's built-in import queries? (I know in some situations it isn't
 an option because the PHP server and the MySQL server are not able to
 read from a common location.)

 Andrew

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




-- 
Keep Smiling
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


Re: [PHP] Another simple question (Probably)

2007-07-09 Thread Shafiq Rehman

Hi,

correct syntax for mktime is mktime( int hour, int minute, int second,  int
month, int day, int year)

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

On 7/9/07, Jason Pruim [EMAIL PROTECTED] wrote:


Okay so given this section of code:

$taskTime=mktime(00,00,00,$_POST['txtReschedule']);

echo HTML

tr
td bgcolor={$rowColor}ID#, {$row['id']} /td
td bgcolor={$rowColor}TicklerName, {$row['task_name']}  /td
td bgcolor={$rowColor}Instructions, a href='{$row
['task_desc']}'Instructions/a/td
td bgcolor={$dowColor}DayOfWeekWord, {$dowword} /td
td bgcolor={$rowColor}DateToReschedule, input type='text'
name='tasks[{$row['id']}][txtReschedule]' value=''/td
td bgcolor={$rowColor}DateRescheduled, {$Date}/td
td bgcolor={$rowColor}a href='update.php?taskid={$row['id']}
taskdate={$taskdate}'Click here!/a/td
td bgcolor={$rowColor}CheckboxForWhenDone,
input  type='checkbox'
name='tasks[{$row['id']}][chkDone]'
value='{$row['id']}'/td
/tr

HTML;

Why am I getting a time stamp of:

1165640400
Sat, Dec-09-06?

I have been fighting with trying to figure this out and finally
decided to show my ignorance of the language and ask for help :)
Besides, the boss wants this done :)

Jason
?PHP

if($brain ==Monday){
echo Let me go home!
};

?

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




Re: [PHP] Date

2007-06-19 Thread Shafiq Rehman

Hello,

There's another way out there using mysql

SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate

but off course not a recommended way. In fact you can use it update query
(update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7 DAY)
where user ='$user')

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


On 6/19/07, Richard Heyes [EMAIL PROTECTED] wrote:


Larry Garfield wrote:
 (Note: strtotime() is probably not the fastest to execute way of doing
it, but
 it's the fastest to write.  Choose wisely.)

Is it? How about:

$timestamp = strtotime($expiry_date) + (86400 * 7);

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software

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




Re: [PHP] Date

2007-06-19 Thread Shafiq Rehman

On 6/19/07, Richard Heyes [EMAIL PROTECTED] wrote:


Shafiq Rehman wrote:
 Hello,

 There's another way out there using mysql

 SELECT DATE_ADD('$expiry_date', INTERVAL 7 DAY) as fDate

 but of course not a recommended way.

So why suggest it?



just to share the knowledge


In fact you can use it update query
 (update tbl_name set expiry_date = date_add('$expiry_date', INTERVAL 7
DAY)
 where user ='$user')

Seriously, no.

--
Richard Heyes
0844 801 1072
http://www.websupportsolutions.co.uk
Knowledge Base and HelpDesk software





--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


Re: [PHP] Re: Controlling project version

2007-06-18 Thread Shafiq Rehman

Hello,

I use CVS in office and home

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


On 6/18/07, Jochem Maas [EMAIL PROTECTED] wrote:


Colin Guthrie wrote:
 Stut wrote:
 I don't like the branching in subversion, it's a lot easier to work
with
 in CVS.

snip lots of interesting stuff about SVN in action...


 One other good thing about Subversion is the flexibility of it's hooks.
 You can setup scripts to automatically deploy your changes to a live
 environment. It's ace!

2 points I'd like to make:

1. I'd be very wary of using an auto deployment script that is triggered
upon check in unless the deployment was only to test system. I think that
deployment to a production env should have at least one step that requires
human intervention - at the very least you have someone to blame if the
shit hits
the fan.**

2. CVS has wrapper/hook scripts that can also do tasks like this -
although I
gather that SVN's implementation is friendly  more manageable.


 If you are using an interal Wiki, Ticket system I can thoroughly
 recommend Trac for this. It has excellent integration with Subversion.

 Hope that helps.


** 'shit hits the fan' reminds me of something I saw in a LIDL supermarket
-
they had a ripoff version of 'PomBaer' crisps (potato chips) which was
called
'Bears Hit' ... I kid you not! now you too can say with confidence, 'I
feel
like eating some bear shit' :-

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




Re: [PHP] Re: London PHP salaries

2007-06-14 Thread Shafiq Rehman

Hi,

You can get a rough idea from
http://www.totaljobs.com/JobSearch/Results.aspx?Keywords=php+mysql

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385

On 6/14/07, Gary Smith [EMAIL PROTECTED] wrote:


Joker7 wrote:
 For living in London you would need at the lower end 35k but why would
you
 want to come and live in London from Spain ? If I had the choice I know
 where I would choose.

Indeed. It might also be worth pointing out that you'd be utterly
fruitloop to consider getting a central London flat. Live further out ==
cheaper. The thing with doing PHP in Central London is that people will
do it for less. Asking anything above £35k for a PHP developer (even a
decent one) is probably likely to get you laughed at.

(YMMV)

Gary

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




Re: [PHP] linking to an image with document_root

2007-06-01 Thread Shafiq Rehman

Hi,

You cannot use document_root to get the paths for images. You can write a
function to get the images url in your application.

function imageServer()
{
  return /images/;
}

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk
Cell: +92 300 423 9385


On 6/1/07, Chris [EMAIL PROTECTED] wrote:


blueboy wrote:
 May be a stupid question but can I link to images with doscument root

 $img_url= $_SERVER['DOCUMENT_ROOT'].'/images/holder.gif';

 echo img src=\$img_url\ width=\250\ height=\163\/;

An image source is the URL to that image.

The server document root is the local location of that file (eg
/home/user/file.gif) - which is never going to work as a URL.

--
Postgresql  php tutorials
http://www.designmagick.com/

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




Re: [PHP] Mail function

2007-04-05 Thread Shafiq Rehman

Hi,

What i understand is, you have written a new function for sending emails.
Are you passing all the variables to that function? If not, you have to
pass.

or you can use my function
?php
// function declaration, This function can send only HTML emails
function sendMail ($toEmail, $subject, $message, $fromName, $fromEmail)
{
   $header .= From: $from_name $fromEmail\n;
   $header .= Reply-To: $fromEmail\n;
   $header .= MIME-Version: 1.0\n;
   $header .= Content-type: text/html; charset=us-ascii; format=flowed\n;
   $header .= Content-Transfer-Encoding: 7bit\n;
   $header .= X-Mailer: php\n\n;
   mail($toEmail, $subject, $message, $header);
}
// variable values and usage
$toEmail= [EMAIL PROTECTED];
$subject = Hello, This is test;
$message= Hellow Shafiq, brbr This is test
messagebrbrRegardsbrShafiq;
$fromName= Sender Name;
$fromEmail= [EMAIL PROTECTED];
sendMail ($toEmail, $subject, $message, $fromName, $fromEmail);
?

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com | http://shafiq.pk

On 4/5/07, Zhimmy Kanata [EMAIL PROTECTED] wrote:


Hi,

  I am working on a program to create a registration feature through a
email notificaiton much like this list. For functional use but also for
personal training.

  However, I can't seem to pass the variable into the mail function() ? If
I echo the variable it displays it so it must be passing the variable down.
If I enter in a fixed and workable email address where $email is then it
works as well. So I am a little confused to this problem. I have other
programs where I do this but I place the mail function within a new
function(). However, when I do that it just barks back at me. Contacted my
Hosting company they are investigating.

  Thanks in advance for your help...

  Here is the code..

  echo $email;
   echo Thanks for registering!  - It does echo it.
   You will recieve an email shortly containing your validation code,
   and a link to activate your account!;


   mail($email, New Registration, www.sitename.com, 
Thanks for registering on SITE NAME.
Here are your login details:

Username: .$username.
Password: .$password.

In order to login and gain full access, you must validate your
account.

Click here to validate:

http://www.sitename.com/login/register.php?action=activateuser=
.$username.code=.$activation_code.

Thanks!

[Webmaster]
);

  I got the code from www.avengingsorrow.com to see all the code.

  Sorry about the HTML email. I am new to the list (first post) and I
don't believe you can turn off HTML email in Yahoo.

  Thanks again in advance

  Zhimmy


-
Make free worldwide PC-to-PC calls. Try the new Yahoo! Canada Messenger
with Voice


Re: [PHP] image uploading/resizing best practices in PHP

2007-03-22 Thread Shafiq Rehman

Option one is much better.

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/22/07, Tijnema ! [EMAIL PROTECTED] wrote:


On 3/22/07, Dwayne Heronimo [EMAIL PROTECTED] wrote:
 Dear All,

 I would like to make a script to upload a jpg filewith php to a server;
then
 make a thumb; save if for later use. And store the path to the image in
a
 database to display it later. But what is the best practice to do this
on a
 relatively low traffic website?

 I dont know where to begin but I have 2 appoaches:

 1. To make a script to upload the image and resize this on the fly and
store
 only the thumb image somewhere for later use. While also to store the
image
 path in de database for later retrieval.

The best way i think if you have enough space on the server to store the
thumb.


 2. to make a script to only upload the image as is and then insert the
image
 path in the database for later use. And upon displaying the image to use
 like a nondistructive img scr=resizer.php?imgfile=image.jpgwidth=250
 border=0 resizer to display the image in the desired dimentions.
This one is worser then the first one, because everytime you request
the thumb would cost some CPU power. This isn't a lot, but if you are
gonna process 1000s thumbs a time, it will really make difference in
performance.


 Which one would be the best practice now a days for a relative low
traffic
 site?
 I really have no idean how to build this but I have a good approach I
maybe
 could start searching for something more specific.

 Thanks for your help,

 Dwayne

You should have a look at the image functions of
PHP(www.php.net/image). Creating the thumbs is the hardest part. The
upload part should be no problem with a little bit of google :)
Or you might want to google for a full working scripts, i saw them around.

Tijnema


 --
 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] Password Protecting

2007-03-21 Thread Shafiq Rehman

visit http://www.softswot.com/Form1Password.php

On 3/21/07, Kevin [EMAIL PROTECTED] wrote:


Hello Everyone!

   I am new to PHP but I am hoping you guys can help me.  I would like
to have my users go to a page that looks like
http://f4.zittle.com/admin, or even just a drop down window or
something whre they can enter a username and password.  Depending on
the username, and of course assuming the password is correct, they
will be forwarded to a certain page or directory.  I think I need to
use a DB but I am not sure anything more.  Sorry it is such a simple
question but hopefully all of you can help!  Thanks in advanced!!!

Kevin

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





--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk


Re: [PHP] Flash animation without install Flash!

2007-03-21 Thread Shafiq Rehman

Impossible with flash... You can add GIF for tiny animations.

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/21/07, Helder Lopes [EMAIL PROTECTED] wrote:


Hi people,

Because the problems with virus in internet the people dont install
activex
controls.
My question is:

How to put a flash in the website without asking the person to install
activex control??

/Helder Lopes



Re: [PHP] Name Capitalization

2007-03-21 Thread Shafiq Rehman

Hi,

Some problems are universal and we cannot fix them in computer science. I
think it's better to educate/guide your visitors about such names that they
write in correct capitalization

Regards
--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/21/07, Tijnema ! [EMAIL PROTECTED] wrote:


On 3/21/07, Richard Lynch [EMAIL PROTECTED] wrote:
 On Tue, March 20, 2007 8:41 am, Tijnema ! wrote:
  What's against just capitalizing the first letter?
 
  Of course there exists a lot of different combinations where a capital
  letter should be, but if names are coming in like MCDONALD or
  mcdonald, a user would be happy if he sees Mcdonald.

 You have clearly never ever dealt with musicians. :-)

 They will not just accept the wrong capitalization.

 You will need to fix it.

 I'll hazard a wild guess somebody will complain about the uc_first
 solution, and for every complaint, you can count on 10 more who just
 shrugged it off, but it's still wrong.

Well, then you are working for hours on implementing filters for
special names, and then you still get a few names wrong... and then
you did all that work for a few fixes. It's just not worth to create
such filter.

Tijnema

 --
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some starving artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?



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




Re: [PHP] read only texbox to html with php

2007-03-21 Thread Shafiq Rehman

Please elaborate the question

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/21/07, Ross [EMAIL PROTECTED] wrote:


I have a readonly textbox that gets mailed as a newsletter. The text is a
standard covering letter. The problem is when I try and convert it to html
it doesn't work  It is inserted into a variable via a form textarea
$mail_text.

available on the web site a
href=http://www.myurl.org;http://www.myurl.org/a so you can see who is
doing.

I tried this

htmlentities((stripslashes($mail_text)));


Any ideas?

R.

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




Re: [PHP] php bar/graph scripts/library

2007-03-16 Thread Shafiq Rehman

Hello,

You can create graphs with Flash. Here is the link
http://www.maani.us/charts/index.php
Alternately you can also use JPGraph: http://www.aditus.nu/jpgraph/

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk


On 3/16/07, Tijnema ! [EMAIL PROTECTED] wrote:


On 3/16/07, Ron Croonenberg [EMAIL PROTECTED] wrote:
 hello all,

 I am looking for some  scripts/libraries etc to produce some bar graphs
etc.

 Does anyone know of something nice (that works on Linux)

 thanks,
 Ron

If i understand you correctly you want to have a moving progress bar?

If so, it is NOT possible with PHP, because PHP is server side, and
making that thing move should be done on client side (Javascript).

If you don't want to let it move, it is nothing more then just
displaying a picture of a bar :)

Tijnema

 --
 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: Posting variable outside of the post form

2007-03-13 Thread Shafiq Rehman

Hello,

Use session variables

--
Shafiq Rehman (ZCE)
http://phpgurru.com | http://shafiq.pk

On 3/13/07, Haydar Tuna [EMAIL PROTECTED] wrote:


Hello,
If your variable is not most important for your application
security, you should use HTML hidden form field but  If your variable is
most important for your application security, you should use session
variable. I think in your HTML form, you use GET method. In this method,
all
HTML form fields appear on your browser address bar and if you want to
hide
HTML form fields before send , you can use POST method. For a long HTML
form
variable you can use POST method:)

--
Haydar TUNA
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net

Otto Wyss [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
I submit a form back to itself with

   action=?PHP echo $_SERVER['PHP_SELF']; ? methode=get

 yet I've a large PHP variable which I'd like to access afterwards as
well.
 Is this possible somehow?

 O. Wyss

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




Re: [PHP] Re: remote file time -small issue

2007-02-22 Thread Shafiq Rehman

Hi,

Alternatively you can use CURL to get last modification time.

study the CURLOPT_HEADERFUNCTION constant for more details.

--
Shafiq Rehman (ZCE)
http://www.phpgurru.com, http://shafiq.pk

On 2/22/07, David Robley [EMAIL PROTECTED] wrote:


SJAMHO DBMS wrote:

 Dear Sirs,


 I have a problem with the attached file.
 Run it or see it here: http://www.sjamho.com/update/remote.php

 The issue is: the timestamps are shown for every file in a subdirectory,
 but never for a file in the root of a domain.
 Can anyone tell me why?


 Kind regards, Jos

It would really help to know what your code is.



Cheers
--
David Robley

MEOW... WOOF... It's a two-litter engine!
Today is Pungenday, the 53rd day of Chaos in the YOLD 3173.

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




Re: [PHP] Temporary Emails - Your Recommendations - An Appeal to the PHP Community

2007-01-03 Thread Shafiq Rehman

Hi,

You can use gmail account to receive as many mails as you want on different
email addresses with one account. For example my email address is
[EMAIL PROTECTED] I can receive email at [EMAIL PROTECTED] and
[EMAIL PROTECTED]

I love this feature especially when I am testing the signup process of any
web application bcoz usualy we do not allow users to create more than one
account with the same email address ;)
--
Shafiq Rehman
Zend Certified Engineer
http://phpgurru.com, http://shafiq.pk

On 1/3/07, Richard Lynch [EMAIL PROTECTED] wrote:






On Mon, January 1, 2007 4:26 am, Jason Paschal wrote:
 i realize this isn't the appropriate mailing list and i risk being
 black-listed (flame, defamed, ignored, etc.).

 i occasionally use temporary emails when registering for forums or to
 get
 some shareware (we've all done it, don't give me that look, i have
 given
 what i could, when i could) and while i like the way mytrashmail.com
 works,
 i don't like having mytrashmail.com as part of the temp addy.

 does anyone know of a similar service that uses a more enticing
 domain?

Yahoo.com?
Hotmail.com?

Or, since you control your own domain name, presumably, use something
like:
[EMAIL PROTECTED]
when you give your email to jpaschal.com and use
[EMAIL PROTECTED]
when you give your email to example.com and...

You can set up your email with catchall, or you can just set up the
email alias for as long as you need it to exist, and nuke it later
or...

--
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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




Re: [PHP] PAYPAL TRANSACTION.

2006-08-04 Thread Shafiq Rehman

On 7/31/06, Chris [EMAIL PROTECTED] wrote:


BBC wrote:
 Hi list..

 Please any one point me to the web which talk about making transaction
with paypal step by step. Some body offered me the source
 code and tutorial but until know he or she didn't send me.

http://www.paypal.com

I'm sure someone here has used / set up paypal but they provide complete
instructions on everything you need to do.

If you have any problems, that's what their support team is for.

--
Postgresql  php tutorials
http://www.designmagick.com/

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





Hi,

You can find PHP code examples for paypal integration at

https://www.paypal.com/cgi-bin/webscr?cmd=p/pdn/software_dev_kit_php-outside

--
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com


Re: [PHP] Searching and storing results index in cookies or session variables

2006-07-13 Thread Shafiq Rehman

Hello Brian,

Storing the result set in session or cookie is not a good idea. You can
implement some caching mechanism in your search results. I implemented this
in my project and it works simply great.

Its very simple, You have to write two functions

1- writeCache($id, $data, $ttl)
This routine will write data (serialized result set) in cache (file system)
with ttl (time to live as timestamp). $id is the file name on disk. you can
use md5 of your sql query.

Example:
$query = select * from table limit 0, 100
$id = md5($query);
$data = serialize(resultSet)
$ttl = time()+ 600; 10 minutes

When you executes your page first time, the above routine will generate a
cache file on disk (data from SQL)
When you execute your page 2nd time the getCache() will check the validity
of cache, if its valid then displays data from cache and if invalid creates
the new cache for next 10 minutes

2- getCache($id)
This function will checks the validity of cache and return false or
unserialized record set from cache

This mechanism will save your lot of MySQL queries in searching becoz you
are not querying every time. If your data is static you can increase the
$ttl accordingly.

--
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com

On 7/13/06, Brian Anderson [EMAIL PROTECTED] wrote:


Hello,

I have a question about how I am searching through a products database.
What I am wanting to do is store the result set so that I can provide a
link to go back to previous searches quickly, and also manipulate it
quickly. If I had a flat catalog  of pages I could index the content in
a few tables and go with that, but I want the results to be
customizable, and more flexible than ten links to ten items on ten
different pages. I want the results delivered and recombined in one page.

Currently what I am doing is the following:

  1. I open an SQL statement with delimiters
  2. I circulate through the entries and append to a array called
 $pageset both the item number and a ranking based on keywords etc.
  3. I sort the array by relevance ranking
  4. I figure out what my limit and offset are in my array and paginate
 based on user input.
  5. I grab the 20 or so array elements within the range and create a
 new array called $display set.
  6. For each of the current page items I pull the full item details
 from the database and propagate the array to my html template


I wonder if instead of propagating the $pageset (results index) array
every time I could store the $pageset  array as a cookie or session
variable.

It is a small array with a few hundred elements and rankings, but if I
could store it, I wouldn't have to build the array and do a relevancy
sort every time I paginate to the next page. I would just take the
current stored search array which is already sorted, and grab element x
through element y. Would this be an efficient way using a session
variable?

Does anybody else handle search results in a similar way?

-Brian Anderson

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




Re: [PHP] RE: [PHP-WIN] Dynamic HTML table sort with PHP

2006-07-09 Thread Shafiq Rehman

Hello,

Why not you use the javascript to sort any column on client side.

http://www.kryogenix.org/code/browser/sorttable/

1. include the js file in your page
2. give your table an id
3. put your table in the class the code looks for.

That's it.  Sortable clientside tables!  Example:
http://pkfinance.info/analysis/

Hope this will help!

Regards
Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com


Re: [PHP] Shopping Carts

2006-07-09 Thread Shafiq Rehman

hi,

http://www.cubecart.com/site/home/

CubeCart is an eCommerce script written with PHP  MySQL. With CubeCart you
can setup a powerful online store as long as you have hosting supporting PHP
and one MySQL database.

To edit or remove copyright thay charge $69.95 per domain* and you will be
issued with a License Key

I used it two years back and it works excellent


Shafiq Rehman
Sr. Web Engineer
http://www.phpgurru.com


Re: [PHP] Re: Setting cookie for two domains.

2006-01-05 Thread Shafiq Rehman
Hello Guys,

Thanx a lot for sharing some really great ideas. especial Mark and Albert
has suggested some great stuff to do.

Thanx a lot.
--
*** phpgurru.com [A php resource provider] ***

\\\|///
  \\  - -  //
   (  @ @  )   PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
|Mian Shafiq ur Rehman
|phpgurru.com [A php resource provider]
|107 B, New Town, Multan Road
|Lahore Pakistan
|
| Mobile:0300 423 9385
|
|   ooo0 http://www.phpgurru.com
|  ()   0ooo E-Mail: [EMAIL PROTECTED]
+---\  ((   )--+
  \_)) /
 (_/


Re: [PHP] help register domain name

2006-01-05 Thread Shafiq Rehman
This person should be awarded with some great prize :) Great topic.

On 1/5/06, Jay Blanchard [EMAIL PROTECTED] wrote:

 [snip]
  hi,
  i want to register a domain name through NetworkSolutions.com,
  but it require a credit card which i dont have to pay the bill.
 
  if you have a credit card, i can transfer to your account, and then
  you please regiter the domain using my info.
 
  or if you have any other ways to do so.
 
  p.s. i live in P.R.China. please make sure i can send money to you.
 
  anybody would like to help me ?
 

 Now this takes the prize of most off topic post of the year.
 [/snip]

 I held back to see if anyone would answer this first.but you're
 rightWE HAVE A WINNER!

 Only 5 days into 2006..

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




--
*** phpgurru.com [A php resource provider] ***

\\\|///
  \\  - -  //
   (  @ @  )   PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
|Mian Shafiq ur Rehman
|phpgurru.com [A php resource provider]
|107 B, New Town, Multan Road
|Lahore Pakistan
|
| Mobile:0300 423 9385
|
|   ooo0 http://www.phpgurru.com
|  ()   0ooo E-Mail: [EMAIL PROTECTED]
+---\  ((   )--+
  \_)) /
 (_/


[PHP] Setting cookie for two domains.

2006-01-04 Thread Shafiq Rehman
Hi,

How can I register a session or cookie for two domains. I want to maintain
logged user's state when he goes from one domain to other domain.

Example
Suppose a user is logged in on domain1.com. A cookie is set and user is
authenticated from database on the basis of that cookie. When he goes from
domain1.com to domain2.com, I want he remains loggedin on domain2.com. I do
not want any query string. Is it possible by playing with cookie or session
settings?

Please advise if anybody has faced such problem.

Regards
http://www.phpgurru.com


Re: [PHP] Output of html without using functions?

2005-09-14 Thread Shafiq Rehman
Hi,

You can use your code1.php as

?php
return rand(1,1);
?

and then you can get the value as

$returnedData = require(code1.php);


On 9/14/05, Gustav Wiberg [EMAIL PROTECTED] wrote:
 
 Hi there!
 
 Look at the following code
 
 
 code1.php
 
 ?php
 echo rand(1,1);
 ?
 
 
 code2.php
 
 //Here I want to get the output of code1.php without using functions. Is 
 it
 possible?
 //
 //Something like $test = require(http://domain/mobil_info.php); but
 instead of returning 1 at success I want to return the random value...
 
 Why? Because I want to be platform independent. I'm connecting to a server
 running PHP 4.3.11.
 
 Ideas? Please give me!
 
 /G
 http://www.varupiraten.se
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] Re: Parsing MS-WORD docs

2005-09-08 Thread Shafiq Rehman
Hello,

Thanx to all of you for excellent suggestions. I am using Linux as OS and I 
want to parse the CVs and place in db for fulltext search. I think wvWare 
will work a lot for my case.

Thanx again.

On 9/8/05, Ben Ramsey [EMAIL PROTECTED] wrote:
 
 zzapper wrote:
 On Wed, September 7, 2005 7:39 am, Shafiq Rehman wrote:
 
 Hello,
 
 I want to parse the .doc files with PHP. Anybody have some idea 
 regarding
 this problem.
 
 Your help regarding this matter is really appreciated
 
 
  Also consider antiword
 
 
 And also:
 
 wvWare: http://wvware.sourceforge.net/
 Word2x: http://word2x.sourceforge.net/
 
 --
 Ben Ramsey
 http://benramsey.com/
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


[PHP] Parsing MS-WORD docs

2005-09-07 Thread Shafiq Rehman
Hello,

I want to parse the .doc files with PHP. Anybody have some idea regarding 
this problem.

Your help regarding this matter is really appreciated

Regards
-- 

PHP is too logical for my brain (http://www.phpgurru.com)


Re: [PHP] how to divide string

2005-09-05 Thread Shafiq Rehman
Hi Zebic

It is pretty much simple./ Look into the code

$text = abcdefghijklmnopqrstuwvxyz;
$newtext = wordwrap($text, 4, br, 1);
echo $newtext;

// if you want all these chunks in an array use it as
$array = explode(br, $newtext);

echo $array[0];
echo $array[1];
echo $array[2];

Regards
Shafiq [http://www.phpgurru.com]


On 9/5/05, Adi Zebic [EMAIL PROTECTED] wrote:
 
 Hi,
 
 is there any magic function who can give me from:
 
 $string =  abcdefghijklmnopqrstuwvxyz;
 
 somthing like this:
 
 abcd
 efgh
 ijkl
 mnop
 qrst
 uwvx
 yz
 
 (each 'x' letters go to the next line)
 
 Thanks a lot,
 
 ADI
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] displaying certain number of character

2005-08-31 Thread Shafiq Rehman
Hey Philip you can use this function

function cuttext($text, $maxChars = 20, $tail = '')
{
$arrWords = explode( , $text);
$temp = ;
for ($i=0; $icount($arrWords); $i++)
{
$temp = ($i == 0 ? $arrWords[$i] :  . $arrWords[$i] );
if (strlen($temp)  $maxChars)
{
$returnStr = $temp;
} 
else 
{
return $returnStr.$tail;
}
}
return $returnStr;
}

Usage:
echo cuttext(Please visit my site, 15, $tail = '..');
This will echo Please visit

On 8/31/05, Philip Hallstrom [EMAIL PROTECTED] wrote:
 
  $words= If length is given and is negative,
  then that many characters will be omitted from
  the end of string (after the start position has
  been calculated when a start is negative). If start
  denotes a position beyond this truncation, an empty
  string will be returned. ;
 
  echo substr($words, 0, 50);
  ?
 
 
  I have been using this but how can I make sure I do not split a word in
  half? - Finishing on a space would probably do it.
 
 You could use wordwrap() to wrap lines at 50 characters and then just take
 the first line
 
 http://us3.php.net/wordwrap
 
 -philip
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] Re: security while building online store

2005-08-31 Thread Shafiq Rehman
You must read the articles by shiflet 
http://www.phpgurru.com/index.php?acion=pagingchid=www.shiflett.orgoffset=10

On 8/31/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 [EMAIL PROTECTED] wrote:
  kat
 
 Dzesi momak ;)
 
 I think you know PHP enough to make your code secure.
 Just take care (as Christian wrote)about sql-injections and
 register_globals.
 
 The biggest problem could be Linux/Apache/MySQL server security threat...
 
 
 ---
 avast! Antivirus: Outbound message clean.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


[PHP] php vulnerability

2005-08-22 Thread Shafiq Rehman
Hi all,

My server was hacked last week and the message displayed on home page was 
spy kidz owns your server. I researched on internet and found that this is 
some kind of trojan which infects the *.index files. It penetrate from HTTP. 
Some paople were saying that there is vulnerability in PHP. Please help how 
can I protect my server from further attacks.

Best Regards
-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] php vulnerability

2005-08-22 Thread Shafiq Rehman
Hi all,

Thanx to all of you. My server is running on Linux and there is not any 
phpbb running on it. If vulnerability is in my code.. Is there any way that 
I can find the buggy code on my server which allowed that trojan to write 
into all the index files.

I analyzed the apache logs but did not found any thing wrong. My server is 
protected with firewar and only port 80 is opened.

Thanx
-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/

On 8/22/05, Torgny Bjers [EMAIL PROTECTED] wrote:
 
 Shafiq Rehman wrote:
  My server was hacked last week and the message displayed on home page 
 was
  spy kidz owns your server. I researched on internet and found that 
 this is
  some kind of trojan which infects the *.index files. It penetrate from 
 HTTP.
  Some paople were saying that there is vulnerability in PHP. Please help 
 how
  can I protect my server from further attacks.
 
 Hello Shafiq,
 
 One very common culprit in this scenario would be phpBB, especially
 older versions, and if you are running PHP without safe_mode and
 include_path directives, a script could very well overwrite every
 world-writable (or web server writable) file on your entire server.
 Happened to us once after a client had been running an old phpBB
 version. We now have a set of scripts in place that scan our servers for
 vulnerable scripts, phpBB among those, and alerts us when they're found
 in a client's home directory.
 
 So, to protect your server: turn on safe_mode. If clients (if you have
 clients on the machine) request safe_mode to be turned off, you can do
 that manually in httpd.conf for Apache (not sure about IIS on Windows).
 Also, using hard include paths in the httpd.conf for each virtual host
 will prevent the scripts running on a site from including/touching files
 that are outside said paths unless they manage to run a shell with a PHP
 script that can be activated without using php.ini, which might in this
 case be another security hole.
 
 Regards,
 Torgny
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



Re: [PHP] Looking for CMS advice

2005-08-22 Thread Shafiq Rehman
Hey Michael, 

Visit the site for excellent open source CMS http://www.ez.no

Regards
-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/


Re: [PHP] Special HTML characters question.

2005-08-22 Thread Shafiq Rehman
Hi,

Here are two routines for your problem.

function htmlentities2($myHTML) {
$translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
$translation_table[chr(38)] = '';
return preg_replace(/(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/,amp; , 
strtr($myHTML, $translation_table));
}

function displaytextData($variable){
$variable = 
eregi_replace(quot;,'',eregi_replace(amp;,,eregi_replace(lt;,,eregi_replace(gt;,,htmlentities2($variable);
$variable = trim($variable);
return $variable;
}

Hopefully this will help a lot... Enjoy... ;)
-- 
*** phpgurru.com http://phpgurru.com [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo--+
| Mian Shafiq ur Rehman
| phpgurru.com http://phpgurru.com [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (( )--+
\_) ) /
(_/