mysql_real_escape_string

mysql_real_escape_string

am 17.02.2007 01:35:03 von Ron Piggott

--=-esgSqF59YxAARZw4Wa7d
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I am creating a form where I am using

$web_site_#

for the various fields. At the present time there are 11 fields I am
asking the user to key in. I am wondering if there is a slick way to
use the mysql_real_escape_string command with this so

$web_site_1 = mysql_real_escape_string($web_site_1);
$web_site_2 = mysql_real_escape_string($web_site_2);
$web_site_3 = mysql_real_escape_string($web_site_3);
....
$web_site_11 = mysql_real_escape_string($web_site_11);

would be replaced by some type of loop

Suggestions?

Ron


--=-esgSqF59YxAARZw4Wa7d--

Re: mysql_real_escape_string

am 17.02.2007 11:03:59 von Oskar

Ron Piggott wrote:

>I am creating a form where I am using
>
>$web_site_#
>
>for the various fields. At the present time there are 11 fields I am
>asking the user to key in. I am wondering if there is a slick way to
>use the mysql_real_escape_string command with this so
>
>$web_site_1 = mysql_real_escape_string($web_site_1);
>$web_site_2 = mysql_real_escape_string($web_site_2);
>$web_site_3 = mysql_real_escape_string($web_site_3);
>...
>$web_site_11 = mysql_real_escape_string($web_site_11);
>
>would be replaced by some type of loop
>
>
for ($i=1;$i<=11;$i++)
${"web_site_$i"}=mysql_real_escape_string(${"web_site_$i"}};

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

Re: mysql_real_escape_string

am 17.02.2007 17:07:13 von Michael Weaver

--Apple-Mail-1-147705158
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

Hi Ron,

One thing that you could do is name the variables as an array as
opposed to creating a series of like-named variables.

Instead of:




....


Which would give:

$web_site_1
$web_site_2
$web_site_3
....
$web_site_11

You could set up the variables as:




....



This would give you a $web_site array which could then be looped
through:

for($i = 0; $i < count($web_site);$i++)
{
$web_site[$i] = mysql_real_escape_string($web_site[$i]);
}

Hope this helps and is what you are looking for....

Best regards,

Mike Weaver

--
Michael Weaver
Founder/Chief Facilitator
Dynamic Insight
Enhancing Professional Awareness & Communication
Tel: 1.814.574.4871
Email: weaver@dynamicinsight.com

The information in this email and subsequent attachments may contain
confidential information that is intended solely for the attention
and use of
the named addressee(s). This message or any part thereof must not be
disclosed,
copied, distributed or retained by any person without authorization
from the
addressee. If you are not the intended recipient, please contact the
sender by
reply email and destroy all copies of the original message.





--Apple-Mail-1-147705158--

Passing emails to php script

am 18.02.2007 13:05:01 von ShortStay

I am trying to pass emails as they come in to a php script to parse. I
apologise in advance if this does not appear a database question, though
I will be using a database with it once I figure out the initial method
of getting the incoming email to the parsing script. If you think this
should go to another discussion group I will contritely go away.

I am on a shared server and have three options:

/mail account
Parsing messages directly by accessing them in the /mail directory (all
mail for the domain is stored there.). However, I don't think this will
work as it is unpredictable when they are deleted from the server ie
when I log on to my computer they are downloaded.

..procmail file
Or I could also manage filtering and handling using the .procmail file
in the root directory. Unfortunately, I don't have access to that file.

Adding a filter:
http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=32

I have tried to set up a filter in my server's control panel to pass all
messages to a program for processing (via |, a pipe). However, the
script does not seem to run in response to this.

In summary I have set up the filter to send incoming emails to a file
(/public_html/mailfilters/email.php), which is acknowledged in the
cpanel response when I test it, but the file should send me an email as
its only command but I don't get any email. The php file contents are
below also, it is a simple mail() test. So the first question is what
might be wrong here - why does the file not seem to execute, has it been
reached by the mail filter? I have asked the server support team but
they say it is a coding question. Is it significant that when sent a
message with test in the subject I get an error email back including this:

"A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/public_html/mailfilters/email.php
generated by john@shortstay-london.com
local delivery failed
"

The second question is what are the variable names for the input mail
sent by the mail filter, is it STDIN, the php constant, and is this an
array, or is there a way of knowing what the individual variable names
are representing the subject, body, from address etc?

mail.php:-
mail("john@shortstay-london.com","anytext","anytext","From:j ohn@shortstay-london.com");

?>

The filter is set up and I get this acknowledgement in response to a
test on the set up page:

*Filter Trace Results:*

Condition is true: $header_subject: contains test
Return-path copied from sender
Sender = shortsta@box148.bluehost.com
Recipient = shortsta@box148.bluehost.com
Testing Exim filter file "/etc/vfilters/shortstay-london.com"

Pipe message to: /public_html/mailfilters/email.php
*Filtering set up at least one significant delivery or other action.
**No other deliveries will occur.
*

I definitely have this file: /public_html/mailfilters/email.php.

Testing by sending an email to myself with test in the subject, I get a
return message:

"This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/public_html/mailfilters/email.php
generated by john@shortstay-london.com
local delivery failed

------ This is a copy of the message, including all the headers. ------

Return-path:
Received: from shortsta by box148.bluehost.com with local-bsmtp (Exim 4.63)
(envelope-from )
id 1HIXbm-00017Y-NC
for john@shortstay-london.com; Sat, 17 Feb 2007 15:00:49 -0700
X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on
box148.bluehost.com
X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0
tests=AWL,BAYES_00 autolearn=ham version=3.1.7
Received: from smtp803.mail.ird.yahoo.com ([217.146.188.63])
by box148.bluehost.com with smtp (Exim 4.63)
(envelope-from )
id 1HIXbm-00017P-Do
for john@shortstay-london.com; Sat, 17 Feb 2007 15:00:42 -0700
Received: (qmail 48251 invoked from network); 17 Feb 2007 22:00:41 -0000
Received: from unknown (HELO ?192.168.1.3?)
(ioannes@btinternet.com@81.158.50.3 with plain)
by smtp803.mail.ird.yahoo.com with SMTP; 17 Feb 2007 22:00:41 -0000
X-YMail-OSG:
mOKmmGAVM1kYlA.mjkBaa2_RtuLxhTh77Tbb41y1VQkB7oeisDh..4_lUjV8 QebfQsR.uBqJ.Q.rps5NVKrZnnsO2QSutda_GLqjKvSosK8xXg--

Message-ID: <45D77B08.1010901@shortstay-london.com>
Date: Sat, 17 Feb 2007 22:00:40 +0000
From: "john@shortstay-london.com"
Reply-To: john@shortstay-london.com
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
To: john@shortstay-london.com
Subject: test
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

test




John "

Any help appreciated.

John

>

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

RE: Passing emails to php script

am 27.02.2007 02:35:32 von Bastien Koert

Not sure if you got a reply to this yet, but another option is to read the
mailbox via a cron job. I use this successfully. You can see an example here
( http://www.weberdev.com/get_example-4015.html )


bastien

>From: "john@shortstay-london.com"
>Reply-To: john@shortstay-london.com
>To: php-db@lists.php.net
>Subject: [PHP-DB] Passing emails to php script
>Date: Sun, 18 Feb 2007 12:05:01 +0000
>
>I am trying to pass emails as they come in to a php script to parse. I
>apologise in advance if this does not appear a database question, though I
>will be using a database with it once I figure out the initial method of
>getting the incoming email to the parsing script. If you think this
>should go to another discussion group I will contritely go away.
>
>I am on a shared server and have three options:
>
>/mail account
>Parsing messages directly by accessing them in the /mail directory (all
>mail for the domain is stored there.). However, I don't think this will
>work as it is unpredictable when they are deleted from the server ie when I
>log on to my computer they are downloaded.
>
>.procmail file
>Or I could also manage filtering and handling using the .procmail file in
>the root directory. Unfortunately, I don't have access to that file.
>
>Adding a filter:
>http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=32
>
>I have tried to set up a filter in my server's control panel to pass all
>messages to a program for processing (via |, a pipe). However, the script
>does not seem to run in response to this.
>
>In summary I have set up the filter to send incoming emails to a file
>(/public_html/mailfilters/email.php), which is acknowledged in the cpanel
>response when I test it, but the file should send me an email as its only
>command but I don't get any email. The php file contents are below also,
>it is a simple mail() test. So the first question is what might be wrong
>here - why does the file not seem to execute, has it been reached by the
>mail filter? I have asked the server support team but they say it is a
>coding question. Is it significant that when sent a message with test in
>the subject I get an error email back including this:
>
>"A message that you sent could not be delivered to one or more of its
>recipients. This is a permanent error. The following address(es) failed:
>
>pipe to |/public_html/mailfilters/email.php
> generated by john@shortstay-london.com
> local delivery failed
>"
>
>The second question is what are the variable names for the input mail sent
>by the mail filter, is it STDIN, the php constant, and is this an array, or
>is there a way of knowing what the individual variable names are
>representing the subject, body, from address etc?
>
>mail.php:-
> >mail("john@shortstay-london.com","anytext","anytext","From: john@shortstay-london.com");
>
>?>
>
>The filter is set up and I get this acknowledgement in response to a test
>on the set up page:
>
>*Filter Trace Results:*
>
>Condition is true: $header_subject: contains test
>Return-path copied from sender
>Sender = shortsta@box148.bluehost.com
>Recipient = shortsta@box148.bluehost.com
>Testing Exim filter file "/etc/vfilters/shortstay-london.com"
>
>Pipe message to: /public_html/mailfilters/email.php
>*Filtering set up at least one significant delivery or other action.
>**No other deliveries will occur.
>*
>
>I definitely have this file: /public_html/mailfilters/email.php.
>
>Testing by sending an email to myself with test in the subject, I get a
>return message:
>
>"This message was created automatically by mail delivery software.
>
>A message that you sent could not be delivered to one or more of its
>recipients. This is a permanent error. The following address(es) failed:
>
>pipe to |/public_html/mailfilters/email.php
> generated by john@shortstay-london.com
> local delivery failed
>
>------ This is a copy of the message, including all the headers. ------
>
>Return-path:
>Received: from shortsta by box148.bluehost.com with local-bsmtp (Exim 4.63)
> (envelope-from )
> id 1HIXbm-00017Y-NC
> for john@shortstay-london.com; Sat, 17 Feb 2007 15:00:49 -0700
>X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on
>box148.bluehost.com
>X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00
>autolearn=ham version=3.1.7
>Received: from smtp803.mail.ird.yahoo.com ([217.146.188.63])
> by box148.bluehost.com with smtp (Exim 4.63)
> (envelope-from )
> id 1HIXbm-00017P-Do
> for john@shortstay-london.com; Sat, 17 Feb 2007 15:00:42 -0700
>Received: (qmail 48251 invoked from network); 17 Feb 2007 22:00:41 -0000
>Received: from unknown (HELO ?192.168.1.3?)
>(ioannes@btinternet.com@81.158.50.3 with plain)
>by smtp803.mail.ird.yahoo.com with SMTP; 17 Feb 2007 22:00:41 -0000
>X-YMail-OSG:
>mOKmmGAVM1kYlA.mjkBaa2_RtuLxhTh77Tbb41y1VQkB7oeisDh..4_lUjV 8QebfQsR.uBqJ.Q.rps5NVKrZnnsO2QSutda_GLqjKvSosK8xXg--
>
>Message-ID: <45D77B08.1010901@shortstay-london.com>
>Date: Sat, 17 Feb 2007 22:00:40 +0000
>From: "john@shortstay-london.com"
>Reply-To: john@shortstay-london.com
>User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
>MIME-Version: 1.0
>To: john@shortstay-london.com
>Subject: test
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Content-Transfer-Encoding: 7bit
>
>test
>
>
>
>
>John "
>
>Any help appreciated.
>
>John
>
>>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

____________________________________________________________ _____
Buy what you want when you want it on Sympatico / MSN Shopping
http://shopping.sympatico.msn.ca/content/shp/?ctId=2,ptnrid= 176,ptnrdata=081805

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

md5() function

am 14.01.2008 20:26:42 von MIGUEL ANTONIO GUIRAO AGUILAR

Hi!!

I'm using the md5() function to encrypt a password and store it into a
database. Now I want to retrieve that MD5 password and convert it into it's
human readable condition.
Is there a function opposite to md5()??

Best Regards,

M Guirao

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

Re: md5() function

am 14.01.2008 20:52:06 von Steven Cruz

Hello;

I maybe wrong, but I believe it is one way. What you need to do is take
your input and encrypt it and check if matches your current encrypted
value. :)

peace and hugs.

Miguel Guirao wrote:
> Hi!!
>
> I'm using the md5() function to encrypt a password and store it into a
> database. Now I want to retrieve that MD5 password and convert it into it's
> human readable condition.
> Is there a function opposite to md5()??
>
> Best Regards,
>
> M Guirao
>
>

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

Re: md5() function

am 14.01.2008 20:54:52 von andresmontanez

MD5 is also known as an one-way crypt system; you can encryptit but
never unencrypted; only using brute force or a hash list you can
retrive a 'string' that it's hash is the one stored; but it is not
necesary the same original string; this is also known as a hash
collision.

So, in short... no, there isn't a unMd5().
If you need to retrive the original string, try GPG.


On 14/01/2008, Miguel Guirao wrote:
> Hi!!
>
> I'm using the md5() function to encrypt a password and store it into a
> database. Now I want to retrieve that MD5 password and convert it into it=
's
> human readable condition.
> Is there a function opposite to md5()??
>
> Best Regards,
>
> M Guirao
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--=20
Atte, Andr=E9s G. Monta=F1ez
T=E9cnico en Redes y Telecomunicaciones
Montevideo - Uruguay

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

Re: md5() function

am 14.01.2008 20:55:24 von parasane

On Jan 14, 2008 2:26 PM, Miguel Guirao wrote:
> Hi!!
>
> I'm using the md5() function to encrypt a password and store it into a
> database. Now I want to retrieve that MD5 password and convert it into it's
> human readable condition.
> Is there a function opposite to md5()??

Negative. Once it's hashed with an MD5, SHA1, or similar
encryption method, it's (as of now) impossible to reverse. You could
create a table with a column of unencrypted phrases, characters, and
combinations, with a second column containing the correlating hashed
string, but that's about it.

--


Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].

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

Re: md5() function

am 14.01.2008 21:03:38 von Jason Gerfen

Steven Cruz wrote:
> Hello;
>
> I maybe wrong, but I believe it is one way. What you need to do is take
> your input and encrypt it and check if matches your current encrypted
> value. :)
>
> peace and hugs.
>
> Miguel Guirao wrote:
>> Hi!!
>>
>> I'm using the md5() function to encrypt a password and store it into a
>> database. Now I want to retrieve that MD5 password and convert it into
>> it's
>> human readable condition.
>> Is there a function opposite to md5()??
>>
>> Best Regards,
>>
>> M Guirao
>>
>>
>

If you want to do a comparison on the md5() hash you just created you
could always run your SQL query like:

SELECT * FROM `table` WHERE `password` = md5( $password ) LIMIT 1;

That will return a true or false value based on the md5() hash of the
$password var. But you cannot reverse the md5 hash to obtain the
original value unless you perform a crack on it using software available
software. I think what you are looking for is the base64_encode() and
base64_decode() functions which will perform a simple encoding of data.

--
Jason Gerfen

"I practice my religion
while stepping on your
toes..."
~The Ditty Bops

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

RE: md5() function

am 15.01.2008 04:38:03 von MIGUEL ANTONIO GUIRAO AGUILAR

Thanks every body for your replies!!

It is clear to me that I can not reverse a hased string!!
Thanks!!!

Guirao

-----Original Message-----
From: Jason Gerfen [mailto:jason.gerfen@scl.utah.edu]
Sent: Lunes, 14 de Enero de 2008 02:04 p.m.
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] md5() function


Steven Cruz wrote:
> Hello;
>
> I maybe wrong, but I believe it is one way. What you need to do is take
> your input and encrypt it and check if matches your current encrypted
> value. :)
>
> peace and hugs.
>
> Miguel Guirao wrote:
>> Hi!!
>>
>> I'm using the md5() function to encrypt a password and store it into a
>> database. Now I want to retrieve that MD5 password and convert it into
>> it's
>> human readable condition.
>> Is there a function opposite to md5()??
>>
>> Best Regards,
>>
>> M Guirao
>>
>>
>

If you want to do a comparison on the md5() hash you just created you
could always run your SQL query like:

SELECT * FROM `table` WHERE `password` = md5( $password ) LIMIT 1;

That will return a true or false value based on the md5() hash of the
$password var. But you cannot reverse the md5 hash to obtain the
original value unless you perform a crack on it using software available
software. I think what you are looking for is the base64_encode() and
base64_decode() functions which will perform a simple encoding of data.

--
Jason Gerfen

"I practice my religion
while stepping on your
toes..."
~The Ditty Bops

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

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

Select...

am 15.01.2008 04:44:21 von MIGUEL ANTONIO GUIRAO AGUILAR

Hello List,

I'm having kind of trouble to get done this: Select data from a table,
except those data already in a second table. Actually, if there is a rowid
in table2, I wont get it from table1, rowid is the key that relates both
tables.

I just can't express this with a SQL statement!! idequipomed is the key that
relates both tables!!
So, if idequipomed is already in Table2, I shouldn't get it from Table1.
Any suggestions?

Table1
Field Type Null Key Default Extra
Privileges
----------- ------------------- ------ ------ ---------- --------------
-------------------------------
idequipomed tinyint(3) unsigned PRI (NULL) auto_increment
select,insert,update,references
idcat tinyint(3) 0
select,insert,update,references
af varchar(10)
select,insert,update,references
ns varchar(10)
select,insert,update,references
depto varchar(40) YES (NULL)
select,insert,update,references
zona char(3)
select,insert,update,references
reqcal char(1) YES 1
select,insert,update,references
tipocal char(1)
select,insert,update,references
estado char(2)
select,insert,update,references
alta date 0000-00-00
select,insert,update,references
ubicacion varchar(15) 0
select,insert,update,references

Table2
Field Type Null Key Default Extra
Privileges
----------- ------------------- ------ ------ ------- -------------- -
------------------------------
calid tinyint(4) unsigned PRI (NULL) auto_increment
select,insert,update,references
idequipomed tinyint(4) unsigned 0
select,insert,update,references
faseid tinyint(4) unsigned 0
select,insert,update,references
ultimacal date YES (NULL)
select,insert,update,references
proxcal date YES (NULL)
select,insert,update,references
idcat tinyint(4) unsigned 0
select,insert,update,references


-----Original Message-----
From: Daniel Brown [mailto:parasane@gmail.com]
Sent: Lunes, 14 de Enero de 2008 01:55 p.m.
To: Miguel Guirao
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] md5() function


On Jan 14, 2008 2:26 PM, Miguel Guirao
wrote:
> Hi!!
>
> I'm using the md5() function to encrypt a password and store it into a
> database. Now I want to retrieve that MD5 password and convert it into
it's
> human readable condition.
> Is there a function opposite to md5()??

Negative. Once it's hashed with an MD5, SHA1, or similar
encryption method, it's (as of now) impossible to reverse. You could
create a table with a column of unencrypted phrases, characters, and
combinations, with a second column containing the correlating hashed
string, but that's about it.

--


Daniel P. Brown
Senior Unix Geek and #1 Rated "Year's Coolest Guy" By Self Since
Nineteen-Seventy-[mumble].

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

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

Re: Select...

am 15.01.2008 11:46:46 von Niel Archer

Hi

First off, please create your own thread, do not reply to someone else's
and change the subject.

> I'm having kind of trouble to get done this: Select data from a table,
> except those data already in a second table. Actually, if there is a rowid
> in table2, I wont get it from table1, rowid is the key that relates both
> tables.
>
> I just can't express this with a SQL statement!! idequipomed is the key that
> relates both tables!!
> So, if idequipomed is already in Table2, I shouldn't get it from Table1.
> Any suggestions?

You need to do a join between the two tables using the common column to
make the connection. This should get you started

SELECT * FROM Table1 RIGHT JOIN Table2 USING (idequipomed) WHERE Table1.idequipomed
IS NULL


--
Niel Archer

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

Re: Select...

am 15.01.2008 12:30:46 von Oskar

-------- Original Message --------
Subject: [PHP-DB] Select...
From: Miguel Guirao
To: php-db@lists.php.net
Date: 15.1.2008 4:44
> Hello List,
>
> I'm having kind of trouble to get done this: Select data from a table,
> except those data already in a second table. Actually, if there is a rowid
> in table2, I wont get it from table1, rowid is the key that relates both
> tables.
>
> I just can't express this with a SQL statement!! idequipomed is the key that
> relates both tables!!
> So, if idequipomed is already in Table2, I shouldn't get it from Table1.
> Any suggestions?
>
>
Many ways to do this. Choose the solution that gives you the best
performance.

Solution 1:
SELECT t2.idequipomed
FROM table2 t2
WHERE NOT EXISTS (
SELECT 1 FROM table1 WHERE table1.idequipomed = t2.idequipomed
)

Solution 2:
SELECT idequipomed
FROM table2
WHERE idequipomed NOT IN (SELECT idequipomed FROM table1)

Solution 3:
SELECT table2.idequipomed
FROM table2
LEFT JOIN table1 ON table1.idequipomed = table2.idequipomed
WHERE table1.idequipomed IS NULL

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