Re: [PHP] [News] Affordable Independent Web Developer - Search Engine Optimization Services - March 19th, 2009

2009-03-20 Thread James Ausmus
On Fri, Mar 20, 2009 at 11:39 AM, Ginkga Studio, LLC
 wrote:
> LOL.
>
> :0)
>
> Ok. You guys are fun but I have to get to work. Hope all works out for you
> guys. Sorry for posting to your list. Just block me so I don't bother you
> again.
>
> Good luck with all your programming. You all seem like pretty good people.
>
> Sorry for harassing you George. I'm sure you are sexy in something short and
> lacy.
>
> Sorry for offending Daniel and all of his greatness. I'm sure he's a pretty
> good guy when he isn't being so defensive.
>
>
> Anyway, nice meeting you all, even it was on such terms.
>
> God Bless.
>
> XOXOXOXO
>

OK, umm... Wow. Bi-polar, anyone??? I'm getting whiplash reading this
thread. Not to say it isn't entertaining... ;)

-James






>
>
>
> -Original Message-
> From: George Larson [mailto:george.g.lar...@gmail.com]
> Sent: Friday, March 20, 2009 11:34 AM
> To: Thiago H. Pojda
> Cc: webdes...@ginkga.com; php-general@lists.php.net
> Subject: Re: [PHP] [News] Affordable Independent Web Developer - Search
> Engine Optimization Services - March 19th, 2009
>
> Oh, good; I look forward to polishing your nails... spammer.
>
>
> On Fri, Mar 20, 2009 at 2:29 PM, Thiago H. Pojda 
> wrote:
>
>
>        On Fri, Mar 20, 2009 at 3:23 PM, Ginkga Studio, LLC
> wrote:
>
>
>        >
>        > IF YOU WERE MY HUSBAND I WOULD SPANK YOUR ASS SO HAR YOU'D NEVER
> TALK BACK
>        > ANY WOMAN EVER AGAIN !!!
>        >
>        >
>
>        > Oh, gee.
>
>        Thanks for filters, Gmail.
>
>        --
>        Thiago Henrique Pojda
>        http://nerdnaweb.blogspot.com
>
>
>
>
>
> --
> 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] Directing form to different handlers?

2009-06-01 Thread James Ausmus
On Mon, Jun 1, 2009 at 12:32 PM, Matthew McKay  wrote:
> It would be much simpler and cleaner to use Javascript to modify the form's
> action attribute onClick.
>

Not really. What about clients who don't have Javascript installed?
What about users who want to either do something nefarious or just to
see what happens,  - exposing your "Delete my record"-specific PHP
code could potentially cause security holes. The less of your internal
interface/structure you expose to the end user, the less easy it is
for the casual script kiddies to find the security holes that you have
(and yes, everyone has them... ;)  )

-James

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



Re: [PHP] Plotting a Line Graph

2009-10-16 Thread James Ausmus
jpgraph:

http://www.aditus.nu/jpgraph/

On Fri, Oct 16, 2009 at 10:32 AM,   wrote:
> (sorry about the long Subject line typo - resending)
>
> I have a data file that stores about 500 numbers in a record - meant to plot
> a basic line graph (left to right). The numbers can be imported into a
> record with 500 fields or just stored in a text field - which ever is
> better.
>
> The user might want to pick a few random records and plot them together - so
> the line graph may compare the few records together.
>
> It seems that the google charts work from a url - so 500 points would be way
> to long for any url - so I guess that option is out.
>
> Q: what is the best way to create / display line graphs in with PHP?
>
> Thanks in advance for your help - dave
>
>
>
>
> Thanks,
> c...@hosting4days.com
>
>
>
>
>
>
> --
> 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



[PHP] Override parent class constants

2007-08-22 Thread James Ausmus
Hello - I'm trying to find a (sane) way to, in an extended class,
override the parent class's constants, something like the following
(which doesn't actually work):

class baseClass
{
  const myBaseVar = "base value!";

  protected $myVar;

  function __construct()
  {
$this->myVar = self::myBaseVar;
echo $this->myVar;
  }
}

class extClass
{
  const myBaseVar = "overriden value!";
}


And, when instanciated, should do the following:

$bc = new baseClass();
Output: base value!

$ec = new extClass();
Output: overridden value!


Any way to do that?
There's a hacky way to do it, which would be to change the
__contruct() function to the following:

function __construct()
{
  $this->myVar = eval("echo " . get_class($this) . "::myBaseVar;");
  echo $this->myVar;
}

but that is really, really ugly - I don't want to have to change all
instances of myVar re-initialization in my baseClass methods into eval
statements...


Any thoughts?

-James

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-08-29 Thread James Ausmus
On 8/29/07, Stephen <[EMAIL PROTECTED]> wrote:
> --- Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> > So to say it another way, I have a table that has
> > 900 records in it,
> > I've added 3 records, but then deleted 2 of those
> > which puts the
> > actual record count at 901 but my auto increment
> > field starts at 904
> > on the next insert.
> >
> > Is there away with PHP that I can pragmatically
> > change that value to
> > the total records in the database more so then a
> > representation of
> > the actual record number?
>
> Some database concepts:
>
> The autoincrement feature is to provide a unique "key"
> for the record. It does not provide an "order". Many
> tables have more than one "order".
>
> Usually a different field or field determines the
> order(s). It usually has an index.
>
> To provide a row number, based on some order, you need
> a field for this. Whenever a field is deleted, you
> would need to repopulate the fields in each record
> after the deleted record in the database.
>
> I saw a nested SQL query that did this once, but my
> SQL is not good enough to try to illustrate.

Fairly easy - depending on your version of MySQL - if you are 5.0+,
then the following will do it:

SELECT @rownum:[EMAIL PROTECTED] rownum, t.* FROM (SELECT @rownum:=0) r, 
myTable t;

(Quoted from a post by Mark Malakanov on April 30 2006 1:42pm at
http://dev.mysql.com/doc/refman/5.0/en/user-variables.html)

-James


>
> Stephen
>
> --
> 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] Try to find a solution, when restart Apache with PHP Script

2007-09-18 Thread James Ausmus
On 9/17/07, Rodolfo De Nadai <[EMAIL PROTECTED]> wrote:
> Hi all...
>
> I'm facing a serious problem with my application. I have a script write
> in PHP that starts in Internet Explorer, this script keep on running
> until a varible value change on my MySQL database.
> The problem is that when i restart Apache, the process child initalized
> isn't kill... then the apache can't be start because the script is use
> the port 80.

Hi Rodolfo-

I think you are going about this the wrong way. You shoud not have the
PHP script itself execute the forever running task, it should just
trigger the separate starting/stopping of the task. There are several
ways to do this, the first two that spring to mind are:

1. Create a custom init-script in /etc/init.d (or wherever your
distribution has init scripts) that the PHP process triggers with a
start command (/etc/init.d/myprog start). This will require root
privileges for the PHP process (or no-password sudo privileges for
that command).

--or--

2. Have a cron job running as a user that has appropriate permissions.
This cron job should look for the presence of specific files - if it
sees them, it takes the appropriate action, and then deletes the
trigger file. For example, have the cron job watch for the presence of
/tmp/startMyProg.marker - when it sees it, it starts the program and
deletes /tmp/startMyProg.marker. Also have it watch for the presence
of /tmp/stopMyProg.marker, when it sees that, it would stop the
running program, and delete the marker file. At this point, all your
PHP script has to do is create the appropriate file in /tmp (could be
as simple as a exec("touch /tmp/startMyProg.marker") call).

Hope that sends you a workable direction-

James

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



Re: [PHP] the opposite of a join?

2007-10-03 Thread James Ausmus
On 10/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I have a company table and a contacts table.  In the contacts table, there
> is a field called "companyID" which is a link to a row in the company
> table.
>
>
>
> What is the easiest way to query the company table for all the company
> rows
> whose ID is NOT linked to in the contact table? Basically, the opposite of
> a
> join?



SELECT company.*
FROM company LEFT JOIN contacts ON (company.companyID = contacts.companyID)
WHERE contacts.companyID IS NULL

(Assuming your DB can handle a left join)

-James



Thanks
>
>
>
> J
>
>
>
>


Re: [PHP] RE: the opposite of a join?

2007-10-03 Thread James Ausmus
On 10/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hi J,
> >
> >
> > Checkout this,
> >
> >
> > SELECT * FROM tbl_company where id not in (SELECT companyID from
> > tbl_contacts)
> >
>
>
> Brilliant! This is exactly what I was looking for, and is quite
> logical/readable!  Thanks to everyone for the ideas!
>
> J
>

No, don't do this! It is a very inefficient way to retrieve the
information you are looking for (Use a query analysis tool to check it
out yourself, if you want) - if your tables get to any larger size at
all, it will start having a noticeable performance impact on your
script (not to mention your DB) - let the DB do the hard work and use
a LEFT JOIN syntax, the database can optimize that much more
efficiently. Only if your DB doesn't support the LEFT JOIN syntax
would you want to do the above.

-James



>
>
>
>
>
> >
> >
> >
> >
> > Regards,
> > Lasitha Alawatta
> > Application Developer
> > Destinations of the World Holding Establishment
> > P O Box: 19950
> > Dubai, United Arab Emirates
> > ( Ph +971 4 295 8510 (Board) / 1464 (Ext.)
> > 7 Fax +971 4 295 8910
> > + [EMAIL PROTECTED]
> >
> > -Original Message-
> > From: John Pillion [mailto:[EMAIL PROTECTED] 
> On Behalf Of
> > [EMAIL PROTECTED]
> > Sent: Wednesday, October 03, 2007 2:21 PM
> > To: php-general@lists.php.net; [EMAIL PROTECTED]
> > Subject: [PHP-DB] the opposite of a join?
> >
> > I have a company table and a contacts table.  In the contacts table,
> > there
> > is a field called "companyID" which is a link to a row in the company
> > table.
> >
> >
> >
> > What is the easiest way to query the company table for all the company
> > rows
> > whose ID is NOT linked to in the contact table? Basically, the opposite
> > of a
> > join?
> >
> >
> >
> > Thanks
> >
> >
> >
> > J
> >
> >
> >
> > DOTW DISCLAIMER:
> >
> > This e-mail and any attachments are strictly confidential and intended
> > for the addressee only. If you are not the named addressee you must not >
> disclose, copy or take
> > any action in reliance of this transmission and you should notify us as
> > soon as possible. If you have received it in error, please contact the
> > message sender immediately.
> > This e-mail and any attachments are believed to be free from viruses but
> > it is your responsibility to carry out all necessary virus checks and
> > DOTW accepts no liability
> > in connection therewith.
> >
> > This e-mail and all other electronic (including voice) communications
> > from the sender's company are for informational purposes only.  No such
> > communication is intended
> > by the sender to constitute either an electronic record or an electronic
> > signature or to constitute any agreement by the sender to conduct a
> > transaction by electronic means.
> >
>
> >
>
>

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



Re: [PHP] How do I get PHP to save a backslash in a Mysql table?

2007-10-10 Thread James Ausmus
On 10/10/07, Don Proshetsky <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a field in which a user inputs a Windows style directory path, hence
> using backslashes and not forward slashes.
>
> Example: c:\qb\data\mydatadile.qbw
>
> However, when the use clicks update, what gets saved is:
> c:qbdatamydatadile.qbw
>
> Does anyone know if there is a work around?

How are you checking the value actually saved in the database -
through another PHP script, or directly via the MySQL
command-line-interface? If you're using another script to view the
value, it might be the display script that is screwing up, not the
save script - check the value directly with the MySQL CLI client.

HTH-

James



>
> The backslashes mysteriously are stripped.  I use the following function to
> wrap each variable that's saved in the MySQL table:
>
> function update_database($value)
> {
>// Addslashes
>if (!(get_magic_quotes_gpc())) {
>$value = addslashes($value);
>}
>// Quote if not a number or a numeric string
>if (!is_numeric($value)) {
>$value = mysql_real_escape_string($value);
>}
>return $value;
> }
>
>

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



Re: [PHP] combining 2 arrays

2007-10-16 Thread James Ausmus
On 10/16/07, Ladislav Andel <[EMAIL PROTECTED]> wrote:
> Hi list!
> I read data from 2 databases and for the purpose of displaying the
> information at my web interface as one piece
> I need to combine the data into one array first.. Here is my problem:
>
> Firstly, it reads from first DB and get this array: (it's a sum of
> server names in table)
>
> arrayDB1 = array(array('8', 'SER'),  array('5','Asterisk'))
>
> When finished then it starts reading from second DB
> where I would get
>
> arrayDB2 = array(array('6', 'XIP'),  array('4','Asterisk'))
>
>
> Is there any function where I would get
> result = array(array('8', 'SER'),  array('9','Asterisk'), array('6','XIP'))

If you have to have data manipulation when combining the arrays (such
as adding the two separate values for "Asterisk" as per your example),
then there isn't a pre-defined function to do what you want. I'd
change the arrangement of your arrays a bit, so that they looked
something like the following (very untested):

$arrDB1 = array('Asterisk' => 5, 'SER' => 8);
$arrDB2 = array('Asterisk' => 4, 'SER' => 6);

function addArrays($arr1, $arr2)
{
  $res = array();

  if (is_array($arr1) and is_array($arr2))
  {
$keys = array_merge(array_keys($arr1), array_keys($arr2));
foreach ($keys as $key)
{
  $res["$key"] = $arr1["$key"] + $arr2["$key"];  //May have to
check isset of each $arrX["$key"] before addition, not sure
}
  } else
  {
//Do appropriate error handling here...
  }
  return $res;
}



>
> Probably, it would be best to add number of Asterisk while cycling
> through data of second DB.
> The problem could be when databases have thousands of rows in each DB.
>
> I'm just asking in case you know a better approach.
>
> Thank you,
> Lada
>
> --
> 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] combining 2 arrays

2007-10-16 Thread James Ausmus
Array merge won't work as he needs to add the numerical values
involved, not just merge the arrays - there are overlap on the text
values, and any overlap needs to result in a val1 + val2.

-James


On 10/16/07, Daevid Vincent <[EMAIL PROTECTED]> wrote:
> > -Original Message-
> > From: Ladislav Andel [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, October 16, 2007 1:05 PM
> > To: James Ausmus; PHP List
> > Subject: Re: [PHP] combining 2 arrays
> >
> > Thank you very much!
> > It's exactly the code I was looking for!
> >
> > Lada
> > PS: my previous ungly code is half long now :)
> >
> > James Ausmus wrote:
> > > On 10/16/07, Ladislav Andel <[EMAIL PROTECTED]> wrote:
> > >
> > >> Hi list!
> > >> I read data from 2 databases and for the purpose of displaying the
> > >> information at my web interface as one piece
> > >> I need to combine the data into one array first.. Here is
> > my problem:
> > >>
> > >> Firstly, it reads from first DB and get this array: (it's a sum of
> > >> server names in table)
> > >>
> > >> arrayDB1 = array(array('8', 'SER'),  array('5','Asterisk'))
> > >>
> > >> When finished then it starts reading from second DB
> > >> where I would get
> > >>
> > >> arrayDB2 = array(array('6', 'XIP'),  array('4','Asterisk'))
> > >>
> > >>
> > >> Is there any function where I would get
> > >> result = array(array('8', 'SER'),  array('9','Asterisk'),
> > array('6','XIP'))
> > >>
> > >
> > > If you have to have data manipulation when combining the
> > arrays (such
> > > as adding the two separate values for "Asterisk" as per
> > your example),
> > > then there isn't a pre-defined function to do what you want. I'd
> > > change the arrangement of your arrays a bit, so that they looked
> > > something like the following (very untested):
> > >
> > > $arrDB1 = array('Asterisk' => 5, 'SER' => 8);
> > > $arrDB2 = array('Asterisk' => 4, 'SER' => 6);
> > >
> > > function addArrays($arr1, $arr2)
> > > {
> > >   $res = array();
> > >
> > >   if (is_array($arr1) and is_array($arr2))
> > >   {
> > > $keys = array_merge(array_keys($arr1), array_keys($arr2));
> > > foreach ($keys as $key)
> > > {
> > >   $res["$key"] = $arr1["$key"] + $arr2["$key"];  //May have to
> > > check isset of each $arrX["$key"] before addition, not sure
> > > }
> > >   } else
> > >   {
> > > //Do appropriate error handling here...
> > >   }
> > >   return $res;
> > > }
> > >
> > >
> > >
> > >
> > >> Probably, it would be best to add number of Asterisk while cycling
> > >> through data of second DB.
> > >> The problem could be when databases have thousands of rows
> > in each DB.
> > >>
> > >> I'm just asking in case you know a better approach.
> > >>
> > >> Thank you,
> > >> Lada
>
> Wouldn't this work?
> http://us2.php.net/manual/ro/function.array-merge.php
> http://us2.php.net/manual/ro/function.array-merge-recursive.php
>
> Also, you don't need to do (and shouldn't do):
>
> $arr1["$key"]
>
> Just make it
>
> $arr1[$key]
>
> No " marks. The quotes are a waste of time and will slow down your script if
> you have many rows.
>
> --
> 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] variable substitution

2008-01-01 Thread James Ausmus
On Jan 1, 2008 2:17 PM, jekillen <[EMAIL PROTECTED]> wrote:
> Hello again;
> I have two variables declared in the global scope of a script.
> $string_a = 'stuff $string_b and more stuff';
> $string_b = '';
> One is a string with a reference for substitution to the other
> string which is empty.
> In the processing body of the script are if/if else blocks.
> In these blocks I want to use $string_a  and
> set $string_b  to a value
> if( condition)
> { $string_b = 'by the way;';... etc
> so $string_a should read:
> "stuff and by the way; and more stuff"
> But this substitution will not take place
> in the context of the else if block. I do not
> want to write $string_a in at least 5 different
> if else blocks because it is about 10 lines
> intended to be an e-mail message body -> !SPAM.

Several ways to do this (and avoid globals or a str_replace call):

#1:

if (condition)
{
  $string_b = 'blah';
} else if (condition2)
{
 $string_b = 'foo';
} else if (condition3)
{
  $string_b = 'bar';
} else
{
  $string_b = 'other';
}

$string_a = "stuff $string_b and more stuff";

The reason for this is the variable substition occurs *at the time of
assignment* - not later.

Another way, if it's not easy to have your string_b setting
conditionals all in a row like that (or if this needs to be done
elsewhere in code, as well), would be:

function assignStrA($subStr)
{
  $retVal = "stuff $subStr and more stuff";
  return $retVal;
}

if (cond1)
{
  $string_a = assignStrA('foo');
} else if (cond2)
{
  $string_a = assignStrA('bar');
} else
{
  $string_a = assignStrA('other');
}


HTH-

James Ausmus
Integration Software Engineer
HTRI
"Cross Technology Integration Specialists"
503-538-8085



>
> this script is used to process data sent from a
> link in another e-mail message used to validate
> and e-mail address.
>
> Q: Is there a way to get the substitution to take
>  place here? (by reference, maybe?)
>
> Thank you in advance for info
> Jeff K
>
> --
> 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] More frustration with MySQL and PHP

2008-01-21 Thread James Ausmus
On Jan 21, 2008 11:57 AM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> Today, I found a bug in my software which I was originally happy to
> find since that means there's one less that I have to worry about... 3
> hours later while trying to figure out how to fix it I wish I never
> found it!
>
> Here's the deal, I have a file that exports the records in the
> database to excel, which works perfectly, except for 1 small thing...
> If you search the database first, it exports just those records.
>
> Basically what I need to do is allow people the choice of either
> exporting just certain search criteria, or the entire database without
> having to logout/login each time.
>
> I have tried using HTTP_REFERER to grab weither the user is coming
> from search.php (My search script) or directly from the index.php site
> which would mean they want the entire database.  Nothing I have done
> has been successful, I either get just the search criteria exported,
> or I get the entire database depending on which version I try it from.
>
> Anyone have any ideas?

Just set a form var (or add a GET variable to your link) from your
search.php page that says that you only want the searched records,
something like:



And then, in your export script, check for the existence of that
variable before doing your query:



HTH-

James



>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
> --
> 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] Using mysql_real_escape_string without connecting to mysql

2008-01-23 Thread James Ausmus
Try using the mysql_ping() command to check to see if your connection
is available:

http://us2.php.net/manual/en/function.mysql-ping.php

something like:



HTH-

James


On Jan 22, 2008 6:04 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> On 23/01/2008, Richard Lynch <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Tue, January 22, 2008 7:01 pm, Dotan Cohen wrote:
> > > I have a file of my own functions that I include in many places. One
> > > of them uses mysql_real_escape_string, however, it may be called in a
> > > context that will or will not connect to a mysql server, and worse,
> > > may already be connected. So I must avoid connecting. However, when I
> > > run the script without connecting I get this error:
> >
> > Don't do that?
> > :-)
> >
> > Can the file really do anything useful without the DB?
>
> The file defines some of my own functions, like these:
>
> function clean_html ($dirty) {
> $dirty=strip_tags($dirty);
> $clean=htmlentities($dirty);
> return $clean;
> }
>
> function clean_mysql ($dirty) {
> $dirty=str_replace ("--", "", $dirty);
> $dirty=str_replace (";", "", $dirty);
> $clean=mysql_real_escape_string($dirty);
> return $clean;
> }
>
> I use these functions in many places, so I simply put them all in a
> file and include it in each page.
>
> > When there *IS* a connection, how do you access it?
>
> mysql_fetch_array or mysql_result
>
> > Can't the file check somehow?
>
> I suppose that it could, by checking the return of one of the two
> functions above. Lucky for me, I always use UTF-8 so I won't get stuck
> connecting with one encoding yet doing mysql_real_escape_string with
> another, which would be a problem if I had to deal with multiple
> encodings.
>
>
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>


Re: [PHP] Using mysql_real_escape_string without connecting to mysql

2008-01-23 Thread James Ausmus
On Jan 23, 2008 10:03 AM, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> On 23/01/2008, James Ausmus <[EMAIL PROTECTED]> wrote:
> > Try using the mysql_ping() command to check to see if your connection
> > is available:
> >
> > http://us2.php.net/manual/en/function.mysql-ping.php
> >
> > something like:
> >
> >  >
> > if ([EMAIL PROTECTED]()) //Note the @ is because, if mysql_ping cannot get
> > connected, it will display a warning - suppress so users don't see
> > {
> >   connectToDB();> }
> >
> > mysql_real_escape_string('stuff');
> >
> > ?>
> >
> > HTH-
> >
> > James
> >
>
> I was thinking about that, but the problem is that if there is no
> connection, then the include is called and doesn't provide the
> mysql_clean function that I expect that it would. Then, I make a
> connection and use the function, expecting it to clean my data and it
> doesn't.

You should be able to have the best of both worlds - it shouldn't have
to be an either/or:

function clean_mysql ($dirty) {
   $dirty=str_replace ("--", "", $dirty);
   $dirty=str_replace (";", "", $dirty);
   if ([EMAIL PROTECTED]())
   {
 functionThatConnectsToMySQL();
   }
   $clean=mysql_real_escape_string($dirty);
   return $clean;
}

This will connect if not connected, but either way it will still run
the mysql_real_escape_string function - it's not inside an else
statement...

-James





>
>
> Dotan Cohen
>
> http://what-is-what.com
> http://gibberish.co.il
> א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
>
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
>


Re: [Fwd: Re: [PHP] Please stop me from tearing my hair out.]

2008-06-19 Thread James Ausmus
On Thu, Jun 19, 2008 at 7:54 AM, Robert Cummings <[EMAIL PROTECTED]> wrote:

> Ummm, yes it is :) Static variables have persistence beyond the function
> call and thus beyond the function scope itself.


Umm, no it's not. Static variables have persistence, but are scoped
just like normal variables -
http://us2.php.net/manual/en/language.variables.scope.php, about 10%
down the page, under the header "Using static variables" - "A static
variable exists only in a local function scope, but it does not lose
its value when program execution leaves this scope."

Three simple ways to fix this:

1. Declare $con as a global
2. Return $con from the initialization function, and pass it in as a
parameter to all functions that need it
3. Put all these functions into a class, and make $con a member of the
class, so it could be referenced by $this->con

>From the looks of your code, #3 is really your right answer, as it
appears you're trying to create a set of functions that are related,
and need to shared common data - you've got yourself an object...
Otherwise, if you don't want to go OOP, then go with #2, as #1 is the
most dirty way of fixing the problem. :)

HTH

-James


>
>> >  ie. When you create it (ie when you connect to
>> > MySQL) you could stick it in the global scope. ie In
>> > your connection function, make this the first
>> > statement:
>> >
>> > global $con;
>
> Yes, you could do that... but ad-hoc shoving stuff into global space is
> poor style.
>
>> > Then you can do the same in other functions, or
>> > alternatively you can access it like so:
>> >
>> > $GLOBALS['con']
>
> Not that I like the current implementation, I merely followed what he
> was aiming for, but the implementation above works fine in practice (not
> withstanding any syntax bugs I may have left since it's untested).
>
> Cheers,
> Rob.
>
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Re: Sale 79% OFF !!!

2008-08-21 Thread James Ausmus
On Thu, Aug 21, 2008 at 9:32 AM, Colin Guthrie <[EMAIL PROTECTED]> wrote:
> Bastien Koert wrote:
>>
>> I never cease to be amazed at the continuing stupidity of the human race.
>
> There is a movie called "Idiocracy" that sums up the stupidity of the human
> race quite well it's a very funny movie if you're in the right mood,
> otherwise it's. well... stupid!

It's got what programmers crave! ;)

-James

>
> Col
>
>
>
> --
>
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
>
> Day Job:
>  Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>  Mandriva Linux Contributor [http://www.mandriva.com/]
>  PulseAudio Hacker [http://www.pulseaudio.org/]
>  Trac Hacker [http://trac.edgewall.org/]
>
>
> --
> 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] newbie Q: How to say, "if the fileNAME is equal to...", or better yet, "if the fileNAME ends with '.jpg'"?

2008-08-26 Thread James Ausmus
On Tue, Aug 26, 2008 at 8:57 AM, Ford, Mike <[EMAIL PROTECTED]> wrote:
> On 25 August 2008 00:54, Govinda advised:



> Personally, I might be tempted to do something like this:
>
>   if (($pos = strrchr($file, '.'))!==FALSE):
>  switch (strtolower(substr($file, $pos))):
> case '.gif':
> case '.png':
> case '.jpg':
> case '.jpeg':
>echo $file;
>  endswitch;
>   endif;



Of course, this could be simplified *slightly* by actually taking
advantage of the loose typing of PHP - change the above if statement
to:

if (($pos = strpos($file, '.')))
{
$restOfAboveCodeHere;
}

This way, if the file is the '.' or '..' files, then you will get a 0
for the position of the '.', which will evaluate to FALSE. All other
files will return a non-zero position of the '.' char, which will
evaluate to TRUE. Also, I would believe (but have no evidence at all
of) that a forward-looking string position search will be very
slightly faster than a strrchr search - dunno for certain, and don't
care enough to code up a couple-line test, but just my gut... ;)

-James

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



Re: [PHP] newbie Q: How to say, "if the fileNAME is equal to...", or better yet, "if the fileNAME ends with '.jpg'"?

2008-08-26 Thread James Ausmus
On Tue, Aug 26, 2008 at 10:08 AM, Ford, Mike <[EMAIL PROTECTED]> wrote:
> On 26 August 2008 17:15, James Ausmus advised:
>
>> On Tue, Aug 26, 2008 at 8:57 AM, Ford, Mike
>> <[EMAIL PROTECTED]> wrote:
>>> On 25 August 2008 00:54, Govinda advised:
>>
>> 
>>
>>> Personally, I might be tempted to do something like this:
>>>
>>>   if (($pos = strrchr($file, '.'))!==FALSE):
>>>  switch (strtolower(substr($file, $pos))):
>>> case '.gif':
>>> case '.png':
>>> case '.jpg':
>>> case '.jpeg':
>>>echo $file;
>>>  endswitch;
>>>   endif;
>>
>> 
>>
>> Of course, this could be simplified *slightly* by actually taking
>> advantage of the loose typing of PHP - change the above if statement
> to:
>>
>> if (($pos = strpos($file, '.')))
>> {
>> $restOfAboveCodeHere;
>> }
>>
>> This way, if the file is the '.' or '..' files, then you will get a 0
>> for the position of the '.', which will evaluate to FALSE. All other
>> files will return a non-zero position of the '.' char, which will
>> evaluate to TRUE. Also, I would believe (but have no evidence at all
>> of) that a forward-looking string position search will be very
>> slightly faster than a strrchr search - dunno for certain, and don't
>> care enough to code up a couple-line test, but just my gut... ;)
>
> The problem with that is that a file called, say, site.logo.jpg will
> fail the subsequent tests, since the substr() on the next line will
> return '.logo.jpg'.  (And whilst it is vanishingly improbable, it is
> _just_ possible for someone to supply a file called .gif ! ;)
>

Very true - shows what a couple seconds of thought prior to full
caffeine will give you. ;)

However, it still does illustrate a concept that is important - making
PHP's loose typing work *for* you, instead of fighting against it -
many of the posts here have approximately said "DANGER! Loose typing
ahead!", which could tend to make a new PHP programmer only think of
the loose typing in a negative form - something to watch out for and
avoid. If, however, you internalize the implications of loose typing,
then you can actually make good use of it, instead of just guarding
against it like the plague. ;)

-James


> Cheers!
>
> Mike
>
>  --
> Mike Ford,  Electronic Information Developer,
> C507, Leeds Metropolitan University, Civic Quarter Campus,
> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> Email: [EMAIL PROTECTED]
> Tel: +44 113 812 4730
>
>
> To view the terms under which this email is distributed, please go to 
> http://disclaimer.leedsmet.ac.uk/email.htm
>
> --
> 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