php-general Digest 19 Oct 2010 12:00:35 -0000 Issue 6995

Topics (messages 308810 through 308824):

Re: work online
        308810 by: Enrico Weigelt

Re: Formatting an ECHO statement.
        308811 by: admin.buskirkgraphics.com
        308814 by: Cris S
        308815 by: Cris S
        308819 by: Paul M Foster
        308820 by: Shreyas Agasthya
        308821 by: a...@ashleysheridan.co.uk

Re: [PDO] Re: [PHP] PDO working via Apache but not at the command line?
        308812 by: Wez Furlong
        308813 by: Scott Baker
        308818 by: Stanley Sufficool

require_once
        308816 by: jim
        308817 by: 惠新宸

Re: Questions from a Newbie
        308822 by: Ethan Rosenberg

Re: mytr...@mail.us auto responder
        308823 by: Gary

Sessions only work in SSL
        308824 by: Daniel Houle

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 ---
* Jordan Jovanov <jovanovj...@gmail.com> wrote:

Hi,

> Does somebody know company for PHP programing where people can
> work from home? Actual I only want to know does have regular or
> part time job for PHP developers who work from home via internet.

I'm not just php programmer (more software architect and 
systems integrator). Pure sw-development projects are mostly
remote, integration often onsite.


cu
-- 
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 phone:  +49 36207 519931  email: weig...@metux.de
 mobile: +49 151 27565287  icq:   210169427         skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------

--- End Message ---
--- Begin Message ---
I ask as you look at the comments and replies to your post, you think long
term. 
Today you want the italic option, tomorrow you want to change the display to
something else.  Now you have to go back and change ever place you set the
italic symbols to make your change. 

BUT if you use styles you can not only change the display to the desired
look in one location but you can have flexibility.

Example:

Let's say the comments are coming from a database and you want to display
the comment differently based on the contents of the comment.

In my example I have 3 different classes in the style. Now as I foreach over
the fake data array example, I simply pick the style to use based on each
matching criteria. While the static examples

<style>
#wever_comment{font-style:italic}
#good_comment{font-style:italic; color: green;}
#bad_comment{font-weight:bold; color: red;}
</style>

$variable_from_database = array('good','bad','whatever');
Foreach($variable as $key)
{
        Echo 'Other Comments:';
        If(preg_match("/bad/i",'$key')){Echo '<div
class=bad_comment>$key</div>';}
        If(preg_match("/good/i",'$key')){Echo '<div
class=good_comment>$key</div>';}        
        If(preg_match("/whatever/i",'$key')){Echo '<div
class=wever_comment>$key</div>';}
        Echo '<br/>';
}

In the long term the flexibility allows you to make faster changes with a
higher degree, of what I like to call "smarter code". Yes the filters are
static, and I would not use static filters personally. It is meant as an
explanation, not a how to.











-----Original Message-----
From: Shreyas Agasthya [mailto:shreya...@gmail.com] 
Sent: Monday, October 18, 2010 6:10 AM
To: PHP General List
Subject: [PHP] Formatting an ECHO statement.

Team,

A bit of silly one but like my book says, there are no dumb questions, I am
asking it here.

If I have :

$other="Whatever";

and I do:

echo 'Other Comments:' .$other. '<br/>

works perfectly well and prints the value. What if I want to, now, italicize
the value of $other with the above syntax? How do I achieve it?

I know we can do it this way : echo " I am <i>$other</i>"; but I want to
learn how to do it with the above syntax like I mentioned earlier.

Regards,
Shreyas Agasthya


--- End Message ---
--- Begin Message ---
At 13:03 18 10 10, a...@ashleysheridan.co.uk wrote:
There's nothing wrong with using <em> as it indicates emphasised text, which is semantic. Use span tags with classes only when the content you're styling has no semantic alternative. <strong>important message</strong> is much better for machines (including search engines, screen readers, etc) to infer a meaning for than <span class="bold_text">important message</span> Thanks, Ash http://www.ashleysheridan.co.uk ----- Reply message ----- From: "tedd" <tedd.sperl...@gmail.com> Date: Mon, Oct 18, 2010 17:51 Subject: [PHP] Formatting an ECHO statement. To: <php-gene...@lists.php.net> At 9:47 AM -0400 10/18/10, Steve Staples wrote: >or create a style sheet, with a class definition for italic. > >Steve. +1 The "best practices" way to do it. Don't style output in an echo statement, but rather put styling in a css sheet, It's much cleaner there. Cheers, tedd -- ------- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


Jesus H. Christ.

I'm on this list because I want to learn PHP, not how to parse
HTML mail or how to add italics to dolt<stupid text>/dolt.

You add styles to text as a presentation effect. This list is
not supposed to be about the effing presentation.

Must I say it again, more rudely even? I know you guys like
to go on and on, but give it a rest on this one. Get your
asses back on topic - and on topical jokes. This topic is
neither.

Move on already.




--- End Message ---
--- Begin Message ---
At 15:12 18 10 10, Shreyas Agasthya wrote:
Thanks all for their input. Some of the learnings  from the thread :

1. <i> tag is getting deprecated.

Not in HTML5.

2. Use <em> and <strong>

Both? Read that shit again, buckwheat. And by "that shit" I
do mean the standards, not what Joe Bloe told you.

3. Have CSS used to do the kind of stuff I was trying.

Uhm, yeah. @@

 I must inform, this was already in place.

Then why the fuck are we discussing this?

4. Keep an eye on the SE monster.

and on the "go fuck yourself" monster too.

Holy fuck, I've been lurking for months. I turn away for
one day and this is the non-PHP crap that happens?

Someone needs to hire me now, to keep me busy and stop me
from taking this issue apart one piece at a time. Kee-rist.



--- End Message ---
--- Begin Message ---
On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:

> At 15:12 18 10 10, Shreyas Agasthya wrote:
> >Thanks all for their input. Some of the learnings  from the thread :
> >
> >1. <i> tag is getting deprecated.
> 
> Not in HTML5.
> 
> >2. Use <em> and <strong>
> 
> Both? Read that shit again, buckwheat. And by "that shit" I
> do mean the standards, not what Joe Bloe told you.
> 
> >3. Have CSS used to do the kind of stuff I was trying.
> 
> Uhm, yeah. @@
> 
> > I must inform, this was already in place.
> 
> Then why the fuck are we discussing this?
> 
> >4. Keep an eye on the SE monster.
> 
> and on the "go fuck yourself" monster too.
> 
> Holy fuck, I've been lurking for months. I turn away for
> one day and this is the non-PHP crap that happens?

Please go back to lurking. We'd all appreciate it, and you'll be
happier.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Thanks for that detailed mail, Admin. The <i> was an example and I wanted to
understand how does one go about the whole formatting. Nonetheless, I am
pretty well informed after this thread.

Thanks once again, everyone.

Regards,
Shreyas

On Tue, Oct 19, 2010 at 10:09 AM, Paul M Foster <pa...@quillandmouse.com>wrote:

> On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:
>
> > At 15:12 18 10 10, Shreyas Agasthya wrote:
> > >Thanks all for their input. Some of the learnings  from the thread :
> > >
> > >1. <i> tag is getting deprecated.
> >
> > Not in HTML5.
> >
> > >2. Use <em> and <strong>
> >
> > Both? Read that shit again, buckwheat. And by "that shit" I
> > do mean the standards, not what Joe Bloe told you.
> >
> > >3. Have CSS used to do the kind of stuff I was trying.
> >
> > Uhm, yeah. @@
> >
> > > I must inform, this was already in place.
> >
> > Then why the fuck are we discussing this?
> >
> > >4. Keep an eye on the SE monster.
> >
> > and on the "go fuck yourself" monster too.
> >
> > Holy fuck, I've been lurking for months. I turn away for
> > one day and this is the non-PHP crap that happens?
>
> Please go back to lurking. We'd all appreciate it, and you'll be
> happier.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya

--- End Message ---
--- Begin Message ---
Steady on now, this thread started as a php question, and has only deviated a 
little. Most people on the list don't work purely with php, and I for one dont 
mind the odd off-topic thread, especially when the majority of the list is made 
of good php threads.

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

----- Reply message -----
From: "Cris S" <ssski...@gmail.com>
Date: Tue, Oct 19, 2010 03:46
Subject: [PHP] Formatting an ECHO statement.
To: <php-gene...@lists.php.net>

At 15:12 18 10 10, Shreyas Agasthya wrote:
>Thanks all for their input. Some of the learnings  from the thread :
>
>1. <i> tag is getting deprecated.

Not in HTML5.

>2. Use <em> and <strong>

Both? Read that shit again, buckwheat. And by "that shit" I
do mean the standards, not what Joe Bloe told you.

>3. Have CSS used to do the kind of stuff I was trying.

Uhm, yeah. @@

>  I must inform, this was already in place.

Then why the fuck are we discussing this?

>4. Keep an eye on the SE monster.

and on the "go fuck yourself" monster too.

Holy fuck, I've been lurking for months. I turn away for
one day and this is the non-PHP crap that happens?

Someone needs to hire me now, to keep me busy and stop me
from taking this issue apart one piece at a time. Kee-rist.



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


--- End Message ---
--- Begin Message ---
Things to check:

- Environment: what env vars are set or not set in your Apache vs. CLI
- Owner: are you running as the same user as your web server?
- Do you or the web server have some kind of "rc" file that might impact how things run?

Suggestion:

Use "sudo -u webserverusername -s" to run a shell as your web server user, then try to run the CLI.

Get the environment to match up with your webserver.

If this still doesn't work, it might be something more esoteric; check to see if you have other apache modules loaded that might also use FreeTDS or ODBC and that might be messing with things.

Use "strace php db-dump.php" to see what the CLI is up to.
Use "strace -p <apachepid>" to see what the Apache version is up to (probably want to run apache -X to make this easier).

--Wez.

On Oct 18, 2010, at 5:26 PM, Scott Baker wrote:

On 10/18/2010 02:17 PM, a...@ashleysheridan.co.uk wrote:
It's most likely because both cli and web modules are using different
php.ini config files. See what the output of a phpinfo() call in both
browser and command line.

I didn't even think about it parsing different php.ini files. Checking the output of phpinfo() I see it's calling the same php.ini (/usr/local/lib/php.ini) though. :(


--- End Message ---
--- Begin Message ---
On 10/18/2010 06:27 PM, Wez Furlong wrote:
> Things to check:
> 
> - Environment: what env vars are set or not set in your Apache vs. CLI
> - Owner: are you running as the same user as your web server?
> - Do you or the web server have some kind of "rc" file that might impact
> how things run?

Wez you're a genius. When I ran it as the same user as apache it works
fine. That got me thinking that it makes a log in /tmp. Checking the log
it was only writable by the apache user. A little chmod later and now my
script runs perfectly under apache and cli.

Thanks for helping me think outside the box. I spent all day puzzled by
this, you just made my night.

- Scott

--- End Message ---
--- Begin Message ---
Sounds like the error message "SQLSTATE[HY000] Unable to connect:
Adaptive Server is unavailable or does not exist (severity 9)" could
be more informative, but I think this is returned by FreeTDS, not PDO.

On Mon, Oct 18, 2010 at 7:35 PM, Scott Baker <bak...@canbytel.com> wrote:
> On 10/18/2010 06:27 PM, Wez Furlong wrote:
>> Things to check:
>>
>> - Environment: what env vars are set or not set in your Apache vs. CLI
>> - Owner: are you running as the same user as your web server?
>> - Do you or the web server have some kind of "rc" file that might impact
>> how things run?
>
> Wez you're a genius. When I ran it as the same user as apache it works
> fine. That got me thinking that it makes a log in /tmp. Checking the log
> it was only writable by the apache user. A little chmod later and now my
> script runs perfectly under apache and cli.
>
> Thanks for helping me think outside the box. I spent all day puzzled by
> this, you just made my night.
>
> - Scott
>
> --
> PDO Working Group Mailing List (http://pdo.php.net)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message --- I'm having a problem including files using Zend Framework. I have in a controller file this

require_once "models/Member.php"; and it doesn't work ,nor does

require_once "../models/Member.php";

Anyone know what's going on with this?

Jim W.



--- End Message ---
--- Begin Message ---

hi:

print_r(get_include_path());

thanks;

Best regards

惠新宸     Xinchen Hui
http://www.laruence.com/

On 10/19/2010 10:46, jim wrote:
   I'm having a problem including files using Zend Framework. I have in a
controller file this

require_once "models/Member.php"; and it doesn't work ,nor does

require_once "../models/Member.php";

Anyone know what's going on with this?

Jim W.



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



--- End Message ---
--- Begin Message ---
Tamara -

Thanks.

No error_log.

This works ...

<html><body>
<?php phpinfo(); ?>
</body></html>

Ethan
++++++++++
At 02:23 AM 10/19/2010, Tamara Temple wrote:
On Oct 18, 2010, at 11:01 PM, Ethan Rosenberg wrote:


I've added the code you suggest, and I still get a blank screen.
Should I be explicitly be using mysqli functions; eg mysqli_connect?
Odd you should still get a blank screen and nothing in the error_log...

Does phpinfo() work?

Ethan
++++++++
At 11:00 PM 10/18/2010, you wrote:
Where do you set $host, $user and $password?

You should add the following after the new mysqli statement:

if ($mysqli->connect_error) {
   die('Connect Error (' . $mysqli->connect_errno . ') '
           . $mysqli->connect_error);
}

Tamara Temple
-- aka tamouse__
<mailto:tam...@tamaratemple.com>tam...@tamaratemple.com


"May you never see a stranger's face in the mirror."

On Oct 18, 2010, at 4:09 PM, Ethan Rosenberg wrote:

At 05:37 PM 10/17/2010, Tamara Temple wrote:
gah, i botched that up.

For the first part, you want the following:

       $cxn = new mysql($host, $user, $password);
       $res = $cxn->query("create database test22:);
       if (!$res) {
die("Failed to create database test22: " . $cxn- >error());
       }

Then, reopen the connection with the new data base:

       $cxn = new mysql($host, $user, $password, "test22");

Then the following code will work.


Tamara Temple
       -- aka tamouse__
<mailto:tam...@tamaratemple.com>tam...@tamaratemple.com


"May you never see a stranger's face in the mirror."

On Oct 17, 2010, at 4:26 PM, Tamara Temple wrote:


On Oct 17, 2010, at 1:22 PM, Ethan Rosenberg wrote:
At 01:41 AM 10/17/2010, Tommy Pham wrote:
> I cannot get the following to work.  In my Firefox [Iceweasel]
browser, I
> enter the following URL: [w/ the http]

Whenever you get a blank screen running a php application, the
place
to look is the http server's error_log. This is frequently found
in / var/log/httpd/error_log or /var/log/apache2/error_log. (If
your
system is hosted someplace else, it could very easily be in a
different place). Typically you need root permission to read this
file. Tail the file after you run your PHP script to see the most
recent errors.

> The code  contained in the file CreateNew.php is:
>
> /*
>   *  Create Database test22
>   */
>   <html><body>
> <?php
> $cxn = mysqli_connect("$host",$user,$password);

Better to use the OO approach:

       $cxn = new mysqli($host, $user, $password);

> echo    "Create database test22;"

Instead of echo statements (which would just echo the contents to
the output, i.e., your browser, you want to assign them to a
variable, such as:

  $sql = "create database test22; use test22";

Then you need to execute the sql statement:

       $res = $cxn->query($sql);
       if (!$res) {
die("Could not create database test22: " . $cxn- >error());
       }

> echo    "Create table Names2

       $sql = "create table Names2

> (
>          RecordNum Int(11) Primary Key Not null default=10000
auto_increment,
>          FirstName varchar(10),
>          LastName varchar(10),
>          Height  decimal(4,1),
>          Weight0 decimal(4,1),
>          BMI decimal(3,1)
>          Date0 date
> );"

     ; // to close off the php statement
       $res = $cxn->query($sql);
       if (!$res) {
               die("Could not create table Names2: " . $cxn- >error());
       }

>
> echo"   Create table Visit2

       $sql = "create table Visit2

> (
>          Indx Int(7) Primary Key Not null auto_increment,
>          Weight decimal(4,1) not null,
>          StudyDate date not null,
>          RecordNum Int(11)
> );"

       ; // again, to close off the php statement
       $res = $cxn->query($sql);
       if (!$res) {
               die("Could not create table Visit2: " . $cxn- >error());
       }

>
>          $sql= "SHOW DATABASES";

This doesn't work in a programmatic setting.

Terminate the database connection:

       $cxn->close();

> ?>
> </body></html>

> I would also like to be able to add data to a table, using
PHP,
which I
can do
> in MySQL as:
> load data infile '/home/ethan/Databases/tester21.dat.' replace
into table
> Names fields escaped by '\\' terminated by '\t'  lines
terminated by '\n'
;

That's a specific feature of the mysql program. You'd have to
write
something in php to be able to parse the file and insert the data.
There are examples all over the net. Then you would need to set up
sql insert or replace statements to actually get the data into the
data base using mysqli::query. There are numerous examples of this
as well.

Here's one example:

<?php

       $host = "localhost";
       $user = "root";
       $pwd = "rootpassword";
       $db = "test22";
       $table = "table_to_insert_into";

       $cxn = new mysql($host, $user, $pwd, $db);

       $filename = "tab-delimited.txt";
       $contents = file($filename); // returns the contents of
the file
into an array, one line of file per array

       $columns = explode("\t", $contents[0]); // get the column
names
from the first line of the file

       $sql = "insert into $table set ";
       for ($i=1; $i<count($contents) ; $i++) {
               $data = explode("\t", $contents[$i]);
               $j = 0;
               foreach ($columns as $column) {
$insertdata[] = "$column='" . $cxn- >real_escape_string($data[$j+ +]) . "'"; // this assumes the
column names in the tsv file match
the column names in your data base table exactly. It also assumes
that all your data are strings, not numerics.
               }
               $sql .= implode(",",$insertdata);
               $res = $cxn->query($sql);
if (!res) die ("Error inserting data: " . $cxn- >error());
       }
?>
<html><head><title>Imported data</title></head>
<body>
<p>Data just imported:</p>
<table border="1" cellpadding="2px" cellspacing="2px">
<thead>
<tr style="color: white; background-color: black; text-align:
center">
<?

       $res = $cxn->query("select * from $table limit 1"); //
get one row
from table for generating column names
if (!res) die ("Query failed for table $table: " . $cxn- >error());
       $row = $res->fetch_assoc();
       foreach ($row as $column => $value) {
               echo "<th>" . $column . "</th>";
       }
?>
</tr>
</thead>
<tbody>
<?

       $res = $cxn->query("select * from $table");
if (!res) die ("Query failed for table $table: " . $cxn- >error());
       while ($row = $res->fetch_assoc()) {
               echo "<tr>";
               foreach ($row as $column => $value) {
                       echo "<td>" . $value . "</td>";
               }
               echo "</tr>\n";
       }
?>
</tbody>
</table>
</body>
</html>



As I stated, I am a newbie.

1] I am trying to shorten the learning curve by asking some
questions, which I understand are probably trivial.  A whole
MySQLi
list of functions at this point is to much for me.  I have to
break
the problem into manageable parts.

Important, most used mysqli functions:

Creating the database connection: $cxn = new mysqli( host, user,
password, database );  (mysqli::__construct function)

Submitting queries: $result = $cxn->query( sql ); (mysqli::query
function)

Working with results: $row = $result->fetch_assoc(); -- returns an
associative array of a sql select statement result, subsequent
calls
return the next row in the result until the results are exhausted.

Syntax errors: $cxn->error() -- reports the mysql error of the
last
query.

These will get you started quite well.

2] It has been my experience that using a GUI does not teach the
whole subject.  Linux, which is the OS I use cannot be run from a
GUI.

In the code being discussed, I wish to create a database and add
two tables.  I also note a MySQL statement that can be used to
add
data to an existing table, and wish to be able to execute this
statement using PHP.

mysql(1) is an interactive program that does a lot of things to
help
you interact with mysql databases. It's functions are not all
duplicated in the programmatic interface to mysql(i) -- i.e. you
have to write them yourself.

So, therefore......

Let us try to answer the following two(2) questions:

a] What changes [other than moving the simicolons] have to be
made
to correct the code.

See above

b] What books can you suggest to help w/ MySQL and PHP?  I
already
have the SQL, MySQL & PHP, and HTML books in the ..... for
Dummies
series.  I need something with a little more depth and detail.

Personally, Dummies books don't provide the necessary
information to
actually become proficient at any particular topic.

My personal favourite books are in the O'Reilly catalog, although
some are dated:

- Head First PHP and MySql: http://oreilly.com/catalog/9780596006303/
- PHP Cookbook: http://oreilly.com/catalog/9780596101015/
- Learning PHP, MySQL, and JavaScript: http://oreilly.com/catalog/9780596157135/
- MySQL Cookbook (oreilly.com is currently returning a server
error
on this title, unfortunately)


Tamara


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

Tamara -

Excellent!!

Can you [or someone else] help w/ this ....

I followed the instructions to create the database and the
tables.  No errors appear on the screen, which is also blank, and
the error logfile was never written.  I cannot find the database
tester22 or the tables Names2 and Visit2.  Where should I look, or
did I make a mistake?

Here is the code:

/*
*  Create Database test22
*/
<html><body>
<?php
       {
       $cxn = new mysql($host, $user, $password);
       $res = $cxn->query("create database test22");
       if (!$res)
       {
               die("Failed to create database test22: " . $cxn- >error());
       }

       $cxn = new mysql($host, $user, $password, "test22");
       $sql = "create table Names2";
       $res = $cxn->query($sql);
       if (!$res)
               die("Could not create table Names2: " . $cxn- >error());
       $sql = "create table Visit";
       $res = $cxn->query($sql);
       if (!$res)

               die("Could not create table Visit2: " . $cxn- >error());
       $cxn->close();
?>
</body></html>

Thanks.

Ethan



--- End Message ---
--- Begin Message ---
Ethan Rosenberg wrote:
> Address confirmation is a commonly used to prevent Spam, since spammers
> use false email addressed. I would like to remind you that this is used
> by this mail list and  I do the same as do may companies.

We are not here to solve your spam problem.


--- End Message ---
--- Begin Message ---
I have a strange issue here.  I am running a CentOS machine, with

apache 2.2.3
php 5.1.6
kernel 2.6.18-194.8.1.el5xen

My sessions will work using https, but not using simple http. I've compared my configs with another identical machine which works with both, and I can't figure out why. Anyone got an idea?

Here's the simple script I run to test.

<?php

session_start();

echo 'session started';

if (isset($_SESSION['name'])) {
  echo '<br />' . $_SESSION['name'];
  session_destroy();
} else {
  echo '<br />No session found';
  $_SESSION['name'] = 'My session';
}

phpinfo();
?>

--- End Message ---

Reply via email to