php-general Digest 26 Oct 2009 14:39:55 -0000 Issue 6411
Topics (messages 299333 through 299343):
Re: getcsv error
299333 by: Steve
299338 by: John Black
Issues with MySQL connectivity ... on only one machine, and for a while now
299334 by: Michael Shadle
299335 by: Kim Madsen
299336 by: Michael Shadle
299339 by: John Black
Re: RewriteRule to hide PHP vars in URL
299337 by: Ashley Sheridan
Re: php mail() function
299340 by: Bob McConnell
299341 by: John Black
dynamic menu with show hide capabilities - understanding possible workflow
299342 by: MEM
299343 by: Ashley Sheridan
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Brian Hazelton wrote:
Brian Hazelton wrote:
Brian Hazelton wrote:
I have a script which uploads csv data into a database. This works
well and has worked in every instance so far. However what I am
noticing is that today, even if I escape the data before putting it
into mysql it will not enter a line if it has a single quote, once I
take out the single quote it enters it into the database so I know
it is the single quote, is this an error or are single quotes not
allowed in csv...?
I figured out part of the problem. The problem lies with one of my
functions for cleaning the data before putting it into the database.
I have a function, see below, that will clean the data to put into
mysql and work whether magic quotes is on or off. It is not working
because I echo the query and the part I need escaped is not being
escaped. I try mysql_real_escape_string and it is being escaped by
that so I think the problem is something with my function, if anyone
can help that would be appreciated.
function clean($str){
if(get_magic_quotes_gpc()){
stripslashes($str);
mysql_real_escape_string($str);
return $str;
}
else{
mysql_real_escape_string($str);
return $str;
}
}
$name = 'O'Leksy';
$cleaned_name = clean($name);
echo of $cleaned name = O'Leksy';
if mysql_real_escape_string is used it echoes O\'Leksy';
Sorry for all of the posts. I got it figured out, it was just me being
stupid. Since this data isnt coming from get, post or cookies then
calling this function will still work but no slashes are getting added
so when the stripslashes function is called it returns an error and
will not continue to work because it does not return the string on error.
You'll need to assign the results of stripslashes and
mysql_real_escape_string to $str, otherwise your function will have no
effect and just return the original string.
function clean($str){
if(get_magic_quotes_gpc()){
$str = stripslashes($str);
$str = mysql_real_escape_string($str);
return $str;
}
else{
$str = mysql_real_escape_string($str);
return $str;
}
}
--- End Message ---
--- Begin Message ---
Looks like Steve posted the answer so here is something related.
I use the function below to deal with those annoying magic quotes setups.
The function will remove the magically annoying quotes from the POST,
GET, COOKIE and REQUEST arrays. Simply save it to a file and include it
on top of your pages.
<?php
//This is here to deal with MagicQuotes source:
//http://usphp.com/manual/en/security.magicquotes.disabling.php
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
?>
--
John
There's room at the top they are telling you still,
But first you must learn how to smile as you kill,
If you want to be like the folks on the hill...
[John Lennon]
--- End Message ---
--- Begin Message ---
Oct 25 22:00:01 sql02 php: PHP Warning: mysqli_connect():
(HY000/2013): Lost connection to MySQL server at 'sending
authentication information', system error: 32 in
/home/foo/web/foo.com/core.php on line 2394
It's either this or one or two others. What is odd is I have switched
to making it sockets only - doesn't seem to help. I think it was
anyway, it's all over localhost. It wasn't always like this either.
Can't seem to find any reason for it. Scripts are able to connect at
near lightning speed, do 20+ queries a page load and disconnect
without an issue before it even shows up in a "show processlist" but
I'm seeing issues with disconnections on localhost.
I wanted to upgrade to PHP 5.3.x to use the mysqli.reconnect option,
but I don't think the code will work 100% - does anyone else have any
ideas? I have a second server, same specs, being beaten (not as hard,
but decently) that exhibits none of these behaviors.
mysql 5.0.75 on ubuntu jaunty 64-bit
php 5.2.11 (but has been showing this issue since 5.2.9 if not
earlier, I didn't start tracking it then)
I don't understand why it would be having issues during the
authentication phase especially over localhost or socket!?! I think
this might be more of a question for the PHP community than the MySQL
one; I've tried some additional MySQL tuning and it doesn't seem to
help, and the error comes from PHP, I can't reproduce it any other
way.
Any ideas?
Thanks!
--- End Message ---
--- Begin Message ---
Michael Shadle wrote on 2009-10-26 06:48:
Oct 25 22:00:01 sql02 php: PHP Warning: mysqli_connect():
(HY000/2013): Lost connection to MySQL server at 'sending
authentication information', system error: 32 in
/home/foo/web/foo.com/core.php on line 2394
It's either this or one or two others. What is odd is I have switched
to making it sockets only - doesn't seem to help. I think it was
anyway, it's all over localhost. It wasn't always like this either.
I think it's related to network flaws, at least that was the
understanding I had from the same problem, which occured some months ago
at an ISP i'm using, but you're writing "all over localhost"?
--
Kind regards
Kim Emax - masterminds.dk
--- End Message ---
--- Begin Message ---
Yep the only connectivity issues are coming from the server itself.
I have 3 webservers talking to this server and never get a failed read
- the batch jobs running on the server itself have issues once in a
while. I even FORCED sockets just in case it was using TCP via
localhost...
On Mon, Oct 26, 2009 at 12:24 AM, Kim Madsen <php....@emax.dk> wrote:
> Michael Shadle wrote on 2009-10-26 06:48:
>>
>> Oct 25 22:00:01 sql02 php: PHP Warning: mysqli_connect():
>> (HY000/2013): Lost connection to MySQL server at 'sending
>> authentication information', system error: 32 in
>> /home/foo/web/foo.com/core.php on line 2394
>>
>> It's either this or one or two others. What is odd is I have switched
>> to making it sockets only - doesn't seem to help. I think it was
>> anyway, it's all over localhost. It wasn't always like this either.
>
> I think it's related to network flaws, at least that was the understanding I
> had from the same problem, which occured some months ago at an ISP i'm
> using, but you're writing "all over localhost"?
>
> --
> Kind regards
> Kim Emax - masterminds.dk
>
--- End Message ---
--- Begin Message ---
Michael Shadle wrote:
Oct 25 22:00:01 sql02 php: PHP Warning: mysqli_connect():
(HY000/2013): Lost connection to MySQL server at 'sending
authentication information', system error: 32 in
/home/foo/web/foo.com/core.php on line 2394
mysql 5.0.75 on ubuntu jaunty 64-bit
php 5.2.11 (but has been showing this issue since 5.2.9 if not
earlier, I didn't start tracking it then)
Is this a VPS (virtual private server)?
Reason I am asking is because some VPS implementations only give you RAM
but no SWAP space. So once all RAM is consumed processes will get aborted.
--
John
Klarmachen zum Ändern!
Piratenpartei Deutschland
http://www.youtube.com/v/-u3IUno5A-M
--- End Message ---
--- Begin Message ---
On Mon, 2009-10-26 at 07:46 +0530, kranthi wrote:
> <base will just complicate things... (its sure to solve your problems but
> you have to type the relative path to your document root for every URI)
>
> seems you are looking for
> http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#RewriteCond
I don't think that will do what he wants. Consider the following two
examples:
http://www.example.com/docs/somedoc
http://www.example.com/
Now imagine there was a rewrite rule set up to take these URLs and
convert them into the following server-side:
http://www.example.com/index.php?doc=somedoc
http://www.example.com/index.php
The same index.php page is being used to serve up all the content, but
to the browser, one 'page' is located in the document root, the other
in /docs. Any relative URL's in the pages to images, CSS, Javascript,
etc will be treated as relative to where the browser thinks the page is,
not where the server does. Therefore, you either have to use the <base>
tag or make all the URL's absolute. The <base> tag method allows for
more flexibilty in the future, for example if you changed domain name
slightly.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
From: James Prentice
> I have tried setting both $to and $email to be the same shaw address
> since I assumed it should be recognized by the mail server, but it's
> still getting bounced. So why is 'www-d...@homemade' being listed as
> the sender? Any ideas?
I strongly recommend you call the help desk at Shaw and ask them to
explain what is happening. They should know what is going on with their
servers. Everyone on this list appears to be guessing at the problem,
which is not likely to help you.
Bob McConnell
--- End Message ---
--- Begin Message ---
Bob McConnell wrote:
I strongly recommend you call the help desk at Shaw and ask them to
explain what is happening. They should know what is going on with their
servers. Everyone on this list appears to be guessing at the problem,
which is not likely to help you.
But they are educated guesses :)
No seriously, without a definitive error message it is hard to say for sure.
Since he only needs postfix on the server to allow php to email out I
may have a different solution for him.
I sent him my custom smtp_email function which talks to the ISPs SMTP
server directly and supports authentication.
Lets see if that help.
--
John
Nur wer im Wohlstand lebt, schimpft auf ihn.
[Ludwig Marcuse]
--- End Message ---
--- Begin Message ---
Hello all,
I'm on my way to build my first dynamic menu using php.
However, each time I say this, people start jumping at me crying out loud:
"Jquery" .
I don't need js for this. Really. (At least, this is what I believe).
So I was wondering if It's possible to accomplish it, by using css and php
only.
If so, I'm wondering if something like this it's a good way for doing this:
1)
Generate a multidimensional array from database table containing categories
and subcategories.
2)
Create a css file with two classes one that shows, another that hides.
3)
Grab that array and:
3.1) print it recursively (no idea how to accomplish this)
3.2) print it with some sort of class="showThis" inside the generated html
element.
3.3) make a conditional somewhere (I really don't know where, and this may
be related with the recursion doubt), in order to display the children
elements, only when we click the parent element.
And here resides my main doubt: Is the point 3.3 feasible without the use of
js?
I just need some directions please,
Regards,
Márcio
--- End Message ---
--- Begin Message ---
On Mon, 2009-10-26 at 13:28 +0000, MEM wrote:
> Hello all,
>
> I'm on my way to build my first dynamic menu using php.
> However, each time I say this, people start jumping at me crying out loud:
> "Jquery" .
> I don't need js for this. Really. (At least, this is what I believe).
>
> So I was wondering if It's possible to accomplish it, by using css and php
> only.
>
>
> If so, I'm wondering if something like this it's a good way for doing this:
>
> 1)
> Generate a multidimensional array from database table containing categories
> and subcategories.
>
> 2)
> Create a css file with two classes one that shows, another that hides.
>
> 3)
> Grab that array and:
> 3.1) print it recursively (no idea how to accomplish this)
> 3.2) print it with some sort of class="showThis" inside the generated html
> element.
> 3.3) make a conditional somewhere (I really don't know where, and this may
> be related with the recursion doubt), in order to display the children
> elements, only when we click the parent element.
>
> And here resides my main doubt: Is the point 3.3 feasible without the use of
> js?
>
>
>
> I just need some directions please,
>
> Regards,
> Márcio
>
>
>
Everything there is feasible without Javascript except for the clicking
part, which is pretty essential to what you want. Pure CSS-only menus
are still unavailable because of IE, so using some Javascript is your
only option really.
Is there a particular reason you are shying away from Javascript in this
case? There are ways you can construct drop-down menus in a way that if
Javascript is unavailable, then they fall back to becoming a
bog-standard navigation bar.
Also, before anyone mentions them, <select> lists are not the same thing
as a drop-down menu, and navigating to different parts of a document
upon changing the selected option is actually breaking their default
behavior, and can become confusing to people who expect them to work as
select lists.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---