php-general Digest 4 Jul 2010 10:32:57 -0000 Issue 6829

Topics (messages 306660 through 306669):

Re: What's wrong in this function? Does not work for me.
        306660 by: Hans Åhlin
        306661 by: Ashley Sheridan
        306662 by: Ashley Sheridan
        306664 by: Hans Åhlin
        306665 by: Ashley Sheridan

Re: how to use HTML Symbol Entities with mail() ?
        306663 by: Ashley Sheridan

Static Methods and System Resources
        306666 by: Daniel Kolbo

(null)
        306667 by: te0t3l
        306668 by: Ashley Sheridan
        306669 by: te0t3l

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
You have forgotten the ending ; in the sql query....
try this
mysql_query("INSERT INTO employes (name,lastname, salary, id, afp,
isss, nit) VALUES ('".$field[0]."',
'".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."');");

**********************************************
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**********************************************



2010/7/3 Ashley Sheridan <[email protected]>:
> On Fri, 2010-07-02 at 23:19 +0000, Carlos Sura wrote:
>
>> Hello Ash,
>>
>> No, I don't get an error message, the thing is, my post form, isn't 
>> working... I can't post those fields in database when I fill them up in the 
>> form... But, I really don't know why... Do you want my form code? all the 
>> entire class.php code??
>>
>> Thank you for helping me.
>>
>> Carlos Sura.
>>
>>
>>
>>
>>
>>
>> Subject: Re: [PHP] What's wrong in this function? Does not work for me.
>> From: [email protected]
>> To: [email protected]
>> CC: [email protected]
>> Date: Sat, 3 Jul 2010 00:08:05 +0100
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> On Fri, 2010-07-02 at 22:05 +0000, Carlos Sura wrote:
>>
>>
>> Hello, this function does not work for me... And I really don't know what am 
>> I doing wrong... Any help??
>>
>> This function is in a class, and I call it in a form, to create a new user..
>>
>>
>>
>>     $objEmploye=new Employe;
>>     if ( 
>> $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == 
>> true){
>>         echo 'Saved';
>>     }else{
>>         echo 'Error, try again';
>>     }
>> }else{
>>
>>
>>     function insert($field){
>>         if($this->con->connect()==true){
>>             return mysql_query("INSERT INTO employes (name,lastname, salary, 
>> id, afp, isss, nit) VALUES ('".$field[0]."', 
>> '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."')");
>>         }
>>     }
>>
>>
>>
>>
>> Thanks.
>>
>> _________________________________________________________________
>> http://clk.atdmt.com/UKM/go/197222280/direct/01/
>> Do you have a story that started on Hotmail? Tell us now
>>
>>
>>
>>
>> I can't see anything wrong with that code excerpt. Are you getting a 
>> specific error, and if so, what is the code on and around the line number 
>> indicated in that error?
>>
>>
>>
>>
>>
>>
>> Thanks,
>>
>> Ash
>>
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>>
>>
>>
>>
>> _________________________________________________________________
>> http://clk.atdmt.com/UKM/go/197222280/direct/01/
>> We want to hear all your funny, exciting and crazy Hotmail stories. Tell us 
>> now
>
>
> Break the code down into very simple parts with echo statements. First,
> I'd echo out the $_POST or $_GET data that you're using to see if the
> values you think are being sent are being sent. Then, move onto the next
> part of code, stepping through with echo statements to output variable
> values to ensure that your data is following the right path. This is one
> of the easiest ways to find a problem I've found, short of using an IDE
> to step through the code.
>
> Also, you could put the code up on something like pastebin and post a
> link to it, which will let people see what the code looks like and
> hopefully figure out where the problem is.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>

--- End Message ---
--- Begin Message ---
On Sat, 2010-07-03 at 09:01 +0200, Alexandre Simon wrote:

> Hello,
> 
> multiple things:
> - escape your values:
>   1. if some of the user input contains '\'' for instance, your query is
> not well formed
>   2. if some evil user want to do anything with your DB, he can do it
>   => See mysql_escape_string or PDO prepared statements
> - Use "else" part of the if statement everywhere you can to see where
> the error is. Maybe you can not connect to DB for instance...
> 
> Hope you will fix your code..
> 
> Le vendredi 02 juillet 2010 à 22:05 +0000, Carlos Sura a écrit : 
> > 
> > Hello, this function does not work for me... And I really don't know what 
> > am I doing wrong... Any help??
> > 
> > This function is in a class, and I call it in a form, to create a new user..
> > 
> > 
> > 
> >     $objEmploye=new Employe;
> >     if ( 
> > $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == 
> > true){
> >         echo 'Saved';
> >     }else{
> >         echo 'Error, try again';
> >     } 
> > }else{
> > 
> > 
> >     function insert($field){
> >         if($this->con->connect()==true){
> >             return mysql_query("INSERT INTO employes (name,lastname, 
> > salary, id, afp, isss, nit) VALUES ('".$field[0]."', 
> > '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."')");
> >         }
> >     }
> > 
> > 
> > 
> > 
> > Thanks.
> >                                       
> > _________________________________________________________________
> > http://clk.atdmt.com/UKM/go/197222280/direct/01/
> > Do you have a story that started on Hotmail? Tell us now
> 
> 
> 


As the variables aren't using the special global arrays $_POST or $_GET,
there's no indication that the values aren't being sanitised when they
go into the query.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Sat, 2010-07-03 at 09:20 +0200, Hans Åhlin wrote:

> You have forgotten the ending ; in the sql query....
> try this
> mysql_query("INSERT INTO employes (name,lastname, salary, id, afp,
> isss, nit) VALUES ('".$field[0]."',
> '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."');");
> 
> **********************************************
>  Hans Åhlin
>    Tel: +46761488019
>    icq: 275232967
>    http://www.kronan-net.com/
>    irc://irc.freenode.net:6667 - TheCoin
> **********************************************
> 
> 
> 
> 2010/7/3 Ashley Sheridan <[email protected]>:
> > On Fri, 2010-07-02 at 23:19 +0000, Carlos Sura wrote:
> >
> >> Hello Ash,
> >>
> >> No, I don't get an error message, the thing is, my post form, isn't 
> >> working... I can't post those fields in database when I fill them up in 
> >> the form... But, I really don't know why... Do you want my form code? all 
> >> the entire class.php code??
> >>
> >> Thank you for helping me.
> >>
> >> Carlos Sura.
> >>
> >>
> >>
> >>
> >>
> >>
> >> Subject: Re: [PHP] What's wrong in this function? Does not work for me.
> >> From: [email protected]
> >> To: [email protected]
> >> CC: [email protected]
> >> Date: Sat, 3 Jul 2010 00:08:05 +0100
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> On Fri, 2010-07-02 at 22:05 +0000, Carlos Sura wrote:
> >>
> >>
> >> Hello, this function does not work for me... And I really don't know what 
> >> am I doing wrong... Any help??
> >>
> >> This function is in a class, and I call it in a form, to create a new 
> >> user..
> >>
> >>
> >>
> >>     $objEmploye=new Employe;
> >>     if ( 
> >> $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) 
> >> == true){
> >>         echo 'Saved';
> >>     }else{
> >>         echo 'Error, try again';
> >>     }
> >> }else{
> >>
> >>
> >>     function insert($field){
> >>         if($this->con->connect()==true){
> >>             return mysql_query("INSERT INTO employes (name,lastname, 
> >> salary, id, afp, isss, nit) VALUES ('".$field[0]."', 
> >> '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."')");
> >>         }
> >>     }
> >>
> >>
> >>
> >>
> >> Thanks.
> >>
> >> _________________________________________________________________
> >> http://clk.atdmt.com/UKM/go/197222280/direct/01/
> >> Do you have a story that started on Hotmail? Tell us now
> >>
> >>
> >>
> >>
> >> I can't see anything wrong with that code excerpt. Are you getting a 
> >> specific error, and if so, what is the code on and around the line number 
> >> indicated in that error?
> >>
> >>
> >>
> >>
> >>
> >>
> >> Thanks,
> >>
> >> Ash
> >>
> >> http://www.ashleysheridan.co.uk
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> _________________________________________________________________
> >> http://clk.atdmt.com/UKM/go/197222280/direct/01/
> >> We want to hear all your funny, exciting and crazy Hotmail stories. Tell 
> >> us now
> >
> >
> > Break the code down into very simple parts with echo statements. First,
> > I'd echo out the $_POST or $_GET data that you're using to see if the
> > values you think are being sent are being sent. Then, move onto the next
> > part of code, stepping through with echo statements to output variable
> > values to ensure that your data is following the right path. This is one
> > of the easiest ways to find a problem I've found, short of using an IDE
> > to step through the code.
> >
> > Also, you could put the code up on something like pastebin and post a
> > link to it, which will let people see what the code looks like and
> > hopefully figure out where the problem is.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> >


Semicolons at the end of SQL statements are not required unless you are
issuing multiple SQL statements in one string.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Another thing is that I would use != false, so every value but false passes.

$objEmploye=new Employe;
   if ( $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit))
== true){
       echo 'Saved';
   }else{
       echo 'Error, try again';
   }


**********************************************
 Hans Åhlin
   Tel: +46761488019
   icq: 275232967
   http://www.kronan-net.com/
   irc://irc.freenode.net:6667 - TheCoin
**********************************************



2010/7/3 Carlos Sura <[email protected]>:
>
>
> Hello, this function does not work for me... And I really don't know what am 
> I doing wrong... Any help??
>
> This function is in a class, and I call it in a form, to create a new user..
>
>
>
>    $objEmploye=new Employe;
>    if ( 
> $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == 
> true){
>        echo 'Saved';
>    }else{
>        echo 'Error, try again';
>    }
> }else{
>
>
>    function insert($field){
>        if($this->con->connect()==true){
>            return mysql_query("INSERT INTO employes (name,lastname, salary, 
> id, afp, isss, nit) VALUES ('".$field[0]."', 
> '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."')");
>        }
>    }
>
>
>
>
> Thanks.
>
> _________________________________________________________________
> http://clk.atdmt.com/UKM/go/197222280/direct/01/
> Do you have a story that started on Hotmail? Tell us now

--- End Message ---
--- Begin Message ---
On Sat, 2010-07-03 at 16:11 +0200, Hans Åhlin wrote:

> Another thing is that I would use != false, so every value but false passes.
> 
> $objEmploye=new Employe;
>    if ( 
> $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit))
> == true){
>        echo 'Saved';
>    }else{
>        echo 'Error, try again';
>    }
> 
> 
> **********************************************
>  Hans Åhlin
>    Tel: +46761488019
>    icq: 275232967
>    http://www.kronan-net.com/
>    irc://irc.freenode.net:6667 - TheCoin
> **********************************************
> 
> 
> 
> 2010/7/3 Carlos Sura <[email protected]>:
> >
> >
> > Hello, this function does not work for me... And I really don't know what 
> > am I doing wrong... Any help??
> >
> > This function is in a class, and I call it in a form, to create a new user..
> >
> >
> >
> >    $objEmploye=new Employe;
> >    if ( 
> > $objEmploye->insert(array($name,$lastname,$salary,$dui,$afp,$isss,$nit)) == 
> > true){
> >        echo 'Saved';
> >    }else{
> >        echo 'Error, try again';
> >    }
> > }else{
> >
> >
> >    function insert($field){
> >        if($this->con->connect()==true){
> >            return mysql_query("INSERT INTO employes (name,lastname, salary, 
> > id, afp, isss, nit) VALUES ('".$field[0]."', 
> > '".$field[1]."','".$field[2]."','".$field[3]."','".$field[4]."','".$field[5]."','".$field[6]."')");
> >        }
> >    }
> >
> >
> >
> >
> > Thanks.
> >
> > _________________________________________________________________
> > http://clk.atdmt.com/UKM/go/197222280/direct/01/
> > Do you have a story that started on Hotmail? Tell us now
> 


Actually, removing the '== true' part would do that and result in
shorted code. The mysql_query() function returns different values
depending on the query made, but will only ever be one of 3 values:
true, false, or a mysql resource. In this code example, there is no
difference between '== true' and '!= false'.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On Fri, 2010-07-02 at 22:58 -0300, Manuel Lemos wrote:

> Hello,
> 
> on 07/01/2010 10:34 AM [email protected] said the following:
> > Hi List,
> > 
> > I am working on generated emails, using the mail() function.
> > Works fine, but when including characters like &#8743 (= &and;) or &#8744; 
> > (= &or;)
> > in the message, these characters are displayed as ? in the emails.
> > 
> > Snippet:
> > $headers  = 'MIME-Version: 1.0' . "\r\n";
> > $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
> > ...
> > $bool = mail ($mailto, $subject, $body, $headers);
> > 
> > also tested with:
> > $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
> > but without result.
> > 
> > Any ideas ?
> > TIA, Cor
> 
> When those characters appear as question marks is because you are using
> a font in the messages that does not have characters with those codes.
> 
> Try including the sections of those characters with some span tags like
> this <span style="font-family: font-name-here">&#8744;</span>
> 
> -- 
> 
> Regards,
> Manuel Lemos
> 
> Find and post PHP jobs
> http://www.phpclasses.org/jobs/
> 
> PHP Classes - Free ready to use OOP components written in PHP
> http://www.phpclasses.org/
> 


I don't believe it is the font issue, and don't forget that outputting
HTML for an email is very different, so there are some things that you
can specify that will be ignored by some email clients when they render
your email.

Those glyphs should be available to any system, as the email client
should use whatever font on the system is set up for the extended glyphs
where they are not available in the current font. What email clients are
you testing this on? Are they web based, or local? It's a good idea to
test HTML emails on a variety of email clients, as they all can behave
very differently.

Thanks,
Ash
http://www.ashleysheridan.co.uk



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

Does PHP 'reinclude' static methods with each new instantiation of a
class that has static methods?

That is, if i have 100 objects is the static method sitting in memory 1
time or 100 times?

Thanks,
dK
`

--- End Message ---
--- Begin Message ---
Hi, I have a photo gallery and I update it with a XML file like this:

$NuevaCol = new SimpleXMLElement("../xml/" . $coleccionXML . '.xml', null,
true);
$first = $NuevaCol->addChild('coleccion');
$attsNuevaCol = $first->addAttribute('nombre_col',
utf8_encode($titNuevaColEspacios));
$attsNuevaCol = $first->addAttribute('archivo', utf8_encode($uploadDir .
$nombreMiniatura));
$NuevaCol->asXML("../xml/" . $coleccionXML . '.xml');


Now I try to include the new Child at the begining of the document because I
want that the last update will be show the first in the gallery, do me
explain?
How can I do it?,

Thanks in advance,

te0

--- End Message ---
--- Begin Message ---
On Sat, 2010-07-03 at 18:58 +0100, te0t3l wrote:

> Hi, I have a photo gallery and I update it with a XML file like this:
> 
> $NuevaCol = new SimpleXMLElement("../xml/" . $coleccionXML . '.xml', null,
> true);
> $first = $NuevaCol->addChild('coleccion');
> $attsNuevaCol = $first->addAttribute('nombre_col',
> utf8_encode($titNuevaColEspacios));
> $attsNuevaCol = $first->addAttribute('archivo', utf8_encode($uploadDir .
> $nombreMiniatura));
> $NuevaCol->asXML("../xml/" . $coleccionXML . '.xml');
> 
> 
> Now I try to include the new Child at the begining of the document because I
> want that the last update will be show the first in the gallery, do me
> explain?
> How can I do it?,
> 
> Thanks in advance,
> 
> te0

First, please use a subject, as a lot of email clients can only thread
emails by the subject, and it helps the archives too.

What I believe you're looking for is the insertBefore() method, which
you can use to add an element before an existing one in the DOM. You're
already reading in the DOM from the xml file, so you just need to find
the first <coleccion> element and use insertBefore() add the new one
before it, then output the whole DOM again into the xml file.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
Thanks Ash, and so sorry I forgot to use the subject...

ok, I'll read about insertBefore () method,

Regards,

te0

--- End Message ---

Reply via email to