php-general Digest 4 Jul 2009 05:15:00 -0000 Issue 6210
Topics (messages 294868 through 294874):
Re: Writing to a file
294868 by: Shawn McKenzie
294870 by: Jason Carson
is there a way to get more info about *why* the initial (DB PEAR) connect to db
is failing?
294869 by: Govinda
294873 by: Phpster
Browser Alert
294871 by: tedd
Re: php get rss tag using DOM
294872 by: Rodgerr
294874 by: Michael A. Peters
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 ---
Jason Carson wrote:
> Hello everybody,
>
> How would I go about writing stuff to a file but in between the <?php ?>
> tags?
>
> Example, say I have config.php as follows...
>
> <?php
>
> $hostname = "localhost";
> $database = "database";
> $username = "username";
> $password = "password";
>
> ?>
>
> How would I go about adding stuff at the end of the file, but before the
> ?> tag?
>
The way I've done this in the past is to use an array. Then I can
include the file, change the array and then var_export() to the file:
//config.php
<?php
$config = array (
'hostname' => 'localhost',
'database' => 'database',
'username' => 'username',
'password' => 'password',
);
//file that does the changing writing
<?php
include('config.php');
$config['database'] = 'otherdb';
$config['username'] = 'jason';
$config['password'] = 'abcdefg123';
$content = "<?php\n".'$config = '.var_export($config, true).";\n?>";
file_put_contents('config.php', $content);
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
> On Fri, Jul 3, 2009 at 06:01, Jason Carson<[email protected]> wrote:
>> Hello everybody,
>>
>> How would I go about writing stuff to a file but in between the <?php ?>
>> tags?
>
> The current industry standard is a combination of text editor and
> keyboard, but there are many options.
>
> More specifically, are you trying to write to a PHP file *with*
> PHP? And if so, would this be the kind of file you're trying to write
> (such as creating an automated installer with auto-config)?
>
> --
> </Daniel P. Brown>
> [email protected] || [email protected]
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our great hosting and dedicated server deals at
> http://twitter.com/pilotpig
>
Yes, I am trying to write stuff to a file with PHP but in between the
<?php ?> tags and without deleting what is already in the file.
--- End Message ---
--- Begin Message ---
my code:
require 'DB.php';
// $db=DB::connect('db_program://user:passw...@hostname/database');
$db=DB::connect('mysql://metheuser:[email protected]/
mydatabase');
if (DB::isError($db)) { die("Can't connect: " . $db->getMessage()); }
is returning:
"Can't connect: DB Error: connect failed"
Any advise to find out WHY this is failing?
(Note: I am fairly new to PHP, and brand spanking new at anything db-
related with PHP.)
thanks, Govinda
--
P.S.
I realize this had probably been covered countless times (best step by
step advice how to troubleshoot the first connection to a mysql db),
so i first did try to search the php list archives, here:
http://marc.info/?l=php-general&w=2&r=1&s=db+connect&q=b
and I am apparently missing something because when I input
"failed db connection"
at the top, in the search box, then it returns posts all over the map,
and also takes out the middle word in my search string (so now it is
just "failed db"). Why is that?
I also searched for "failed database connection" which does not change
my search input, but still the posts I found did not give me enough
clue to stop me from posting here now.
--- End Message ---
--- Begin Message ---
On Jul 3, 2009, at 7:31 PM, Govinda <[email protected]>
wrote:
my code:
require 'DB.php';
// $db=DB::connect('db_program://user:passw...@hostname/database');
if (DB::isError($db)) { die("Can't connect: " . $db->getMessage
()); }
is returning:
"Can't connect: DB Error: connect failed"
Any advise to find out WHY this is failing?
(Note: I am fairly new to PHP, and brand spanking new at anything db-
related with PHP.)
thanks, Govinda
--
P.S.
I realize this had probably been covered countless times (best step
by step advice how to troubleshoot the first connection to a mysql
db), so i first did try to search the php list archives, here:
http://marc.info/?l=php-general&w=2&r=1&s=db+connect&q=b
and I am apparently missing something because when I input
"failed db connection"
at the top, in the search box, then it returns posts all over the
map, and also takes out the middle word in my search string (so now
it is just "failed db"). Why is that?
I also searched for "failed database connection" which does not
change my search input, but still the posts I found did not give me
enough clue to stop me from posting here now.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
It's usually a simple thing since there are only 3 parameters so it's
something that you have likely mis-spelled or input in the wrong order.
It's not rocket science to figure it out, the docs are clear about how
it works.
But a likely guess maybe that you need to connect via localhost
instead of the full domain name.
$db=DB::connect('mysql://metheuser:myp...@localhost/mydatabase');
Bastien
Sent from my iPod
--- End Message ---
--- Begin Message ---
Hi gang:
I just wasted a day trying to figure out why a standard html form
using enctype='multipart/form-data" wasn't uploading images as it
should in Safari.
Sometimes it would work and sometimes it wouldn't. Sometimes I would
get the spinning "loading X" of death in the address-bar and
sometimes it would simply work and upload. No changes in code, just
it works sometimes and it doesn't other times.
This really had me stumped. Then I tried other browsers, such as
FireFox and Opera and they worked every time. This is a Safari
problem.
So, if you're having problems with Safari 4.0 on Mac OSX uploading
files, you're not alone.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Morris-25 wrote:
>
> Hi,
>
> I am trying to write a programme to read a rss xml file.
>
> ...
> <media:content url="*exampe.jpg*" ...>
> ...
>
> scan anyone tell me how to get the url attribute? I wrote some codes
> similar:
>
>
> $doc = new DOMDocument;
> $doc->load($myFlickrRss);
>
> $r = $doc->getElementsByTagName('media:content');
> for($i=0;$i<=$r->length;$i++) {
>
> // help here
>
> }
>
>
Hi. Our site http://rssphp.blogspot.net http://rssphp.blogspot.net is
working on providing possible solutions to the problem with different
parsing methods in PHP. It's worth to have a look at the options.
--
View this message in context:
http://www.nabble.com/php-get-rss-tag-using-DOM-tp21901033p24330531.html
Sent from the PHP - General mailing list archive at Nabble.com.
--- End Message ---
--- Begin Message ---
Rodgerr wrote:
Morris-25 wrote:
Hi,
I am trying to write a programme to read a rss xml file.
...
<media:content url="*exampe.jpg*" ...>
...
scan anyone tell me how to get the url attribute? I wrote some codes
similar:
$doc = new DOMDocument;
$doc->load($myFlickrRss);
$r = $doc->getElementsByTagName('media:content');
for($i=0;$i<=$r->length;$i++) {
$node = $r->item($i);
if ($node->hasAttribute('url') {
$url[] = $node->>getAttribute('url');
}
}
That should give you an array called $url of all the url attributes in
the nodes.
--- End Message ---