[PHP] Running several applications involving PHP on virtual private server - optimization possible?

2013-02-27 Thread Gary Lebowitz
I currently have 1 domain on a VPS with 1 instance of Moodle 2.3.2. To
minimize the danger of overtaxing the resources (I share a processor :-(
but have 2GBytes of guaranteed RAM) I was wondering if there were anything
I could do if I wanted to put, say, Wordpress or another domain on the same
server with another instance of Moodle in terms of PHP tuning. For the
moment all is well, but I prefer to avoid problems in future if possible.
Ah yes, my PHP version is 5.3.3.


[PHP] Question about PHP-CGI, mysqld and sudden spiking average load readings on Linux Virtual Dedicated Server running CentOS 6.3

2013-02-11 Thread Gary Lebowitz
I have noticed when doing a top via SSH on my GoDaddy virtual dedicated
server that every time a user logs in in the COMMAND column I see the
PHP-CGI process start to run, followed by mysqld. Often when these two
processes run I start to see a spike in average load, and sometimes this
spike spins out of control to the point that when trying to log on to my
Moodle 2.3.2 LMS I get an 500 Internal Server Error from Apache. Now, what
I'd like to know given the fact that I have only 2GBytes of RAM and am
sharing a processor with other users :-( is if there is any way to make
sure my PHP 5.3.3 is properly configured. I am given, for example, a choice
between CGI, fastCGI and Apache in my Plesk panel, and I am not quite sure
how to optimize things for my environment. I went to the Moodle.org site to
try and see what's the right setting, but it's not clear if the persons
writing there have a different setup or not. Unfortunately, it's impossible
to get specs on my VDS's processor from the fine folks at GoDaddy, and
perhaps there is just a simple processor power issue going on here, but I
only have 30 students and only a handful going in simultaneously. And at
times my average load can move from .08 to 1.5+ and all the way up to 2+
within the space of a few seconds. I should point out that at one point it
was discovered by GoDaddy technicial people that a user was running a rogue
process that overtaxing resources. But perhaps I also need to tweak my
installation despite this incident. Any help here would be appreciated.


[PHP] Problem with PHP in Moodle LMS

2012-09-27 Thread Gary Lebowitz
Has anyone ever heard of a problem with the Moodle LMS when trying to edit
an activity (quiz, resource) in which there is a timeout after only a few
seconds and a message saying something to the effect of that the system is
sorry but there was a time out, please retry. When I look in the URL I see
the following after my domain name:

.../course/modeit.php

Is this purely a Moodle thing, or something someone can help me with. (I've
already searched the Moodle site for information about this error, but
can't see anything related to version 2.2.3, which I am using.) Any help
would be appreciated. I thought I might want to up the timout figure in the
php5.ini file in the root directory of my shared Linux hosting with
Godaddy, but I don't think that's really the problem.

Regards,

Gary


Re: [PHP] Depreciation message I can't make out....

2012-06-30 Thread Gary Lebowitz
By the way, I told GoDaddy about the # deprecation issue and they told me
that I could simply change my root directory php5.ini file. But the error
message is related to the PHP.ini file in /web/config, as I said. I could
almost hear them shrugging their shoulders, what-me-worry style. If anyone
with more might than i could explain this error might affect others when
multiplied hundreds of times it could be useful.
Am 30.06.2012 19:23 schrieb Daniel Brown danbr...@php.net:

 On Thu, Jun 28, 2012 at 8:37 PM, tamouse mailing lists
 tamouse.li...@gmail.com wrote:
 
  Just a quick followup -- # comments are deprecated for .ini files,
  only, correct? They are still full citizens in php source, aren't
  they?

Correct, Tam.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

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




[PHP] Depreciation message I can't make out....

2012-06-28 Thread Gary Lebowitz
Hi,

I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy
and am getting the message about depreciation after having typed the
following command into their cron job manager:
 /web/cgi-bin/php5_3 $HOME/html/moodle223a/admin/cli/cron.php

 PHP Deprecated:  Comments starting with '#' are deprecated in
/web/conf/php5.ini on line 1256 in Unknown on line 0
PHP Deprecated:  Comments starting with '#' are deprecated in
/web/conf/php5.ini on line 1257 in Unknown on line 0
br /
bDeprecated/b:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3
and greater in bUnknown/b on line b0/bbr /
Content-type: text/html

GoDaddy says that I am using a command that is not adapted to version 5.3
of PHP, but they suggested I contact you to fix it. Also, I do not believe
I have access to php5.ini; only they do. But I would need to tell them how
to fix this issue. And no one at Moodle.org seems to be able to help.
Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact
you. By the way, this message is only sent to me when using version 5.3 of
PHP; I have another Moodle site using 5.2 and things go perfectly well,
without this message.

Regards,


Re: [PHP] PHP cron job optimization

2011-09-10 Thread Gary Golden
 I want to design an application that reads news from RSS sources.
 I have about 1000 RSS feed to collect from.

 I also will use Cron jobs every 15 minutes to collect the data.
 the question is: Is there a clever way to collect all those feed items
 without exhausting the server
 any Ideas
 Thank you in advance
Just watch your memory and you'll be fine.
As was stated fetching an rss feed is fast and cheap, so I would
contrariwise think about  paralleling if I would you.



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-24 Thread Gary

Steve Staples sstap...@mnsi.net wrote in message 
news:1298568238.14826.2431.camel@webdev01...
 On Thu, 2011-02-24 at 11:42 -0500, Gary wrote:
 Steve Staples sstap...@mnsi.net wrote in message
 news:1298492194.14826.2425.camel@webdev01...
  On Wed, 2011-02-23 at 14:56 -0500, Gary wrote:
  Steve Staples sstap...@mnsi.net wrote in message
  news:1298490417.14826.2418.camel@webdev01...
   On Wed, 2011-02-23 at 14:17 -0500, Gary wrote:
   Jim Lucas li...@cmsws.com wrote in message
   news:4d653673.7040...@cmsws.com...
On 2/23/2011 4:35 AM, Gary wrote:
Pete Ford p...@justcroft.com wrote in message
news:62.c1.32612.d49d4...@pb1.pair.com...
This bit?
   
On 22/02/11 22:06, Gary wrote:
for($i=1; $i=$_POST['counties']; $i++) {
if ( isset($_POST[county{$i}] ) ) {
   
You loop over $_POST['counties'] and look for 
$_POST[county$i]
   
I suspect that there is no field 'counties' in your form, so 
the
server
is
complaining about the missing index - seems likely that the
production
server
is not showing the error, but instead just giving up on the 
page.
   
I think the IE7/Firefox browser difference is a red herring: it
wasn't
actually working in any browser, or the code changed between
tests.
Remember, PHP is server side and generates HTML (or whatever).
Unless
you
tell the PHP what browser you are using and write PHP code to 
take
account
of that (not generally recommended) then the server output is 
the
same
regardless of browser.
   
-- 
Peter Ford, Developer phone: 01580 89 fax:
01580
893399
Justcroft International Ltd.
www.justcroft.com
Justcroft House, High Street, Staplehurst, Kent   TN12 0AH
United
Kingdom
Registered in England and Wales: 2297906
Registered office: Stag Gates House, 63/64 The Avenue, 
Southampton
SO17
1XS
   
   
Pete
   
Once again, thank you for your help.
   
I was able to get it to work, I did not understand the browser
differences
either, but on my testing server on IE, it worked as I wanted 
but
not
on
anything else.  I chopped out most of the code and ended up with
this:
   
if ( isset($_POST['submit']) ) {} else {
print form action=\phpForm3.php\ method=\POST\\n;
if ($Recordset1) {
print table width=200 border=1\n;
print thnbsp; /th\n;
print th State /th\n; //2 fields in Counties table, State 
and
County
print th County /th\n;
print /tr\n;
//create table
$i = 0;
while ( $row = mysql_fetch_array($Recordset1) ) {
$i++;
print tr\n;
print tdinput type=\checkbox\ name=\county$i\
value=\$row[name]\/td\n;
echo td{$row['state_id']}/td\n;
echo td{$row['name']}/td\n;
echo /tr\n;
}//end while
print /table\n;
} else {
echo(PError performing query:  .
mysql_error() . /P);
}
print input type=\hidden\ name=\counties\ 
value=\$i\/\n;
print input type=\submit\ name=\submit\ value=\Go\/\n;
}
?
   
Again, thank you.
   
Gary
   
__ Information from ESET Smart Security, version of 
virus
signature database 5899 (20110223) __
   
The message was checked by ESET Smart Security.
   
http://www.eset.com
   
   
If you would allow me to show you a little easier way of doing 
this.
   
if ( !isset($_POST['submit']) ) {
 echo 'form action=phpForm3.php method=POST';
 if ($Recordset1) {
   echo HEADER
table width=200 border=1
 trth nbsp; /thth State /thth County /th/tr
HEADER;
   while ( $row = mysql_fetch_array($Recordset1) ) {
 echo ROW
 tr
   tdinput type=checkbox name=county[]
value={$row['name']}/td
   td{$row['state_id']}/td
   td{$row['name']}/td
 /tr
ROW;
 }//end while
 echo '/table';
} else {
 echo 'pError performing query: '.mysql_error().'/p';
}
 echo 'input type=submit name=submit value=Go /';
}
   
Now, the main thing I want you to see is the line for the country
checkbox'es
   
The county[] turns the submitted values into an array.  So, in 
the
processing
script, you would do this.
   
?php
   
...
   
if ( !empty($_POST['county'])
 foreach ( $_POST['county'] AS $id = $name )
   echo {$id} {$name}\n;
   
...
?
   
Hope this clears things up for you a little.
   
Enjoy.
   
Jim
  
   In a weird twist, I have/had  the script working, but again it is 
   not
   working in FF or Chrome.  This is a link to the first page which 
   runs
   you
   through the pages.
  
   I have the submit to trigger upon change so there is no submit 
   button.
   This
   works in IE7.  If I add a submit button, it does not work in any of
   them.
  
   I am wondering if this is more a problem with the html.
  
  
   http

Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-24 Thread Gary

Steve Staples sstap...@mnsi.net wrote in message 
news:1298570683.14826.2438.camel@webdev01...
 On Thu, 2011-02-24 at 12:52 -0500, Gary wrote:
 Steve Staples sstap...@mnsi.net wrote in message
 news:1298568238.14826.2431.camel@webdev01...
  On Thu, 2011-02-24 at 11:42 -0500, Gary wrote:
  Steve Staples sstap...@mnsi.net wrote in message
  news:1298492194.14826.2425.camel@webdev01...
   On Wed, 2011-02-23 at 14:56 -0500, Gary wrote:
   Steve Staples sstap...@mnsi.net wrote in message
   news:1298490417.14826.2418.camel@webdev01...
On Wed, 2011-02-23 at 14:17 -0500, Gary wrote:
Jim Lucas li...@cmsws.com wrote in message
news:4d653673.7040...@cmsws.com...
 On 2/23/2011 4:35 AM, Gary wrote:
 Pete Ford p...@justcroft.com wrote in message
 news:62.c1.32612.d49d4...@pb1.pair.com...
 This bit?

 On 22/02/11 22:06, Gary wrote:
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county{$i}] ) ) {

 You loop over $_POST['counties'] and look for
 $_POST[county$i]

 I suspect that there is no field 'counties' in your form, so
 the
 server
 is
 complaining about the missing index - seems likely that the
 production
 server
 is not showing the error, but instead just giving up on the
 page.

 I think the IE7/Firefox browser difference is a red herring: 
 it
 wasn't
 actually working in any browser, or the code changed between
 tests.
 Remember, PHP is server side and generates HTML (or 
 whatever).
 Unless
 you
 tell the PHP what browser you are using and write PHP code 
 to
 take
 account
 of that (not generally recommended) then the server output 
 is
 the
 same
 regardless of browser.

 -- 
 Peter Ford, Developer phone: 01580 89 
 fax:
 01580
 893399
 Justcroft International Ltd.
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH
 United
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue,
 Southampton
 SO17
 1XS


 Pete

 Once again, thank you for your help.

 I was able to get it to work, I did not understand the 
 browser
 differences
 either, but on my testing server on IE, it worked as I wanted
 but
 not
 on
 anything else.  I chopped out most of the code and ended up 
 with
 this:

 if ( isset($_POST['submit']) ) {} else {
 print form action=\phpForm3.php\ method=\POST\\n;
 if ($Recordset1) {
 print table width=200 border=1\n;
 print thnbsp; /th\n;
 print th State /th\n; //2 fields in Counties table, 
 State
 and
 County
 print th County /th\n;
 print /tr\n;
 //create table
 $i = 0;
 while ( $row = mysql_fetch_array($Recordset1) ) {
 $i++;
 print tr\n;
 print tdinput type=\checkbox\ name=\county$i\
 value=\$row[name]\/td\n;
 echo td{$row['state_id']}/td\n;
 echo td{$row['name']}/td\n;
 echo /tr\n;
 }//end while
 print /table\n;
 } else {
 echo(PError performing query:  .
 mysql_error() . /P);
 }
 print input type=\hidden\ name=\counties\
 value=\$i\/\n;
 print input type=\submit\ name=\submit\ 
 value=\Go\/\n;
 }
 ?

 Again, thank you.

 Gary

 __ Information from ESET Smart Security, version of
 virus
 signature database 5899 (20110223) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 If you would allow me to show you a little easier way of doing
 this.

 if ( !isset($_POST['submit']) ) {
  echo 'form action=phpForm3.php method=POST';
  if ($Recordset1) {
echo HEADER
 table width=200 border=1
  trth nbsp; /thth State /thth County /th/tr
 HEADER;
while ( $row = mysql_fetch_array($Recordset1) ) {
  echo ROW
  tr
tdinput type=checkbox name=county[]
 value={$row['name']}/td
td{$row['state_id']}/td
td{$row['name']}/td
  /tr
 ROW;
  }//end while
  echo '/table';
 } else {
  echo 'pError performing query: '.mysql_error().'/p';
 }
  echo 'input type=submit name=submit value=Go /';
 }

 Now, the main thing I want you to see is the line for the 
 country
 checkbox'es

 The county[] turns the submitted values into an array.  So, in
 the
 processing
 script, you would do this.

 ?php

 ...

 if ( !empty($_POST['county'])
  foreach ( $_POST['county'] AS $id = $name )
echo {$id} {$name}\n;

 ...
 ?

 Hope this clears things up for you a little.

 Enjoy.

 Jim
   
In a weird twist, I have/had  the script working, but again it 
is
not
working

[PHP] Re: Dynamically Created Checkboxes

2011-02-23 Thread Gary

Pete Ford p...@justcroft.com wrote in message 
news:62.c1.32612.d49d4...@pb1.pair.com...
 This bit?

 On 22/02/11 22:06, Gary wrote:
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county{$i}] ) ) {

 You loop over $_POST['counties'] and look for $_POST[county$i]

 I suspect that there is no field 'counties' in your form, so the server is 
 complaining about the missing index - seems likely that the production 
 server
 is not showing the error, but instead just giving up on the page.

 I think the IE7/Firefox browser difference is a red herring: it wasn't 
 actually working in any browser, or the code changed between tests. 
 Remember, PHP is server side and generates HTML (or whatever). Unless you 
 tell the PHP what browser you are using and write PHP code to take account 
 of that (not generally recommended) then the server output is the same 
 regardless of browser.

 -- 
 Peter Ford, Developer phone: 01580 89 fax: 01580 
 893399
 Justcroft International Ltd. 
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United 
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 
 1XS


Pete

Once again, thank you for your help.

I was able to get it to work, I did not understand the browser differences 
either, but on my testing server on IE, it worked as I wanted but not on 
anything else.  I chopped out most of the code and ended up with this:

if ( isset($_POST['submit']) ) {} else {
print form action=\phpForm3.php\ method=\POST\\n;
if ($Recordset1) {
print table width=200 border=1\n;
print thnbsp; /th\n;
print th State /th\n; //2 fields in Counties table, State and County
print th County /th\n;
print /tr\n;
//create table
$i = 0;
while ( $row = mysql_fetch_array($Recordset1) ) {
$i++;
print tr\n;
print tdinput type=\checkbox\ name=\county$i\ 
value=\$row[name]\/td\n;
echo td{$row['state_id']}/td\n;
echo td{$row['name']}/td\n;
echo /tr\n;
}//end while
print /table\n;
} else {
echo(PError performing query:  .
mysql_error() . /P);
}
print input type=\hidden\ name=\counties\ value=\$i\/\n;
print input type=\submit\ name=\submit\ value=\Go\/\n;
}
?

Again, thank you.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5899 (20110223) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-23 Thread Gary

Jim Lucas li...@cmsws.com wrote in message 
news:4d653673.7040...@cmsws.com...
 On 2/23/2011 4:35 AM, Gary wrote:
 Pete Ford p...@justcroft.com wrote in message
 news:62.c1.32612.d49d4...@pb1.pair.com...
 This bit?

 On 22/02/11 22:06, Gary wrote:
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county{$i}] ) ) {

 You loop over $_POST['counties'] and look for $_POST[county$i]

 I suspect that there is no field 'counties' in your form, so the server 
 is
 complaining about the missing index - seems likely that the production
 server
 is not showing the error, but instead just giving up on the page.

 I think the IE7/Firefox browser difference is a red herring: it wasn't
 actually working in any browser, or the code changed between tests.
 Remember, PHP is server side and generates HTML (or whatever). Unless 
 you
 tell the PHP what browser you are using and write PHP code to take 
 account
 of that (not generally recommended) then the server output is the same
 regardless of browser.

 -- 
 Peter Ford, Developer phone: 01580 89 fax: 01580
 893399
 Justcroft International Ltd.
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17
 1XS


 Pete

 Once again, thank you for your help.

 I was able to get it to work, I did not understand the browser 
 differences
 either, but on my testing server on IE, it worked as I wanted but not on
 anything else.  I chopped out most of the code and ended up with this:

 if ( isset($_POST['submit']) ) {} else {
 print form action=\phpForm3.php\ method=\POST\\n;
 if ($Recordset1) {
 print table width=200 border=1\n;
 print thnbsp; /th\n;
 print th State /th\n; //2 fields in Counties table, State and 
 County
 print th County /th\n;
 print /tr\n;
 //create table
 $i = 0;
 while ( $row = mysql_fetch_array($Recordset1) ) {
 $i++;
 print tr\n;
 print tdinput type=\checkbox\ name=\county$i\
 value=\$row[name]\/td\n;
 echo td{$row['state_id']}/td\n;
 echo td{$row['name']}/td\n;
 echo /tr\n;
 }//end while
 print /table\n;
 } else {
 echo(PError performing query:  .
 mysql_error() . /P);
 }
 print input type=\hidden\ name=\counties\ value=\$i\/\n;
 print input type=\submit\ name=\submit\ value=\Go\/\n;
 }
 ?

 Again, thank you.

 Gary

 __ Information from ESET Smart Security, version of virus 
 signature database 5899 (20110223) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 If you would allow me to show you a little easier way of doing this.

 if ( !isset($_POST['submit']) ) {
  echo 'form action=phpForm3.php method=POST';
  if ($Recordset1) {
echo HEADER
 table width=200 border=1
  trth nbsp; /thth State /thth County /th/tr
 HEADER;
while ( $row = mysql_fetch_array($Recordset1) ) {
  echo ROW
  tr
tdinput type=checkbox name=county[] value={$row['name']}/td
td{$row['state_id']}/td
td{$row['name']}/td
  /tr
 ROW;
  }//end while
  echo '/table';
 } else {
  echo 'pError performing query: '.mysql_error().'/p';
 }
  echo 'input type=submit name=submit value=Go /';
 }

 Now, the main thing I want you to see is the line for the country 
 checkbox'es

 The county[] turns the submitted values into an array.  So, in the 
 processing
 script, you would do this.

 ?php

 ...

 if ( !empty($_POST['county'])
  foreach ( $_POST['county'] AS $id = $name )
echo {$id} {$name}\n;

 ...
 ?

 Hope this clears things up for you a little.

 Enjoy.

 Jim

Jim

Thank you very much, I have adapted your code and it is working.  I 
appriciate your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5900 (20110223) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-23 Thread Gary

Jim Lucas li...@cmsws.com wrote in message 
news:4d653673.7040...@cmsws.com...
 On 2/23/2011 4:35 AM, Gary wrote:
 Pete Ford p...@justcroft.com wrote in message
 news:62.c1.32612.d49d4...@pb1.pair.com...
 This bit?

 On 22/02/11 22:06, Gary wrote:
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county{$i}] ) ) {

 You loop over $_POST['counties'] and look for $_POST[county$i]

 I suspect that there is no field 'counties' in your form, so the server 
 is
 complaining about the missing index - seems likely that the production
 server
 is not showing the error, but instead just giving up on the page.

 I think the IE7/Firefox browser difference is a red herring: it wasn't
 actually working in any browser, or the code changed between tests.
 Remember, PHP is server side and generates HTML (or whatever). Unless 
 you
 tell the PHP what browser you are using and write PHP code to take 
 account
 of that (not generally recommended) then the server output is the same
 regardless of browser.

 -- 
 Peter Ford, Developer phone: 01580 89 fax: 01580
 893399
 Justcroft International Ltd.
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17
 1XS


 Pete

 Once again, thank you for your help.

 I was able to get it to work, I did not understand the browser 
 differences
 either, but on my testing server on IE, it worked as I wanted but not on
 anything else.  I chopped out most of the code and ended up with this:

 if ( isset($_POST['submit']) ) {} else {
 print form action=\phpForm3.php\ method=\POST\\n;
 if ($Recordset1) {
 print table width=200 border=1\n;
 print thnbsp; /th\n;
 print th State /th\n; //2 fields in Counties table, State and 
 County
 print th County /th\n;
 print /tr\n;
 //create table
 $i = 0;
 while ( $row = mysql_fetch_array($Recordset1) ) {
 $i++;
 print tr\n;
 print tdinput type=\checkbox\ name=\county$i\
 value=\$row[name]\/td\n;
 echo td{$row['state_id']}/td\n;
 echo td{$row['name']}/td\n;
 echo /tr\n;
 }//end while
 print /table\n;
 } else {
 echo(PError performing query:  .
 mysql_error() . /P);
 }
 print input type=\hidden\ name=\counties\ value=\$i\/\n;
 print input type=\submit\ name=\submit\ value=\Go\/\n;
 }
 ?

 Again, thank you.

 Gary

 __ Information from ESET Smart Security, version of virus 
 signature database 5899 (20110223) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 If you would allow me to show you a little easier way of doing this.

 if ( !isset($_POST['submit']) ) {
  echo 'form action=phpForm3.php method=POST';
  if ($Recordset1) {
echo HEADER
 table width=200 border=1
  trth nbsp; /thth State /thth County /th/tr
 HEADER;
while ( $row = mysql_fetch_array($Recordset1) ) {
  echo ROW
  tr
tdinput type=checkbox name=county[] value={$row['name']}/td
td{$row['state_id']}/td
td{$row['name']}/td
  /tr
 ROW;
  }//end while
  echo '/table';
 } else {
  echo 'pError performing query: '.mysql_error().'/p';
 }
  echo 'input type=submit name=submit value=Go /';
 }

 Now, the main thing I want you to see is the line for the country 
 checkbox'es

 The county[] turns the submitted values into an array.  So, in the 
 processing
 script, you would do this.

 ?php

 ...

 if ( !empty($_POST['county'])
  foreach ( $_POST['county'] AS $id = $name )
echo {$id} {$name}\n;

 ...
 ?

 Hope this clears things up for you a little.

 Enjoy.

 Jim

In a weird twist, I have/had  the script working, but again it is not 
working in FF or Chrome.  This is a link to the first page which runs you 
through the pages.

I have the submit to trigger upon change so there is no submit button.  This 
works in IE7.  If I add a submit button, it does not work in any of them.

I am wondering if this is more a problem with the html.


http://www.assessmentappeallawyer.com/forum_state.php

This is the code for the first processing page

if ( !isset($_POST['submit']) ) {
  echo 'form action=forum_delete.php method=POST';
  if ($Recordset1) {
echo HEADER
table width=200 border=0
  trth nbsp; /thth State /thth County /th/tr
HEADER;
while ( $row = mysql_fetch_array($Recordset1) ) {
  echo ROW
  tr
tdinput type=checkbox name=county[] value={$row['name']}/td
td{$row['state_id']}/td
td{$row['name']}/td
  /tr
ROW;
  }//end while
  echo '/table';
} else {
  echo 'pError performing query: '.mysql_error().'/p';
}
  echo 'input type=submit name=submit value=Select /';
}

?

This is the code for the second processing page.


?php


if ( !empty($_POST['county']))
  foreach ( $_POST['county'] AS $id = $name )
echo 'You have selected '.  {$name}.'br /';



$totalRows_county_result_net= ($totalRows_county_result) + (1);
 echo [$totalRows_county_result_net];
 echo $totalRows_county_result;
 ?
/div
!--eo center--


?php
$name=$_POST['name

Re: [PHP] Re: Dynamically Created Checkboxes

2011-02-23 Thread Gary

Steve Staples sstap...@mnsi.net wrote in message 
news:1298490417.14826.2418.camel@webdev01...
 On Wed, 2011-02-23 at 14:17 -0500, Gary wrote:
 Jim Lucas li...@cmsws.com wrote in message
 news:4d653673.7040...@cmsws.com...
  On 2/23/2011 4:35 AM, Gary wrote:
  Pete Ford p...@justcroft.com wrote in message
  news:62.c1.32612.d49d4...@pb1.pair.com...
  This bit?
 
  On 22/02/11 22:06, Gary wrote:
  for($i=1; $i=$_POST['counties']; $i++) {
  if ( isset($_POST[county{$i}] ) ) {
 
  You loop over $_POST['counties'] and look for $_POST[county$i]
 
  I suspect that there is no field 'counties' in your form, so the 
  server
  is
  complaining about the missing index - seems likely that the 
  production
  server
  is not showing the error, but instead just giving up on the page.
 
  I think the IE7/Firefox browser difference is a red herring: it 
  wasn't
  actually working in any browser, or the code changed between tests.
  Remember, PHP is server side and generates HTML (or whatever). Unless
  you
  tell the PHP what browser you are using and write PHP code to take
  account
  of that (not generally recommended) then the server output is the 
  same
  regardless of browser.
 
  -- 
  Peter Ford, Developer phone: 01580 89 fax: 01580
  893399
  Justcroft International Ltd.
  www.justcroft.com
  Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United
  Kingdom
  Registered in England and Wales: 2297906
  Registered office: Stag Gates House, 63/64 The Avenue, Southampton 
  SO17
  1XS
 
 
  Pete
 
  Once again, thank you for your help.
 
  I was able to get it to work, I did not understand the browser
  differences
  either, but on my testing server on IE, it worked as I wanted but not 
  on
  anything else.  I chopped out most of the code and ended up with this:
 
  if ( isset($_POST['submit']) ) {} else {
  print form action=\phpForm3.php\ method=\POST\\n;
  if ($Recordset1) {
  print table width=200 border=1\n;
  print thnbsp; /th\n;
  print th State /th\n; //2 fields in Counties table, State and
  County
  print th County /th\n;
  print /tr\n;
  //create table
  $i = 0;
  while ( $row = mysql_fetch_array($Recordset1) ) {
  $i++;
  print tr\n;
  print tdinput type=\checkbox\ name=\county$i\
  value=\$row[name]\/td\n;
  echo td{$row['state_id']}/td\n;
  echo td{$row['name']}/td\n;
  echo /tr\n;
  }//end while
  print /table\n;
  } else {
  echo(PError performing query:  .
  mysql_error() . /P);
  }
  print input type=\hidden\ name=\counties\ value=\$i\/\n;
  print input type=\submit\ name=\submit\ value=\Go\/\n;
  }
  ?
 
  Again, thank you.
 
  Gary
 
  __ Information from ESET Smart Security, version of virus
  signature database 5899 (20110223) __
 
  The message was checked by ESET Smart Security.
 
  http://www.eset.com
 
 
  If you would allow me to show you a little easier way of doing this.
 
  if ( !isset($_POST['submit']) ) {
   echo 'form action=phpForm3.php method=POST';
   if ($Recordset1) {
 echo HEADER
  table width=200 border=1
   trth nbsp; /thth State /thth County /th/tr
  HEADER;
 while ( $row = mysql_fetch_array($Recordset1) ) {
   echo ROW
   tr
 tdinput type=checkbox name=county[] 
  value={$row['name']}/td
 td{$row['state_id']}/td
 td{$row['name']}/td
   /tr
  ROW;
   }//end while
   echo '/table';
  } else {
   echo 'pError performing query: '.mysql_error().'/p';
  }
   echo 'input type=submit name=submit value=Go /';
  }
 
  Now, the main thing I want you to see is the line for the country
  checkbox'es
 
  The county[] turns the submitted values into an array.  So, in the
  processing
  script, you would do this.
 
  ?php
 
  ...
 
  if ( !empty($_POST['county'])
   foreach ( $_POST['county'] AS $id = $name )
 echo {$id} {$name}\n;
 
  ...
  ?
 
  Hope this clears things up for you a little.
 
  Enjoy.
 
  Jim

 In a weird twist, I have/had  the script working, but again it is not
 working in FF or Chrome.  This is a link to the first page which runs you
 through the pages.

 I have the submit to trigger upon change so there is no submit button. 
 This
 works in IE7.  If I add a submit button, it does not work in any of them.

 I am wondering if this is more a problem with the html.


 http://www.assessmentappeallawyer.com/forum_state.php

 This is the code for the first processing page

 if ( !isset($_POST['submit']) ) {
   echo 'form action=forum_delete.php method=POST';
   if ($Recordset1) {
 echo HEADER
 table width=200 border=0
   trth nbsp; /thth State /thth County /th/tr
 HEADER;
 while ( $row = mysql_fetch_array($Recordset1) ) {
   echo ROW
   tr
 tdinput type=checkbox name=county[] 
 value={$row['name']}/td
 td{$row['state_id']}/td
 td{$row['name']}/td
   /tr
 ROW;
   }//end while
   echo '/table';
 } else {
   echo 'pError performing query: '.mysql_error().'/p';
 }
   echo 'input type=submit name=submit value=Select /';
 }

 ?

 This is the code for the second processing

Re: [PHP] mysql_num_rows()

2011-02-22 Thread Gary
Thanks for your reply
Deva devendra...@gmail.com wrote in message 
news:aanlktimvycqsi5nejd1lxxaqbqsb+q_onhoc7omgj...@mail.gmail.com...
I tried your script locally. Its working for me.

 On Tue, Feb 22, 2011 at 11:10 AM, Gary gp...@paulgdesigns.com wrote:

 Can someone tell me why this is not working?  I do not get an error
 message,
 the results are called and echo'd to screen, the count does not work, I 
 get
 a 0 for a result...



 $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') 
 or
 die(mysql_error());

 if ( isset($_POST['submit']) ) {
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county$i] ) ) {
 echo You have chosen . $_POST[county$i]. br/;
}
}
 }

 $county_total=mysql_num_rows($result);

 while($row = mysql_fetch_array($result))
 {$i++;
echo $row['name'];
 }
 $county_total=mysql_num_rows($result);
 echo $county_total;

 echo 'You Have '  .  $county_total  .  ' Counties ';

 ?
 --
 Gary



Thanks for your reply.

I'm curious, how did you try it locally without a database?

I am still getting either a 0 or a 1 for a result.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5895 (20110222) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] mysql_num_rows()

2011-02-22 Thread Gary

Daniel Molina Wegener d...@coder.cl wrote in message 
news:201102220747.11...@coder.cl...
 On Tuesday 22 February 2011,
 Gary gp...@paulgdesigns.com wrote:

 Can someone tell me why this is not working?  I do not get an error
 message, the results are called and echo'd to screen, the count does not
 work, I get a 0 for a result...

  Are you sure that the table is called `counties` and not `countries`?

  :)




 $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked')
 or die(mysql_error());

 if ( isset($_POST['submit']) ) {
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county$i] ) ) {
 echo You have chosen . $_POST[county$i]. br/;
 }
 }
 }

 $county_total=mysql_num_rows($result);

 while($row = mysql_fetch_array($result))
 {$i++;
 echo $row['name'];
 }
 $county_total=mysql_num_rows($result);
 echo $county_total;

 echo 'You Have '  .  $county_total  .  ' Counties ';

 ?

 Best regards,
 -- 
 Daniel Molina Wegener dmw [at] coder [dot] cl
 System Programmer  Web Developer
 Phone: +56 (2) 979-0277 | Blog: http://coder.cl/


Daniel

Thank you for your reply, yes the database is named counties, working and 
returning results.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5895 (20110222) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: mysql_num_rows()

2011-02-22 Thread Gary

Pete Ford p...@justcroft.com wrote in message 
news:a4.c0.39221.b3ca3...@pb1.pair.com...
 On 22/02/11 05:40, Gary wrote:
 Can someone tell me why this is not working?  I do not get an error 
 message,
 the results are called and echo'd to screen, the count does not work, I 
 get
 a 0 for a result...



 $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') 
 or
 die(mysql_error());

 if ( isset($_POST['submit']) ) {
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county$i] ) ) {
 echo You have chosen . $_POST[county$i].br/;
  }
  }
 }

 $county_total=mysql_num_rows($result);

 while($row = mysql_fetch_array($result))
 {$i++;
  echo $row['name'];
 }
 $county_total=mysql_num_rows($result);
 echo $county_total;

 echo 'You Have '  .  $county_total  .  ' Counties ';

 ?

 The first thing I see is that you do
   $county_total=mysql_num_rows($result)
 twice. Now I'm not to sure, but it is possible that looping over 
 mysql_fetch_array($result) moves an array pointer so the count is not 
 valid after the operation... that's a long shot.

 But since you are looping over the database records anyway, why not just 
 count them as you go? Isn't $i the number of counties after all the 
 looping?


 -- 
 Peter Ford, Developer phone: 01580 89 fax: 01580 
 893399
 Justcroft International Ltd. 
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United 
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 
 1XS


Peter

Thank you for your reply.

I did notice that I had the $county_total=mysql_num_rows($result) twice.  I 
had moved and removed it, always getting either a 0 or 1 result.

I put up another test page with

$result = mysql_query(SELECT * FROM `counties` ) or die(mysql_error());

$tot=mysql_num_rows($result);
echo $tot;

?

And it worked fine.

I have tried count() as well as mysql_num_rows() but am getting the same 
result.

Could you explain what you mean by count them as I go?

Again, Thank you for your reply.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5895 (20110222) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: mysql_num_rows()

2011-02-22 Thread Gary

Pete Ford p...@justcroft.com wrote in message 
news:76.48.39221.054c3...@pb1.pair.com...
 On 22/02/11 13:59, Gary wrote:
 Pete Fordp...@justcroft.com  wrote in message
 news:a4.c0.39221.b3ca3...@pb1.pair.com...
 On 22/02/11 05:40, Gary wrote:
 Can someone tell me why this is not working?  I do not get an error
 message,
 the results are called and echo'd to screen, the count does not work, I
 get
 a 0 for a result...



 $result = mysql_query(SELECT * FROM `counties` WHERE name = 
 'checked')
 or
 die(mysql_error());

 if ( isset($_POST['submit']) ) {
 for($i=1; $i=$_POST['counties']; $i++) {
 if ( isset($_POST[county$i] ) ) {
 echo You have chosen . $_POST[county$i].br/;
   }
   }
 }

 $county_total=mysql_num_rows($result);

 while($row = mysql_fetch_array($result))
 {$i++;
   echo $row['name'];
 }
 $county_total=mysql_num_rows($result);
 echo $county_total;

 echo 'You Have '  .  $county_total  .  ' Counties ';

 ?

 The first thing I see is that you do
$county_total=mysql_num_rows($result)
 twice. Now I'm not to sure, but it is possible that looping over
 mysql_fetch_array($result) moves an array pointer so the count is not
 valid after the operation... that's a long shot.

 But since you are looping over the database records anyway, why not just
 count them as you go? Isn't $i the number of counties after all the
 looping?


 --
 Peter Ford, Developer phone: 01580 89 fax: 01580
 893399
 Justcroft International Ltd.
 www.justcroft.com
 Justcroft House, High Street, Staplehurst, Kent   TN12 0AH   United
 Kingdom
 Registered in England and Wales: 2297906
 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17
 1XS


 Peter

 Thank you for your reply.

 I did notice that I had the $county_total=mysql_num_rows($result) twice. 
 I
 had moved and removed it, always getting either a 0 or 1 result.

 I put up another test page with

 $result = mysql_query(SELECT * FROM `counties` ) or die(mysql_error());

 $tot=mysql_num_rows($result);
 echo $tot;

 ?

 And it worked fine.

 I have tried count() as well as mysql_num_rows() but am getting the same
 result.

 Could you explain what you mean by count them as I go?

 Again, Thank you for your reply.

 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5895 (20110222) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





 Well,

 Lets go back to your original code and cut out the decoration:

 $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked')
 $county_total=mysql_num_rows($result);
 while($row = mysql_fetch_array($result))
 {
 echo $row['name'];
 }
 echo $county_total;

 That code should do pretty much what you want...

 But, because you only show the number of records AFTER the loop, you could 
 do:

 $result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked')
 $county_total = 0;
 while($row = mysql_fetch_array($result))
 {
 echo $row['name'];
 $county_total++;
 }
 echo $county_total;


Peter

Thank you for your suggestion...btw cut out the decoration  LOL

I'm sorry to report it did not work. I tried various configurations of it 
but to no avail.

Any other suggestions?

Again, thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5895 (20110222) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Dynamically Created Checkboxes

2011-02-22 Thread Gary

I have a script that was working, however I discovered it was only working 
in IE7, not in FF or Chrome. It also has stopped working in IE7 once I put 
it on the remote server.  It is to create checkboxes from data called from 
the db. I have echo'd the mysql_num_row and am getting a result, so the 
query seems to be working.  At this point I get a blank page.  Can someone 
point me in the right direction to get this working (again).

$choice=$_POST['state'];
mysql_select_db($database_assess, $assess_remote);
$query_Recordset1 = (SELECT * FROM `counties` WHERE state_id = 
'$choice')or die(mysql_error());
$Recordset1 = mysql_query($query_Recordset1, $assess_remote) or 
die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
   ?php
echo $totalRows_Recordset1;
echo $row_Recordset1;
if ( isset($_POST['submit']) ) { // if form is submitted, process it



/I believe my issue is 
below\\\

for($i=1; $i=$_POST['counties']; $i++) {
if ( isset($_POST[county{$i}] ) ) {
print $_POST[county{$i}]. is checked.br/;
}
}

} else { // if form isn't submitted, output the form
$county_choice=$_SESSION['county{$1}'];
print form action=\phpForm3.php\ method=\POST\\n;

if ($Recordset1) {
print table width=200 border=1\n;

print thnbsp; /th\n;
print th State /th\n; //2 fields in Counties table, State and County
print th County /th\n;

print /tr\n;
//create table
$i = 0;
while ( $row = mysql_fetch_array($Recordset1) ) {
$i++;
print tr\n;

print tdinput type=\checkbox\ name=\county$i\ 
value=\$row[name]\/td\n;

echo td{$row['state_id']}/td\n;

echo td{$row['name']}/td\n;

echo /tr\n;

}//end while
print /table\n;
} else {
echo(PError performing query:  .
mysql_error() . /P);

}
print input type=\hidden\ name=\counties\ value=\$i\/\n;
print input type=\submit\ name=\submit\ value=\Go\/\n;
}

?

Would appriciate your help.

Thank you.
-- 
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5897 (20110222) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] mysql_num_rows()

2011-02-21 Thread Gary
Can someone tell me why this is not working?  I do not get an error message, 
the results are called and echo'd to screen, the count does not work, I get 
a 0 for a result...



$result = mysql_query(SELECT * FROM `counties` WHERE name = 'checked') or 
die(mysql_error());

if ( isset($_POST['submit']) ) {
for($i=1; $i=$_POST['counties']; $i++) {
if ( isset($_POST[county$i] ) ) {
echo You have chosen . $_POST[county$i]. br/;
}
}
}

$county_total=mysql_num_rows($result);

while($row = mysql_fetch_array($result))
{$i++;
echo $row['name'];
}
$county_total=mysql_num_rows($result);
echo $county_total;

echo 'You Have '  .  $county_total  .  ' Counties ';

?
-- 
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5894 (20110221) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] All records not displaying...

2010-12-19 Thread Gary
I have an issue that the first record in a query is not being displayed.  It
seems that the first row in alphabetical order is not being brought to the
screen.

I have run the query in the DB and it displays the correct result, so it has 
to be in the php.

I have a MySQL DB that lists beers.  I have a column for 'type' of beer
(imported, domestic, craft, light). The queries:

$result = MySQL_query(SELECT * FROM beer WHERE type = 'imported' AND stock
= 'YES' ORDER by beername );

When I run the query

if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

  echo 'h3Imported Beers/h3';
  echo 'table width=100% border=0 cellspacing=1 cellpadding=1
id=tableone summary=

  thBeer/th
  thMaker/th
  thType/th
  thSingles/th
  th6-Packs/th
  thCans/th
  thBottles/th
  thDraft/th
  thSize/th
  thDescription/th';

  while ($row = mysql_fetch_array($result)) {

 echo 'tr td' . $row['beername'].'/td';
 echo 'td' . $row['manu'] . '/td';
 echo 'td' . $row['type'] . '/td';
 echo 'td width=40' . $row['singles'] . '/td';
 echo 'td width=20' . $row['six'] . '/td';
 echo 'td width=40' . $row['can'] . '/td';
 echo 'td width=20' . $row['bottles'] . '/td';
 echo 'td width=40' . $row['tap'] . '/td';
 echo 'td' . $row['size'] . '/td';
 echo 'td' . $row['descrip'] . '/td';
'/tr';
}
 echo '/tablebr /';

}

All but the first row in alphabetical order are displayed properly.

Can anyone tell me where I am going wrong?
-- 
Gary

BTW, I do have a bonus question that is about javascript in this same file, 
so if anyone want to take a stab at that, I'll be happy to post it.






__ Information from ESET Smart Security, version of virus signature 
database 5715 (20101219) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] All records not displaying...

2010-12-19 Thread Gary

Tamara Temple tamouse.li...@gmail.com wrote in message 
news:c6993909-dd90-4f52-bf6b-ab888c281...@gmail.com...

 On Dec 19, 2010, at 9:46 AM, Gary wrote:

 I have an issue that the first record in a query is not being  displayed. 
 It
 seems that the first row in alphabetical order is not being brought  to 
 the
 screen.

 I have run the query in the DB and it displays the correct result,  so it 
 has
 to be in the php.

 I have a MySQL DB that lists beers.  I have a column for 'type' of  beer
 (imported, domestic, craft, light). The queries:

 $result = MySQL_query(SELECT * FROM beer WHERE type = 'imported'  AND 
 stock
 = 'YES' ORDER by beername );

 When I run the query

 if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

  echo 'h3Imported Beers/h3';
  echo 'table width=100% border=0 cellspacing=1 cellpadding=1
 id=tableone summary=

  thBeer/th
  thMaker/th
  thType/th
  thSingles/th
  th6-Packs/th
  thCans/th
  thBottles/th
  thDraft/th
  thSize/th
  thDescription/th';

  while ($row = mysql_fetch_array($result)) {

 echo 'tr td' . $row['beername'].'/td';
 echo 'td' . $row['manu'] . '/td';
 echo 'td' . $row['type'] . '/td';
 echo 'td width=40' . $row['singles'] . '/td';
 echo 'td width=20' . $row['six'] . '/td';
 echo 'td width=40' . $row['can'] . '/td';
 echo 'td width=20' . $row['bottles'] . '/td';
 echo 'td width=40' . $row['tap'] . '/td';
 echo 'td' . $row['size'] . '/td';
 echo 'td' . $row['descrip'] . '/td';
 '/tr';
}
 echo '/tablebr /';

 }

 All but the first row in alphabetical order are displayed properly.

 Can anyone tell me where I am going wrong?
 -- 
 Gary

 BTW, I do have a bonus question that is about javascript in this  same 
 file,
 so if anyone want to take a stab at that, I'll be happy to post it.


 This code will totally eliminate the first row of data.

 if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);

 Fetches the first row, but is not output. Because:

  while ($row = mysql_fetch_array($result)) {

 Fetches the second row before you do any output of the data.

 Eliminate the first fetch_array and you're code should work fine.

 BTW, if you put the td attributes 'width=n' in the preceding th 
 tags, you won't have to output them for each row. You should also put  the 
 units those numbers are associated with.


Tamara

Thank you for your help and thank you for the explaination.  I removed the 
line and it works fine.  I dont remember where or why I had that line in 
there, it is code that I have recycled for a while now.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5716 (20101219) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Error Querying Database

2010-12-15 Thread Gary
I cant seem to get this to connect.  This is to my local testing server, 
which is on, so we need not worry that I have posted the UN/PW.

This is a duplicate of a script I have used countless times and it worked. 
The error message is 'Error querying database.'

Some one point out the error of my ways?

Gary


form action=?php echo $_SERVER[PHP_SELF]; ? method=post
tr
td
labelName of Beer/label/tdtdinput name=beername type=text /
/td
/tr
tr
td
labelMaker of Beer/label/tdtdinput name=manu type=text /
/td
/tr
tr
td
labelType of Beer/label/td
tdselect name=type size=1 id=type
  optionImported/option
  optionDomestic/option
  optionCraft/option
  optionLight/option
/select
!--select name=avail size=1 id=avail
  optionAvailable/option
  optionSold/option
/select--
/td
/tr
tr
tdlabelSold in/label
/tdtdinput type=checkbox name=singles value=Yes / Singlesbr /
input type=checkbox name=six value=Yes / Six Packs br /
input type=checkbox name=can value=Yes / Cansbr /
input type=checkbox name=bottles value=Yes / Bottles br /
input type=checkbox name=tap value=Yes / Draft br /
tr
td
labelSize/label/tdtdinput name=size type=text /
/td/tr
trtd
labelDescription/label/tdtdtextarea name=desc cols=40 
rows=5/textarea
/td/tr
trtd
input name=submit type=submit value=Submit //td/tr
/form
/table
/div
div id=list
?php
$beername = $_POST['beername'];
$manu = $_POST['manu'];
$type = $_POST['type'];
$singles = $_POST['singles'];
$six = $_POST['six'];
$can = $_POST['can'];
$bottles = $_POST['bottles'];
$tap = $_POST['tap'];
$size = $_POST['size'];
$desc = $_POST['desc'];
$ip= $_SERVER['REMOTE_ADDR'];

$dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting 
with MySQL Database');

$query = INSERT INTO beer (beername, manu, type, singles, six, can, 
bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu', '$type', 
'$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', '$ip' );

$result = mysqli_query($dbc, $query)
or die('Error querying database.');


mysqli_close($dbc);



-- 
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Error Querying Database

2010-12-15 Thread Gary
Daniel P. Brown daniel.br...@parasane.net wrote in message 
news:aanlkti=gemvzmpjg1uvb4_tdacqlbzyfjcgvd+har...@mail.gmail.com...
On Wed, Dec 15, 2010 at 13:42, Gary gp...@paulgdesigns.com wrote:
 I cant seem to get this to connect. This is to my local testing server,
 which is on, so we need not worry that I have posted the UN/PW.

 This is a duplicate of a script I have used countless times and it worked.
 The error message is 'Error querying database.'

 Some one point out the error of my ways?

Replace:

or die('Error querying database.');

With:

or die('Error querying database.  MySQL said: '.mysql_error());

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

Daniel

Thank you for your reply, the new error message is

Error querying database. MySQL said:

Gary





__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Error Querying Database

2010-12-15 Thread Gary

Steve Staples sstap...@mnsi.net wrote in message 
news:1292440837.5460.8.ca...@webdev01...
 On Wed, 2010-12-15 at 13:42 -0500, Gary wrote:
 I cant seem to get this to connect.  This is to my local testing server,
 which is on, so we need not worry that I have posted the UN/PW.

 This is a duplicate of a script I have used countless times and it 
 worked.
 The error message is 'Error querying database.'

 Some one point out the error of my ways?

 Gary


 form action=?php echo $_SERVER[PHP_SELF]; ? method=post
 tr
 td
 labelName of Beer/label/tdtdinput name=beername type=text /
 /td
 /tr
 tr
 td
 labelMaker of Beer/label/tdtdinput name=manu type=text /
 /td
 /tr
 tr
 td
 labelType of Beer/label/td
 tdselect name=type size=1 id=type
   optionImported/option
   optionDomestic/option
   optionCraft/option
   optionLight/option
 /select
 !--select name=avail size=1 id=avail
   optionAvailable/option
   optionSold/option
 /select--
 /td
 /tr
 tr
 tdlabelSold in/label
 /tdtdinput type=checkbox name=singles value=Yes / Singlesbr 
 /
 input type=checkbox name=six value=Yes / Six Packs br /
 input type=checkbox name=can value=Yes / Cansbr /
 input type=checkbox name=bottles value=Yes / Bottles br /
 input type=checkbox name=tap value=Yes / Draft br /
 tr
 td
 labelSize/label/tdtdinput name=size type=text /
 /td/tr
 trtd
 labelDescription/label/tdtdtextarea name=desc cols=40
 rows=5/textarea
 /td/tr
 trtd
 input name=submit type=submit value=Submit //td/tr
 /form
 /table
 /div
 div id=list
 ?php
 $beername = $_POST['beername'];
 $manu = $_POST['manu'];
 $type = $_POST['type'];
 $singles = $_POST['singles'];
 $six = $_POST['six'];
 $can = $_POST['can'];
 $bottles = $_POST['bottles'];
 $tap = $_POST['tap'];
 $size = $_POST['size'];
 $desc = $_POST['desc'];
 $ip= $_SERVER['REMOTE_ADDR'];

 $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting
 with MySQL Database');

 $query = INSERT INTO beer (beername, manu, type, singles, six, can,
 bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu', '$type',
 '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', 
 '$ip' );

 $result = mysqli_query($dbc, $query)
 or die('Error querying database.');


 mysqli_close($dbc);



 -- 
 Gary


 Read Ash's reply...   but basically, you're running the query with POST
 variables, and inserting them on page display as well as on form submit.

 can you ensure that you can connect from the command line?


 if you may take some criticism, you should rethink your database design,
 as well as the page flow/design... you should either post the form to a
 new page, or if it is back to itself, you should check to see that you
 have in fact posted it before just blindly inserting into the database
 (as currently, every time you view the page, you will insert into the
 database, even if completely empty values).


Steve

Thank you for your reply.

I did not see a reply from Ashley, but I would love to read it.

I always welcome criticism, however this form is for the owner of a bar 
where he will inputing his list of beer that he sells.  The rest of the code 
that is not there is I will have the list then echo to screen below the 
form.  This is an internal list only, no customers will be seeing itif 
that makes any difference to your suggestion.

On your one point

(as currently, every time you view the page, you will insert into the
database, even if completely empty values).

Is this always the case when you process a form onto itself?  Or is there a 
fix?

I did just create a new page, inserted the script onto it, and got the same 
error message.

Again, thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Error Querying Database

2010-12-15 Thread Gary

Sent: Wednesday, December 15, 2010 2:44 PM
Subject: Re: [PHP] Error Querying Database

  On Wed, 2010-12-15 at 13:42 -0500, Gary wrote:
  I cant seem to get this to connect.  This is to my local testing
  server,
  which is on, so we need not worry that I have posted the UN/PW.
 
  This is a duplicate of a script I have used countless times and it
  worked.
  The error message is 'Error querying database.'
 
  Some one point out the error of my ways?
 
  Gary
 
 
  form action=?php echo $_SERVER[PHP_SELF]; ? method=post
  tr
  td
  labelName of Beer/label/tdtdinput name=beername type=text
  /
  /td
  /tr
  tr
  td
  labelMaker of Beer/label/tdtdinput name=manu type=text /
  /td
  /tr
  tr
  td
  labelType of Beer/label/td
  tdselect name=type size=1 id=type
optionImported/option
optionDomestic/option
optionCraft/option
optionLight/option
  /select
  !--select name=avail size=1 id=avail
optionAvailable/option
optionSold/option
  /select--
  /td
  /tr
  tr
  tdlabelSold in/label
  /tdtdinput type=checkbox name=singles value=Yes /
  Singlesbr
  /
  input type=checkbox name=six value=Yes / Six Packs br /
  input type=checkbox name=can value=Yes / Cansbr /
  input type=checkbox name=bottles value=Yes / Bottles br /
  input type=checkbox name=tap value=Yes / Draft br /
  tr
  td
  labelSize/label/tdtdinput name=size type=text /
  /td/tr
  trtd
  labelDescription/label/tdtdtextarea name=desc cols=40
  rows=5/textarea
  /td/tr
  trtd
  input name=submit type=submit value=Submit //td/tr
  /form
  /table
  /div
  div id=list
  ?php
  $beername = $_POST['beername'];
  $manu = $_POST['manu'];
  $type = $_POST['type'];
  $singles = $_POST['singles'];
  $six = $_POST['six'];
  $can = $_POST['can'];
  $bottles = $_POST['bottles'];
  $tap = $_POST['tap'];
  $size = $_POST['size'];
  $desc = $_POST['desc'];
  $ip= $_SERVER['REMOTE_ADDR'];
 
  $dbc = mysqli_connect('localhost','root','','rr')or die('Error
  connecting
  with MySQL Database');
 
  $query = INSERT INTO beer (beername, manu, type, singles, six, can,
  bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu',
  '$type',
  '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc',
  '$ip' );
 
  $result = mysqli_query($dbc, $query)
  or die('Error querying database.');
 
 
  mysqli_close($dbc);
 
 
 
  -- 
  Gary
 
 
  Read Ash's reply...   but basically, you're running the query with POST
  variables, and inserting them on page display as well as on form
  submit.
 
  can you ensure that you can connect from the command line?
 
 
  if you may take some criticism, you should rethink your database
  design,
  as well as the page flow/design... you should either post the form to a
  new page, or if it is back to itself, you should check to see that you
  have in fact posted it before just blindly inserting into the database
  (as currently, every time you view the page, you will insert into the
  database, even if completely empty values).
 

 Steve

 Thank you for your reply.

 I did not see a reply from Ashley, but I would love to read it.

 I always welcome criticism, however this form is for the owner of a bar
 where he will inputing his list of beer that he sells.  The rest of the
 code
 that is not there is I will have the list then echo to screen below the
 form.  This is an internal list only, no customers will be seeing
 itif
 that makes any difference to your suggestion.

 On your one point

 (as currently, every time you view the page, you will insert into the
 database, even if completely empty values).

 Is this always the case when you process a form onto itself?  Or is there
 a
 fix?

 I did just create a new page, inserted the script onto it, and got the
 same
 error message.

 Again, thank you for your help.

 Gary


 Gary

 the line:
 input name=submit type=submit value=Submit /

 is the submit part... if you encapsulate the DB part of the code,
 within:
 if($_POST['submit'] == 'Submit')
 {
# do db stuff in here and value sanitizing
 }

 basically, what that does is the submit button is name $_POST['submit']
 and has the value Submit (the 'value' of the button) which will not be
 set, until you submit the form.   Personally, I do it another way, but
 but is how most people check to see if a form is submitted (i think?)

 but it seems as if your issue stems from the lack of being able to
 connect to the database itself, so either your login credentials are
 wrong, or you dont have the mysqli connector enabled with your php in
 your development box.

 check your phpinfo() to ensure it is enabled.

 Steve

Steve

Again thank you, here is my phpini information, so it would seem mysqli is
enabled


  MysqlI Support enabled
  Client API library version  5.1.41
  Active Persistent Links  0
  Inactive Persistent Links  0
  Active Links  13
  Client API header version  5.1.41
  MYSQLI_SOCKET  MySQL

  Directive Local Value Master Value
  mysqli.allow_local_infile

[PHP] Re: Error Querying Database

2010-12-15 Thread Gary

Gary gp...@paulgdesigns.com wrote in message 
news:81.d1.49824.33c09...@pb1.pair.com...
I cant seem to get this to connect.  This is to my local testing server, 
which is on, so we need not worry that I have posted the UN/PW.

 This is a duplicate of a script I have used countless times and it worked. 
 The error message is 'Error querying database.'

 Some one point out the error of my ways?

 Gary


 form action=?php echo $_SERVER[PHP_SELF]; ? method=post
 tr
 td
 labelName of Beer/label/tdtdinput name=beername type=text /
 /td
 /tr
 tr
 td
 labelMaker of Beer/label/tdtdinput name=manu type=text /
 /td
 /tr
 tr
 td
 labelType of Beer/label/td
 tdselect name=type size=1 id=type
  optionImported/option
  optionDomestic/option
  optionCraft/option
  optionLight/option
 /select
 !--select name=avail size=1 id=avail
  optionAvailable/option
  optionSold/option
 /select--
 /td
 /tr
 tr
 tdlabelSold in/label
 /tdtdinput type=checkbox name=singles value=Yes / Singlesbr 
 /
 input type=checkbox name=six value=Yes / Six Packs br /
 input type=checkbox name=can value=Yes / Cansbr /
 input type=checkbox name=bottles value=Yes / Bottles br /
 input type=checkbox name=tap value=Yes / Draft br /
 tr
 td
 labelSize/label/tdtdinput name=size type=text /
 /td/tr
 trtd
 labelDescription/label/tdtdtextarea name=desc cols=40 
 rows=5/textarea
 /td/tr
 trtd
 input name=submit type=submit value=Submit //td/tr
 /form
 /table
 /div
 div id=list
 ?php
 $beername = $_POST['beername'];
 $manu = $_POST['manu'];
 $type = $_POST['type'];
 $singles = $_POST['singles'];
 $six = $_POST['six'];
 $can = $_POST['can'];
 $bottles = $_POST['bottles'];
 $tap = $_POST['tap'];
 $size = $_POST['size'];
 $desc = $_POST['desc'];
 $ip= $_SERVER['REMOTE_ADDR'];

 $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting 
 with MySQL Database');

 $query = INSERT INTO beer (beername, manu, type, singles, six, can, 
 bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu', '$type', 
 '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', 
 '$ip' );

 $result = mysqli_query($dbc, $query)
 or die('Error querying database.');


 mysqli_close($dbc);




I have tried something completely different, changed to mysql instead of 
mysqli and I put it up on my remote server/database, and it is still not 
behaving...

mysql_connect('server','un','pw') or die(mysql_error());
mysql_select_db(db) or die(mysql_error());

mysql_query(INSERT INTO beer (beername, manu, type, singles, six, can, 
bottles, tap, size, desc, ip).VALUES .('$beername', '$manu', '$type', 
'$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', '$ip' ))
or die(mysql_error());

echo Data Inserted!;

I am now getting this error message, but it does not make sense

You have an error in your SQL syntax; check the manual that corresponds to 
your MySQL server version for the right syntax to use near 'desc, ip)VALUES 
('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1

Does this mean I am getting closer to getting some actual work done today?

Thanks again

gary 



__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: Error Querying Database

2010-12-15 Thread Gary

Bastien Koert phps...@gmail.com wrote in message 
news:aanlktik8s8rgeatp_aq=qjbbuebq9y13zrnhoq+rb...@mail.gmail.com...
On Wed, Dec 15, 2010 at 3:41 PM, Gary gp...@paulgdesigns.com wrote:

 Gary gp...@paulgdesigns.com wrote in message
 news:81.d1.49824.33c09...@pb1.pair.com...
I cant seem to get this to connect. This is to my local testing server,
which is on, so we need not worry that I have posted the UN/PW.

 This is a duplicate of a script I have used countless times and it 
 worked.
 The error message is 'Error querying database.'

 Some one point out the error of my ways?

 Gary


 form action=?php echo $_SERVER[PHP_SELF]; ? method=post
 tr
 td
 labelName of Beer/label/tdtdinput name=beername type=text /
 /td
 /tr
 tr
 td
 labelMaker of Beer/label/tdtdinput name=manu type=text /
 /td
 /tr
 tr
 td
 labelType of Beer/label/td
 tdselect name=type size=1 id=type
 optionImported/option
 optionDomestic/option
 optionCraft/option
 optionLight/option
 /select
 !--select name=avail size=1 id=avail
 optionAvailable/option
 optionSold/option
 /select--
 /td
 /tr
 tr
 tdlabelSold in/label
 /tdtdinput type=checkbox name=singles value=Yes / Singlesbr
 /
 input type=checkbox name=six value=Yes / Six Packs br /
 input type=checkbox name=can value=Yes / Cansbr /
 input type=checkbox name=bottles value=Yes / Bottles br /
 input type=checkbox name=tap value=Yes / Draft br /
 tr
 td
 labelSize/label/tdtdinput name=size type=text /
 /td/tr
 trtd
 labelDescription/label/tdtdtextarea name=desc cols=40
 rows=5/textarea
 /td/tr
 trtd
 input name=submit type=submit value=Submit //td/tr
 /form
 /table
 /div
 div id=list
 ?php
 $beername = $_POST['beername'];
 $manu = $_POST['manu'];
 $type = $_POST['type'];
 $singles = $_POST['singles'];
 $six = $_POST['six'];
 $can = $_POST['can'];
 $bottles = $_POST['bottles'];
 $tap = $_POST['tap'];
 $size = $_POST['size'];
 $desc = $_POST['desc'];
 $ip= $_SERVER['REMOTE_ADDR'];

 $dbc = mysqli_connect('localhost','root','','rr')or die('Error connecting
 with MySQL Database');

 $query = INSERT INTO beer (beername, manu, type, singles, six, can,
 bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu', '$type',
 '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc',
 '$ip' );

 $result = mysqli_query($dbc, $query)
 or die('Error querying database.');


 mysqli_close($dbc);




 I have tried something completely different, changed to mysql instead of
 mysqli and I put it up on my remote server/database, and it is still not
 behaving...

 mysql_connect('server','un','pw') or die(mysql_error());
 mysql_select_db(db) or die(mysql_error());

 mysql_query(INSERT INTO beer (beername, manu, type, singles, six, can,
 bottles, tap, size, desc, ip).VALUES .('$beername', '$manu', '$type',
 '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', 
 '$ip' ))
 or die(mysql_error());

 echo Data Inserted!;

 I am now getting this error message, but it does not make sense

 You have an error in your SQL syntax; check the manual that corresponds to
 your MySQL server version for the right syntax to use near 'desc, 
 ip)VALUES
 ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1

 Does this mean I am getting closer to getting some actual work done today?

 Thanks again

 gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5706 (20101215) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



DESC is a reserved word in mysql (
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html )

Either change the field name or enclose the statement in backticks to
prevent this error. Changing the field name is my recommended action

-- 

Bastien

Cat, the other other white meat


And she appears.viola!

That was itthank you for your help...

I think this will require some onsite research at this site owners shop...

Thanks again

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: Error Querying Database

2010-12-15 Thread Gary

Steve Staples sstap...@mnsi.net wrote in message 
news:1292447844.5460.16.ca...@webdev01...
 On Wed, 2010-12-15 at 15:41 -0500, Gary wrote:
 Gary gp...@paulgdesigns.com wrote in message
 news:81.d1.49824.33c09...@pb1.pair.com...
 I cant seem to get this to connect.  This is to my local testing server,
 which is on, so we need not worry that I have posted the UN/PW.
 
  This is a duplicate of a script I have used countless times and it 
  worked.
  The error message is 'Error querying database.'
 
  Some one point out the error of my ways?
 
  Gary
 
 
  form action=?php echo $_SERVER[PHP_SELF]; ? method=post
  tr
  td
  labelName of Beer/label/tdtdinput name=beername type=text 
  /
  /td
  /tr
  tr
  td
  labelMaker of Beer/label/tdtdinput name=manu type=text /
  /td
  /tr
  tr
  td
  labelType of Beer/label/td
  tdselect name=type size=1 id=type
   optionImported/option
   optionDomestic/option
   optionCraft/option
   optionLight/option
  /select
  !--select name=avail size=1 id=avail
   optionAvailable/option
   optionSold/option
  /select--
  /td
  /tr
  tr
  tdlabelSold in/label
  /tdtdinput type=checkbox name=singles value=Yes / 
  Singlesbr
  /
  input type=checkbox name=six value=Yes / Six Packs br /
  input type=checkbox name=can value=Yes / Cansbr /
  input type=checkbox name=bottles value=Yes / Bottles br /
  input type=checkbox name=tap value=Yes / Draft br /
  tr
  td
  labelSize/label/tdtdinput name=size type=text /
  /td/tr
  trtd
  labelDescription/label/tdtdtextarea name=desc cols=40
  rows=5/textarea
  /td/tr
  trtd
  input name=submit type=submit value=Submit //td/tr
  /form
  /table
  /div
  div id=list
  ?php
  $beername = $_POST['beername'];
  $manu = $_POST['manu'];
  $type = $_POST['type'];
  $singles = $_POST['singles'];
  $six = $_POST['six'];
  $can = $_POST['can'];
  $bottles = $_POST['bottles'];
  $tap = $_POST['tap'];
  $size = $_POST['size'];
  $desc = $_POST['desc'];
  $ip= $_SERVER['REMOTE_ADDR'];
 
  $dbc = mysqli_connect('localhost','root','','rr')or die('Error 
  connecting
  with MySQL Database');
 
  $query = INSERT INTO beer (beername, manu, type, singles, six, can,
  bottles, tap, size, desc, ip ). VALUES ('$beername', '$manu', 
  '$type',
  '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc',
  '$ip' );
 
  $result = mysqli_query($dbc, $query)
  or die('Error querying database.');
 
 
  mysqli_close($dbc);
 



 I have tried something completely different, changed to mysql instead of
 mysqli and I put it up on my remote server/database, and it is still not
 behaving...

 mysql_connect('server','un','pw') or die(mysql_error());
 mysql_select_db(db) or die(mysql_error());

 mysql_query(INSERT INTO beer (beername, manu, type, singles, six, can,
 bottles, tap, size, desc, ip).VALUES .('$beername', '$manu', '$type',
 '$singles', '$six', '$can', '$bottles', '$tap', '$size', '$desc', 
 '$ip' ))
 or die(mysql_error());

 echo Data Inserted!;

 I am now getting this error message, but it does not make sense

 You have an error in your SQL syntax; check the manual that corresponds 
 to
 your MySQL server version for the right syntax to use near 'desc, 
 ip)VALUES
 ('', '', 'Imported', '', '', '', '', '', '', '', '68.80.24.11' at line 1

 Does this mean I am getting closer to getting some actual work done 
 today?

 Thanks again

 gary


 not sure if this is the issue or not, but you have reserved words in
 your field names... try escaping them all in backticks...  and the way i
 do things with variables inside , i put them in {}... here is what i
 mean:

 mysql_query(INSERT INTO `beer` (`beername`, `manu`, `type`, `singles`,
 `six`, `can`, `bottles`, `tap`, `size`, `desc`, `ip`).VALUES
 .('{$beername}', '{$manu}', '{$type}', '{$singles}', '{$six}',
 '{$can}', '{$bottles}', '{$tap}', '{$size}', '{$desc', '{$ip}'));

 Steve


Steve

Thanks again, that was the issue...let me throw that into my vault of 
knowledge about mysql (seems there is plenty of open space in there anyway)

Thanks again

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5706 (20101215) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] empty() in email message

2010-12-13 Thread Gary
I have an email message

$msg =  'Name: $fname ' . ' $lname\n'
. Phone: $phone\n
. Email: $email\n

and it works fine, however in this message there are about 30 variables that 
are being called...as such

. Order: beefschnitzel $beefschnitzel\n
. Order: beefstrips $beefstrips\n
. Order: cheesesausage $cheesesausage\n
. Order: crumbedsausage $crumbedsausage\n
. Order: chucksteak $chucksteak\n
. Order: cornedbeef $cornedbeef\n
. Order: dicedsteak $dicedsteak\n
. Order: filletmignon $filletmignon\n

I want to only send the message if the submitter enters an amount in the 
form for the corresponding variable, instead of having a bunch of empty 
messages.  So I have been trying to use the empty() function as such:

. if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives 
$beefolives\n'}

But I am getting the error

Parse error: syntax error, unexpected T_IF

Can someone point me in the right direction?

Thank you
-- 
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5699 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] empty() in email message

2010-12-13 Thread Gary

Bastien Koert phps...@gmail.com wrote in message 
news:aanlktimimt6h+g+zg4a_78wls4bu09zzsa3jvdujj...@mail.gmail.com...
On Mon, Dec 13, 2010 at 12:47 PM, Gary gp...@paulgdesigns.com wrote:
 I have an email message

 $msg = 'Name: $fname ' . ' $lname\n'
 . Phone: $phone\n
 . Email: $email\n

 and it works fine, however in this message there are about 30 variables 
 that
 are being called...as such

 . Order: beefschnitzel $beefschnitzel\n
 . Order: beefstrips $beefstrips\n
 . Order: cheesesausage $cheesesausage\n
 . Order: crumbedsausage $crumbedsausage\n
 . Order: chucksteak $chucksteak\n
 . Order: cornedbeef $cornedbeef\n
 . Order: dicedsteak $dicedsteak\n
 . Order: filletmignon $filletmignon\n

 I want to only send the message if the submitter enters an amount in the
 form for the corresponding variable, instead of having a bunch of empty
 messages. So I have been trying to use the empty() function as such:

 . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: 
 beefolives
 $beefolives\n'}

 But I am getting the error

 Parse error: syntax error, unexpected T_IF

 Can someone point me in the right direction?

 Thank you
 --
 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5699 (20101213) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



Less complication is better, reduce the code to the below. The empty
portion needs to be inside the parentheses. Also double quotes are
needed to make the vairable parse correctly into the value you want to
see

if (!empty($beefolives)) { echo Order: beefolives $beefolives\n;}


-- 

Bastien

Bastien

Thank you for your response, and I agree, I like simpler.  Your script 
however did not work in the email message, it did work in another section 
where I echo to screen the information to the screen.

Does the echo command work in emails?

Thank you again.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5700 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] empty() in email message

2010-12-13 Thread Gary

Daniel P. Brown daniel.br...@parasane.net wrote in message 
news:aanlktikw+h1nvf6tcg5hgh-2xsubtuosvgkwaynb=...@mail.gmail.com...
On Mon, Dec 13, 2010 at 12:47, Gary gp...@paulgdesigns.com wrote:
 I have an email message

 $msg = 'Name: $fname ' . ' $lname\n'
 . Phone: $phone\n
 . Email: $email\n

 and it works fine, however in this message there are about 30 variables 
 that
 are being called...as such

 . Order: beefschnitzel $beefschnitzel\n
 . Order: beefstrips $beefstrips\n
 . Order: cheesesausage $cheesesausage\n
 . Order: crumbedsausage $crumbedsausage\n
 . Order: chucksteak $chucksteak\n
 . Order: cornedbeef $cornedbeef\n
 . Order: dicedsteak $dicedsteak\n
 . Order: filletmignon $filletmignon\n

 I want to only send the message if the submitter enters an amount in the
 form for the corresponding variable, instead of having a bunch of empty
 messages. So I have been trying to use the empty() function as such:

 . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: 
 beefolives
 $beefolives\n'}

 But I am getting the error

 Parse error: syntax error, unexpected T_IF

 Can someone point me in the right direction?

That's because you're concatenating.  When appending to a
variable, you can't use constructs and conditions, unless using
ternaries:

. (!empty($beefolives)  is_numeric($beefolives) ? 'Order: beefolives
'.$beefolives : null)

However, for readability and ease of management, you might want to
try something like this.  It makes at least two assumptions: you're
using a form post, and you understand that it's untested (as I'm just
typing it here into the body of this email).

?php
// If we've posted our order
if (isset($_POST)  is_array($_POST['order'])) {

// Instantiate the $order variable
$order = null;

// Iterate the order quantities
foreach ($_POST['order'] as $k = $v) {

// If the field is set and the amount is a number
if (isset($v)  is_numeric($v)) {

$order .= 'Order: '.$k.': '.$v.PHP_EOL;
}
}

/**
* Note: in your example, you used single (literal)
* quotes and included the variables.  That would
* literally print $fname and $lname.
*/
$msg  = 'Name: '.$_POST['fname'].' '.$_POST['lname'].PHP_EOL;
$msg .= 'Phone: '.$_POST['phone'].PHP_EOL;
$msg .= 'Email: '.$_POST['email'].PHP_EOL;
$msg .= PHP_EOL;
$msg .= $order;

// And then handle the rest of your processing.  Here, we just echo.
echo 'pre'.PHP_EOL.$msg.'/pre'.PHP_EOL;
}
?
form method=post action=?php echo $_SERVER['PHP_SELF']; ?
First Name: input type=text name=fname id=fnamebr/
Last Name: input type=text name=lname id=lnamebr/
Phone: input type=text name=phone id=phonebr/
Email: input type=text name=email id=emailbr/
br /

h3Order/h3

Beef Schnitzel: input type=text name=order[beefschnitzel]
id=order[beefschnitzel] size=2 maxlength=3br/
Beef Strips: input type=text name=order[beefstrips]
id=order[beefstrips] size=2 maxlength=3br/
Cheese Sausage: input type=text name=order[cheesesausage]
id=order[cheesesausage] size=2 maxlength=3br/
Crumbed Sausage: input type=text name=order[crumbedsausage]
id=order[crumbedsausage] size=2 maxlength=3br/
Chuck Steak: input type=text name=order[chucksteak]
id=order[chucksteak] size=2 maxlength=3br/
Corned Beef: input type=text name=order[cornedbeef]
id=order[cornedbeef] size=2 maxlength=3br/
Diced Steak: input type=text name=order[dicedsteak]
id=order[dicedsteak] size=2 maxlength=3br/
Filet Mignon: input type=text name=order[filletmignon]
id=order[filletmignon] size=2 maxlength=3br/
!-- NOTE: Filet as displayed on the form has one 'L', but the
variable is unchanged. --
br /

input type=submit value=Order Now
/form

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

Daniel

As always, thank you for your input. I had tried your first script, and it 
worked to a degree.  What I was getting was a message that was correct, but, 
well, this is what it looked like in an email

Order: beefschnitzel
10Order:

Which was supposed to look like

Order: beefschnitzel 10

Order:

I have not tried your second suggestion yet, I'll let you know how that 
works.

Again, thank you for your help.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5700 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] empty() in email message

2010-12-13 Thread Gary

Paul M Foster pa...@quillandmouse.com wrote in message 
news:20101213181124.gq21...@quillandmouse.com...
 On Mon, Dec 13, 2010 at 12:47:49PM -0500, Gary wrote:

 I have an email message

 $msg =  'Name: $fname ' . ' $lname\n'
 . Phone: $phone\n
 . Email: $email\n

 and it works fine, however in this message there are about 30 variables 
 that
 are being called...as such

 . Order: beefschnitzel $beefschnitzel\n
 . Order: beefstrips $beefstrips\n
 . Order: cheesesausage $cheesesausage\n
 . Order: crumbedsausage $crumbedsausage\n
 . Order: chucksteak $chucksteak\n
 . Order: cornedbeef $cornedbeef\n
 . Order: dicedsteak $dicedsteak\n
 . Order: filletmignon $filletmignon\n

 I want to only send the message if the submitter enters an amount in the
 form for the corresponding variable, instead of having a bunch of empty
 messages.  So I have been trying to use the empty() function as such:

 . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: 
 beefolives
 $beefolives\n'}

 But I am getting the error

 Parse error: syntax error, unexpected T_IF

 Can someone point me in the right direction?

 It looks like you're trying to do something like:

 $str = 'something' .
 if ($somethingelse)
 'another string'
 else
 'a different string';

 For one thing, you can't put a conditional on the right side of a
 concatenation mark (.). You'd have to do it this way:

 $str = 'something';
 if ($somethingelse) {
 $str .= 'another string';
 }
 else {
 $str .= 'a different string';
 }

 You also can't do:

 elseif (isset($beefolives)) {
 'Order: beefolives $beefolives\n';
 }

 For one thing, surrounding the 'Order...' line with single quotes will
 cause the \n *not* to be interpreted as a newline. Second, your 'Order:
 beefolives...' does nothing. You haven't assigned it to anything or
 operated on that string in any way.

 You might want to study up on single versus double quotes, the
 concatenation operator (.), etc.

 Paul

 -- 
 Paul M. Foster



Paul

Thank you for your reponse.  I will admit I get a little fuzzy on the single 
v double quotation marks, generally the rule I go by is if it is a string, I 
use singles, if any processing I use doubles.  I am not recalling why did it 
that way, perhaps I had doubles and it did not work so I was whittling down 
the options

Thank you again for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5700 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] empty() in email message

2010-12-13 Thread Gary

Andre Polykanine an...@oire.org wrote in message 
news:1110253876.20101214025...@oire.org...
 Hello Gary,

 Try using this:
 if (!empty($beefolives)) $msg.=Order: beef olives;
 or:
 $msg.=empty($beefolives)? : Order: beef olives;

 -- 
 With best regards from Ukraine,
 Andre
 Skype: Francophile
 Twitter: http://twitter.com/m_elensule
 Facebook: http://facebook.com/menelion

 - Original message -
 From: Gary gp...@paulgdesigns.com
 To: php-general@lists.php.net php-general@lists.php.net
 Date: Monday, December 13, 2010, 7:47:49 PM
 Subject: [PHP] empty() in email message

 I have an email message

 $msg =  'Name: $fname ' . ' $lname\n'
 . Phone: $phone\n
 . Email: $email\n

 and it works fine, however in this message there are about 30 variables 
 that
 are being called...as such

 . Order: beefschnitzel $beefschnitzel\n
 . Order: beefstrips $beefstrips\n
 . Order: cheesesausage $cheesesausage\n
 . Order: crumbedsausage $crumbedsausage\n
 . Order: chucksteak $chucksteak\n
 . Order: cornedbeef $cornedbeef\n
 . Order: dicedsteak $dicedsteak\n
 . Order: filletmignon $filletmignon\n

 I want to only send the message if the submitter enters an amount in the
 form for the corresponding variable, instead of having a bunch of empty
 messages.  So I have been trying to use the empty() function as such:

 . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: 
 beefolives
 $beefolives\n'}

 But I am getting the error

 Parse error: syntax error, unexpected T_IF

 Can someone point me in the right direction?

 Thank you
 -- 
 Gary



Andre

That looks good, I will give that a try in the morning, thank you for your 
help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5700 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] empty() in email message

2010-12-13 Thread Gary

Daevid Vincent dae...@daevid.com wrote in message 
news:7d7c84d94dd24035a620e68b5b937...@mascorp.com...
 - Original message -
 From: Gary gp...@paulgdesigns.com
 To: php-general@lists.php.net php-general@lists.php.net
 Date: Monday, December 13, 2010, 7:47:49 PM
 Subject: [PHP] empty() in email message

 I have an email message

 $msg =  'Name: $fname ' . ' $lname\n'
 . Phone: $phone\n
 . Email: $email\n

 and it works fine, however in this message there are about 30
 variables that
 are being called...as such

 . Order: beefschnitzel $beefschnitzel\n
 . Order: beefstrips $beefstrips\n
 . Order: cheesesausage $cheesesausage\n
 . Order: crumbedsausage $crumbedsausage\n
 . Order: chucksteak $chucksteak\n
 . Order: cornedbeef $cornedbeef\n
 . Order: dicedsteak $dicedsteak\n
 . Order: filletmignon $filletmignon\n

 I want to only send the message if the submitter enters an
 amount in the
 form for the corresponding variable, instead of having a
 bunch of empty
 messages.  So I have been trying to use the empty() function as such:

 . if empty($beefolives){''} elseif (isset($beefolives)) {
 'Order: beefolives
 $beefolives\n'}

 You are setting this up fundamentally wrong.

 You should be using an array and looping through it.

 Something like:

 $myorder['cowface'] = 1;
 $myorder['beefenweiner'] = 2;
 $myorder['chucksteak']   = 1;

 foreach ($myorder as $item = $quantity)
 {
 echo Order: $item x $quantity\n;
 }

 Then your array only contains the items someone actually puchased and how
 many.

 d


Daevid

I knew someone was going to point out this was a convoluted method, and I 
agree.  This was sent to me by someone that needed to make the mail form 
work.  My suggestion was to look into a pre-made shopping cart, however that 
was not going to work for them, so I made the mail() work for them.

I had thought about putting it into an array, but had not gotten that far 
into it.  I will look over the code to see how it works.

Thank you for your help.

gary




__ Information from ESET Smart Security, version of virus signature 
database 5700 (20101213) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] E-mail injection question

2010-11-21 Thread Gary
I have been testing various scripts to kill email injection attacks.  I 
adapted this script and it seems to work well.  Does anyone see any issues 
with this?

?php
$newlinecounter = 0;
foreach($_POST as $key = $val_newline){
if(stristr($val_newline, '\r')){$newlinecounter++;}
if(stristr($val_newline, '\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r')){$newlinecounter++;}
if(stristr($val_newline, '\\n')){$newlinecounter++;}
if(stristr($val_newline, '\r\n')){$newlinecounter++;}
if(stristr($val_newline, '\\r\\n')){$newlinecounter++;}
if(stristr($val_newline, 'Bcc')){$newlinecounter++;}
}
if ($newlinecounter = 1){ die('die scum die');
}

?

Thank you,
Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5636 (20101121) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Stripslashes

2010-11-17 Thread Gary

Adam Richardson simples...@gmail.com wrote in message 
news:aanlktin_9_tfe9q+dc2hoynsavccoyuecudkqd919...@mail.gmail.com...
 On Tue, Nov 16, 2010 at 10:10 PM, Gary gp...@paulgdesigns.com wrote:

 I was doing a test of stripslashes on a $_POST, when I recieved the 
 email,
 all of the slashes were still in the data posted.

 I used :

 $fname = stripslashes($_POST['fname']);

 I input G\\a//r\y\\, and was expecting, according to the manuel 
 G\a//r*y\,
 but got the original spelling.


 In this case, you should get the original, if I'm understanding correctly.
 Think of it like a basic math problem:

 Step 1: Happens automatically when you submit the form and PHP receives 
 the
 form variables
 input + slashes = slashed_input

 Step 2: This happens when you call stripslashes.
 slashed_input - slashes = input

 The goal of stripslashes is that it will undo what happened automatically
 using magic_quotes_gpc (which essentially calls addslashes on the GPC vars
 behind the scenes) so you'll end up with the original input.

 So, working through your example:

   1. You inputted into a form G\\a//r\y\\ and submitted the form.
   2. PHP received G\\a//r\y\\ and added slashes (Ga//r\\y).
   3. You called stripslashes (G\\a//r\y\\).





 I added:

 echo stripslashes($fname); and did get the expected result on the page, 
 but
 not in the email from the $_POST.


 Here, you called stripslashes on something already stripped once, so you 
 now
 have a new value (G\a//ry\).



 I also tried

 $fname = (stripslashes($_POST['fname']));


 This would be no different than your attempt without enclosing 
 parentheses.

 Now, let me just say that I detest magic_quotes, and it's best to run with
 them disabled so you  don't even have to worry about this kind of issue
 (they've been deprecated.)  But, perhaps you were just trying to learn 
 about
 some piece of legacy code.

 Hope the explanation helps, Gary.

 Adam

 -- 
 Nephtali:  PHP web framework that functions beautifully
 http://nephtaliproject.com


Adam

Thanks for your reply.  So if I disable magic_quotes, and I assume I can do 
that a script, then the stripslashes would work as the manuel said it would, 
meaning

G\\a//r\y\\ becomes G\a//r'y\

I also assume that until php 6 is out and or I upgrade to it, I will have to 
deal with magic_quotes?

Thank you for your help.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5627 (20101117) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Stripslashes

2010-11-16 Thread Gary
I was doing a test of stripslashes on a $_POST, when I recieved the email, 
all of the slashes were still in the data posted.

I used :

$fname = stripslashes($_POST['fname']);

I input G\\a//r\y\\, and was expecting, according to the manuel G\a//r*y\, 
but got the original spelling.

I added:

echo stripslashes($fname); and did get the expected result on the page, but 
not in the email from the $_POST.

I also tried

$fname = (stripslashes($_POST['fname']));

But got the same result.

Can anyone tell me what I am not understaning?

Thank you

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5625 (20101116) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Watermark with GD

2010-10-31 Thread Gary

Tamara Temple tamouse.li...@gmail.com wrote in message 
news:94df613c-6b40-4897-b101-21cf7d83a...@gmail.com...

 On Oct 30, 2010, at 9:31 AM, Gary wrote:


 tedd tedd.sperl...@gmail.com wrote in message
 news:p06240800c8f1d19b9...@[192.168.1.2]...
 At 3:05 PM -0400 10/29/10, Gary wrote:
 I am trying to get the watermark to work, however I am having a 
 problem in
 that the image is being called from a database (image sits in images
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 
 Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
 on
 line 233

 I have tried various methods, for example: ($_GET ['images/'] or 
 ($_GET
 ['images/$row_WADAimages[image_id]].

 Can anyone shed some light on this for me.

 Thank you

 Gary

 Gary:

 Several things.

 1. Getting an image from a database? You mean that you are getting  the
 path of the image in the file system, right?

 Side note: You could place the image inside the database using a  BLOB 
 and
 do away with the path all together. That has the benefit of being
 portable -- you simply move the database to where ever you want it.  The
 downside is that the database becomes very large, but no more so  that 
 the
 file system. There are pro's and con's in storing actual images in a
 database.

 2. Using a GET is not the way to get the path. Instead, you have to
 retrieve the path from the database table where the path is stored --
 and that requires a MySQL query similar to SELECT * FROM  database 
 WHERE
 id=whatever. There are lot's of examples of how to pull data  from a
 database.

 3. After getting the path, then you can create the watermark like so:

 http://webbytedd.com/b/watermark/

 Hope this helps,

 tedd

 -- 
 ---
 http://sperling.com/


 tedd

 Thank you for your reply.

 I was under the impression that the image is stored in a folder called
 images, in fact the images file do go in, however I have the DB set  up 
 for
 longblob, averaging about 20kb each, so now I am unsure.  I exported  the 
 sql
 so perhaps you can tell me.

 Table structure for table `images`
 --

 CREATE TABLE IF NOT EXISTS `images` (
  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `caption` varchar(50) NOT NULL,
  `wheretaken` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `file_name` varchar(25) NOT NULL,
  `image_file` longblob NOT NULL,
  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`image_id`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;

 When I call the images, which works fine, I do need to specify the  path 
 that
 leads to the images folder. Am I being redundant in this structure.

 This is the script that I use to call the images. I have pulled out  some 
 of
 the html that styles the data.

 ?php if ($totalRows_WADAimages  0) { // Show if recordset not  empty ?
  ?php echo $row_WADAimages[caption]; ?
  src=images/?php echo $row_WADAimages[image_file]; ? ?php echo
 $row_WADAimages[description]; ?

 ?php echo $row_WADAimages[where_taken]; ?
?php echo $row_WADAimages[description]; ?

 Thank you for your help.

 Gary

 is this the imageDetail.php script?

 From what it appears in the code, `image_file` is holding the file  name 
 rather than the actual image. Yet you have `image_file` defined  as a 
 longblob, which would make sense if you were storing the actual  image 
 data in the data base rather than on the file system. As Ashley  noted, 
 you can do it either way. I notice you also have a field  `file_name` --  
 what is this used for? It sounds like your design is a  bit off -- neither 
 one way or the other. The php shown doesn't look  complete enough, 
 though -- where is the img tag and such? Also, going  in and out of php on 
 each line is kind of a waste and looks sloppy. If  i read that code right, 
 it would emit something like this:


 caption text
 src=images/pathtoimagefile description text

 where taken text
 description text

 Look at the html that's emitted from the script and see if that's what 
 you get.

 Can you post or pastebin more of the .php script so I can see more of 
 what is going on?


Tamara

Thanks for the reply, here is a link to the code of the page.

http://www.paulgdesigns.com/detailcode.php

Again, thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5578 (20101031) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Watermark with GD

2010-10-31 Thread Gary
Tamara

I realized I forgot to answer your question about file_name.  It is a text 
field that the photographer enters the name of the image file for easy 
reference.  He does not have access to the DB and he is inserting the images 
from a form I created.

I was sure that the images were being stored and called from the images 
folder and not directly from the DB, that is until tedd brought it up.  I 
did have an issue of getting the images to show in the beginning, however I 
solved it by inserting the path in the call from the DB.  I am wondering now 
if they are stored in both locations.

Thank again

Gary

Tamara Temple tamouse.li...@gmail.com wrote in message 
news:94df613c-6b40-4897-b101-21cf7d83a...@gmail.com...

 On Oct 30, 2010, at 9:31 AM, Gary wrote:


 tedd tedd.sperl...@gmail.com wrote in message
 news:p06240800c8f1d19b9...@[192.168.1.2]...
 At 3:05 PM -0400 10/29/10, Gary wrote:
 I am trying to get the watermark to work, however I am having a 
 problem in
 that the image is being called from a database (image sits in images
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: 
 Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
 on
 line 233

 I have tried various methods, for example: ($_GET ['images/'] or 
 ($_GET
 ['images/$row_WADAimages[image_id]].

 Can anyone shed some light on this for me.

 Thank you

 Gary

 Gary:

 Several things.

 1. Getting an image from a database? You mean that you are getting  the
 path of the image in the file system, right?

 Side note: You could place the image inside the database using a  BLOB 
 and
 do away with the path all together. That has the benefit of being
 portable -- you simply move the database to where ever you want it.  The
 downside is that the database becomes very large, but no more so  that 
 the
 file system. There are pro's and con's in storing actual images in a
 database.

 2. Using a GET is not the way to get the path. Instead, you have to
 retrieve the path from the database table where the path is stored --
 and that requires a MySQL query similar to SELECT * FROM  database 
 WHERE
 id=whatever. There are lot's of examples of how to pull data  from a
 database.

 3. After getting the path, then you can create the watermark like so:

 http://webbytedd.com/b/watermark/

 Hope this helps,

 tedd

 -- 
 ---
 http://sperling.com/


 tedd

 Thank you for your reply.

 I was under the impression that the image is stored in a folder called
 images, in fact the images file do go in, however I have the DB set  up 
 for
 longblob, averaging about 20kb each, so now I am unsure.  I exported  the 
 sql
 so perhaps you can tell me.

 Table structure for table `images`
 --

 CREATE TABLE IF NOT EXISTS `images` (
  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `caption` varchar(50) NOT NULL,
  `wheretaken` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `file_name` varchar(25) NOT NULL,
  `image_file` longblob NOT NULL,
  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`image_id`)
 ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;

 When I call the images, which works fine, I do need to specify the  path 
 that
 leads to the images folder. Am I being redundant in this structure.

 This is the script that I use to call the images. I have pulled out  some 
 of
 the html that styles the data.

 ?php if ($totalRows_WADAimages  0) { // Show if recordset not  empty ?
  ?php echo $row_WADAimages[caption]; ?
  src=images/?php echo $row_WADAimages[image_file]; ? ?php echo
 $row_WADAimages[description]; ?

 ?php echo $row_WADAimages[where_taken]; ?
?php echo $row_WADAimages[description]; ?

 Thank you for your help.

 Gary

 is this the imageDetail.php script?

 From what it appears in the code, `image_file` is holding the file  name 
 rather than the actual image. Yet you have `image_file` defined  as a 
 longblob, which would make sense if you were storing the actual  image 
 data in the data base rather than on the file system. As Ashley  noted, 
 you can do it either way. I notice you also have a field  `file_name` --  
 what is this used for? It sounds like your design is a  bit off -- neither 
 one way or the other. The php shown doesn't look  complete enough, 
 though -- where is the img tag and such? Also, going  in and out of php on 
 each line is kind of a waste and looks sloppy. If  i read that code right, 
 it would emit something like this:


 caption text
 src=images/pathtoimagefile description text

 where taken text
 description text

 Look at the html that's emitted from the script and see if that's what 
 you get.

 Can you post or pastebin more of the .php script so I can see more of 
 what is going on?



 __ Information from ESET Smart Security, version of virus 
 signature database

Re: [PHP] Watermark with GD

2010-10-31 Thread Gary

tedd tedd.sperl...@gmail.com wrote in message 
news:p06240800c8f339e20...@[192.168.1.2]...
 At 9:19 AM -0400 10/31/10, Gary wrote:
I was sure that the images were being stored and called from the images
folder and not directly from the DB, that is until tedd brought it up.  I
did have an issue of getting the images to show in the beginning, however 
I
solved it by inserting the path in the call from the DB.  I am wondering 
now
if they are stored in both locations.

Gary

 Gary:

 Both locations? I think you are confusing yourself.You either have the 
 images stored in the database OR the file system, but not both.

 However, I think you have the images stored as files within the file 
 directory, such as:

 http://yourdomain.com/images/picture1.jpg

 Now, in your database you should have only the path name stored (i.e., 
 images/picture1.jpg) and not the image. However, I usually only store the 
 file names and NOT the path. That way I can move the images to where ever 
 I want and only change their reference in the HTML.

 To recap, to show any image you use the HTML img tag, such as:

 img src=images/picture1.jpg

 To tie this statement to a database, you need to pull out the image name 
 (or file path) from the database and use that. Something like this:

 $query = SELECT file_name FROM pictures WHERE id = '$id' ;
 $result = mysql_query($query) or die();
 $row = mysql_fetch_array($result);
 $file_name = $row['file_name'];

 And then in the HTML you would use:

 img src=images/?php echo($file_name);?

 If you can get to this part, then we can deal with placing a watermark on 
 the image before showing it.

 Please let me know when you get this part to work.

 Cheers,

 tedd

 PS: There is no need to use a LONG BLOB in your database -- that's just a 
 waste of space.

 -- 
 ---
 http://sperling.com/


tedd

Thank you for your reply.

I have the images being displayed in the browser fine, my issue was that I 
was not able to get the watermark to show up.  I believe the issue was here

$img=imagecreatefromjpeg($_GET['pic']);

in that 'pic' is asking for the image that I wanted the watermark displayed 
on, and what I put in did not work.  Since the image file name is being 
stored in the DB, I tried

$row_WADAimages[image_file]

as well as a few others.

What do you suggest I changed longblob to, and is it safe to do so?

Again, thank you for your help.

gary 



__ Information from ESET Smart Security, version of virus signature 
database 5579 (20101031) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

tedd tedd.sperl...@gmail.com wrote in message 
news:p06240800c8f1d19b9...@[192.168.1.2]...
 At 3:05 PM -0400 10/29/10, Gary wrote:
I am trying to get the watermark to work, however I am having a problem in
that the image is being called from a database (image sits in images 
file).

The script in question is this

$image = imagecreatefromjpeg($_GET['src']);

However it produces an error message of

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
line 233

I have tried various methods, for example: ($_GET ['images/'] or ($_GET
['images/$row_WADAimages[image_id]].

Can anyone shed some light on this for me.

Thank you

Gary

 Gary:

 Several things.

 1. Getting an image from a database? You mean that you are getting the 
 path of the image in the file system, right?

 Side note: You could place the image inside the database using a BLOB and 
 do away with the path all together. That has the benefit of being 
 portable -- you simply move the database to where ever you want it. The 
 downside is that the database becomes very large, but no more so that the 
 file system. There are pro's and con's in storing actual images in a 
 database.

 2. Using a GET is not the way to get the path. Instead, you have to 
 retrieve the path from the database table where the path is stored -- 
 and that requires a MySQL query similar to SELECT * FROM database WHERE 
 id=whatever. There are lot's of examples of how to pull data from a 
 database.

 3. After getting the path, then you can create the watermark like so:

 http://webbytedd.com/b/watermark/

 Hope this helps,

 tedd

 -- 
 ---
 http://sperling.com/


tedd

Thank you for your reply.

I was under the impression that the image is stored in a folder called 
images, in fact the images file do go in, however I have the DB set up for 
longblob, averaging about 20kb each, so now I am unsure.  I exported the sql 
so perhaps you can tell me.

Table structure for table `images`
--

CREATE TABLE IF NOT EXISTS `images` (
  `image_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `caption` varchar(50) NOT NULL,
  `wheretaken` varchar(100) NOT NULL,
  `description` text NOT NULL,
  `file_name` varchar(25) NOT NULL,
  `image_file` longblob NOT NULL,
  `submitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`image_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1447 ;

When I call the images, which works fine, I do need to specify the path that 
leads to the images folder. Am I being redundant in this structure.

This is the script that I use to call the images. I have pulled out some of 
the html that styles the data.

?php if ($totalRows_WADAimages  0) { // Show if recordset not empty ?
  ?php echo $row_WADAimages[caption]; ?
  src=images/?php echo $row_WADAimages[image_file]; ? ?php echo 
$row_WADAimages[description]; ?

 ?php echo $row_WADAimages[where_taken]; ?
?php echo $row_WADAimages[description]; ?

Thank you for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

Tamara Temple tamouse.li...@gmail.com wrote in message 
news:7f666311-4bc8-4064-8c70-4f2597e7b...@gmail.com...
 On Oct 29, 2010, at 2:44 PM, Gary wrote:
 Adam Richardson simples...@gmail.com wrote in message
 news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com...
 On Fri, Oct 29, 2010 at 3:05 PM, Gary gp...@paulgdesigns.com wrote:
 I am trying to get the watermark to work, however I am having a  problem 
 in
 that the image is being called from a database (image sits in images
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]:  Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/ imagesDetail.php 
 on
 line 233


 First things first.  It looks like there's nothing in $_GET['src'].
 From where are you getting the value 'src'?

 Adam

 **
 Adam

 Thanks for your reply, that is my question, what is to replace  ['src'] 
 if I
 am calling the image from a database.

 Gary

 I'd really need to know more about this application to help. If you  are 
 calling the image from a database (does this mean you have the  image's 
 file spec saved in the database, or you actually storing the  image data 
 in the database?), you need to use a query to do that. Is  the 
 imagesDetail.php script being called by something else that  already 
 queried the database and put the file spec in the src query  string 
 argument? Before you dump the query string argument directly  into the 
 imagecreatefromjpeg() funciton, you should verify that it  exists:

 if (isset($_GET['src'[)  (!empty($_GET['src'[) {
 $src = $_GET['src'];
 if (fileexists($src)) {
  $image = imageceatefromjpeg($src);
 if ($image === FALSE) {
 # process error from imagecreatefromjpeg
 }
 } else {
  # process missing image
 }
 } else {
  # process missing query string parameter
 }

 This is all prediated on the idea that something is calling your 
 imageDetail.php script with the source path for the image in question.  If 
 that is not the case, and you need to in fact query the database  for the 
 source path of the image, then you need to do a database query.

 Not knowing anything about how your database is set up, I'll take a  stab 
 at a generic method of doing it.

 Somehow, imageDetail.php needs to know what image to get. Let's assume 
 you are calling it from a gallery that has several images displayed.  Part 
 of the information needed is some what to identify the image's  record in 
 the database. Let's assume you have images stored with an  id, that is not 
 null and autoincrements when you store a new image.  Here's a sample 
 schema:

 CREATE TABLE `photos` (
 `id` INT AUTO_INCREMENT NOT NULL,
 `src` VARCHAR(255) NOT NULL,
 `created` TIMESTAMP NOT NULL DEFAULT 0,
 `updated` TIMESTAMP NOT NULL DEFAULT 0 ON UPDATE CURRENT_TIMESTAMP
 PRIMARY KEY (`id`)
 );

 Of course, you would probably want to store a lot more info about an 
 image, but this will do for explanation.

 Let's say you have a gallery shown at your application's index.php 
 program. In the html it generates, you may have something like this  for 
 any particular thumbnail:


 a href=imageDetail.php?id=25img src=thumbs/imageABC.jpg/a

 This is making some assumptions:
   * you have image thumbnails for each image stored in the  subdirectory 
 thumbs/
   * you've figured out somehow that the id for thumbs/imageABC.jpg is  25

 When the user clicks on the image, they get taken to your  imageDetail.php 
 script, with the query string paramter id set to 25.

 In PHP you would then do:

 if (isset($_GET['id']  (!empty($_GET['id']   is_numeric($_GET['id']) {
 $id = $_GET['id'];
 $sql = SELECT * FROM `photos` WHERE id=.$id. LIMIT 1;
 $result = mysql_query($sql,$db);
 if ($result) {
 $imagedata = mysql_fetch_array($result,MYSQL_ASSOC);
 $src = $imagedata['src'];
 if (isset($src)  !empty($src)  fileexists($src)) {
 $image = imagecreatefromjpeg($src);

 # do stuff with image

 } else {

 # handle invalid src data

 }
 } else {

 # handle error from query

 }
 } else {

 # handle invalid id paramter on script

 }


 Note: some people like to handle error conditions before moving on to 
 working with the successful state. It's a matter of style. Either works.

 Hope this helps.

 Tamara

Tamara

Thanks for your reply.  The image is already called, (and if you read the 
response I posted to tedd, you'll see I am now not sure how it is). I also 
posted the code that calls the image if that sheds any light.

I am digesting all the information to get it to work, if any of the code 
changes your answer, I would love to hear it!

Thank you again.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





-- 
PHP General Mailing List (http://www.php.net

Re: [PHP] Watermark with GD

2010-10-30 Thread Gary

tedd tedd.sperl...@gmail.com wrote in message 
news:p06240804c8f1eaf38...@[192.168.1.2]...
 At 10:31 AM -0400 10/30/10, Gary wrote:

I was under the impression that the image is stored in a folder called
images, in fact the images file do go in, however I have the DB set up for
longblob, averaging about 20kb each, so now I am unsure.  I exported the 
sql
so perhaps you can tell me.

 Gary:

 Impressions don't cut it -- you should *know* if the actual images are in 
 the file system or in the database. Find that out before we can proceed.

 Cheers,

 tedd


 -- 
 ---
 http://sperling.com/

tedd

The images do go into the images folder, what I am now unclear about is 
where they are being called from.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5576 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Watermark with GD

2010-10-29 Thread Gary
I am trying to get the watermark to work, however I am having a problem in 
that the image is being called from a database (image sits in images file).

The script in question is this

$image = imagecreatefromjpeg($_GET['src']);

However it produces an error message of

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename 
cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on 
line 233

I have tried various methods, for example: ($_GET ['images/'] or ($_GET 
['images/$row_WADAimages[image_id]].

Can anyone shed some light on this for me.

Thank you

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5575 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Watermark with GD

2010-10-29 Thread Gary

Adam Richardson simples...@gmail.com wrote in message 
news:aanlkti=kenxt7yewrztcm4+hyifrlqhozxse7ufmq...@mail.gmail.com...
On Fri, Oct 29, 2010 at 3:05 PM, Gary gp...@paulgdesigns.com wrote:
 I am trying to get the watermark to work, however I am having a problem in
 that the image is being called from a database (image sits in images 
 file).

 The script in question is this

 $image = imagecreatefromjpeg($_GET['src']);

 However it produces an error message of

 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: Filename
 cannot be empty in /home/content/a/l/i/alinde52/html/imagesDetail.php on
 line 233


First things first.  It looks like there's nothing in $_GET['src'].
From where are you getting the value 'src'?

Adam

**
Adam

Thanks for your reply, that is my question, what is to replace ['src'] if I 
am calling the image from a database.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5575 (20101029) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Unknown Table i field list

2010-10-11 Thread Gary

sueandant hollandsath...@tiscali.co.uk wrote in message 
news:4c8c262adea3459d815fe3e70ae10...@sueandantpc...
 Have you tried :
 $query = INSERT INTO formcom(fname, lname, email, comment, ip) VALUES
 ('$fname','$lname','$email'.'$comment','$ip')
 or die('error in query');
 tholland
 - Original Message - 
 From: Gary gp...@paulgdesigns.com
 To: php-general@lists.php.net
 Sent: Monday, October 11, 2010 8:09 PM
 Subject: [PHP] Unknown Table i field list


I am getting an error of unkown talbe formcom in field list.

 I dont understand this.  I have a talbe called formcom in the database, 
 in fact I created this talbe to replace the first one named comments just 
 in case the table name comments was not allowed.

 I have used this same script a number of time, this is the first time I 
 am getting this error

 Here is the scritpt


 $dbc = mysqli_connect('server','username',password','db name')
 or die('Error connecting to MySQL server');

 $query = INSERT INTO formcom(fname, lname, email, comment, ip) . 
 VALUES ('$fname','$lname','$email'.'$comment','$ip')
 or die('error in query');

 $result = mysqli_query($dbc, $query)
 or die('Error in Result');

 mysqli_close($dbc);

 I have also tried formcom.fname, formcom.lname, formcomemail, 
 formcomcomment, formcom.ip

 I have double triple quad checked to make sure I did not have comment and 
 comments mix up.

 Anyone be able to help me?

 Thank you

 Gary


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



Just tried it, still the same message...

Thank you for trying

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5521 (20101011) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Unknown Table i field list

2010-10-11 Thread Gary

Ashley

I have used the concatenation before and I believe that since I closed the 
INSERT INTO with a , I needed to add the . for the VAULES.


My post is laced with typo's, I just came back from an impromtu hosptial 
stay and they had given me the good stuff,so I was a little cloudier than 
usual.


Thank you again for trying to help.

Gary


a...@ashleysheridan.co.uk wrote in message 
news:40.00.07410.a0783...@pb1.pair.com...

That's the same query.

One thing I did notice (and I wasn't sure if it was a typo as I saw a few 
in the original post) but you've used a period instead of a comma to 
separate the values in the query.


It shouldn't produce the error you're seeing, but sometimes you never 
know!


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

- Reply message -
From: sueandant hollandsath...@tiscali.co.uk
Date: Mon, Oct 11, 2010 22:26
Subject: [PHP] Unknown Table i field list
To: Gary gp...@paulgdesigns.com
Cc: PHP php-general@lists.php.net


Have you tried :
$query = INSERT INTO formcom(fname, lname, email, comment, ip) VALUES

('$fname','$lname','$email'.'$comment','$ip')
or die('error in query');

tholland
- Original Message - 
From: Gary gp...@paulgdesigns.com

To: php-general@lists.php.net
Sent: Monday, October 11, 2010 8:09 PM
Subject: [PHP] Unknown Table i field list



I am getting an error of unkown talbe formcom in field list.

I dont understand this.  I have a talbe called formcom in the database, 
in

fact I created this talbe to replace the first one named comments just in
case the table name comments was not allowed.

I have used this same script a number of time, this is the first time I 
am

getting this error

Here is the scritpt


$dbc = mysqli_connect('server','username',password','db name')
or die('Error connecting to MySQL server');

$query = INSERT INTO formcom(fname, lname, email, comment, ip) . 
VALUES

('$fname','$lname','$email'.'$comment','$ip')
or die('error in query');

$result = mysqli_query($dbc, $query)
or die('Error in Result');

mysqli_close($dbc);

I have also tried formcom.fname, formcom.lname, formcomemail,
formcomcomment, formcom.ip

I have double triple quad checked to make sure I did not have comment and
comments mix up.

Anyone be able to help me?

Thank you

Gary


--
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





__ Information from ESET Smart Security, version of virus signature 
database 5521 (20101011) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



[PHP] Re: Unknown Table i field list Solved

2010-10-11 Thread Gary

Gary gp...@paulgdesigns.com wrote in message 
news:75.f4.27779.7f063...@pb1.pair.com...
I am getting an error of unkown talbe formcom in field list.

 I dont understand this.  I have a talbe called formcom in the database, in 
 fact I created this talbe to replace the first one named comments just in 
 case the table name comments was not allowed.

 I have used this same script a number of time, this is the first time I am 
 getting this error

 Here is the scritpt


 $dbc = mysqli_connect('server','username',password','db name')
 or die('Error connecting to MySQL server');

 $query = INSERT INTO formcom(fname, lname, email, comment, ip) . VALUES 
 ('$fname','$lname','$email'.'$comment','$ip')
 or die('error in query');

 $result = mysqli_query($dbc, $query)
 or die('Error in Result');

 mysqli_close($dbc);

 I have also tried formcom.fname, formcom.lname, formcomemail, 
 formcomcomment, formcom.ip

 I have double triple quad checked to make sure I did not have comment and 
 comments mix up.

 Anyone be able to help me?

 Thank you

 Gary
I put the database into a serperate function and it seems to work nowgo 
figure.


$dbc = mysql_connect(server,'username,'pw')
or die('Error connecting to MySQL server');
mysql_select_db(db,$dbc);

 $query = INSERT INTO formcom(fname, lname, email, comment, ip) . VALUES 
('$fname','$lname','$email','$comment','$ip')
or die('error in query');


  $result = mysql_query($query, $dbc)
or die('Error in Result');

Thanks for all your help

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5522 (20101011) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Syntax Error

2010-10-03 Thread Gary
I have just created a registration page using Webassist, and I am getting a
syntax error that I am not understanding.  Anyone be able to point me in the
right direction?

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near ' NULL, NULL)' at
line 1

This is the code (I have not modified it)

?php require_once('Connections/local.php'); ?
?php
if (!function_exists(GetSQLValueString)) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = ,
$theNotDefinedValue = )
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists(mysql_real_escape_string) ?
mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case text:
$theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
break;
case long:
case int:
$theValue = ($theValue != ) ? intval($theValue) : NULL;
break;
case double:
$theValue = ($theValue != ) ? ' . doubleval($theValue) . ' : NULL;
break;
case date:
$theValue = ($theValue != ) ? ' . $theValue . ' : NULL;
break;
case defined:
$theValue = ($theValue != ) ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?
?php
// *** Redirect if username exists
$MM_flag=MM_insert;
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect=;
$loginUsername = $_POST['id'];
$LoginRS__query = SELECT id FROM family WHERE id=' . $loginUsername . ';
mysql_select_db($database_local, $local);
$LoginRS=mysql_query($LoginRS__query, $local) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

//if there is a row in the database, the username was found - can not add
the requested username
if($loginFoundUser){
$MM_qsChar = ?;
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,?) =1) $MM_qsChar = ;
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar
.requsername=.$loginUsername;
header (Location: $MM_dupKeyRedirect);
exit;
}
}
?
?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= ? . htmlentities($_SERVER['QUERY_STRING']);
}

?
?php
if ((isset($_POST[MM_insert]))  ($_POST[MM_insert] ==
WAATKRegistrationForm)) {
$insertSQL = sprintf(INSERT INTO family (firstname, lastname, email,
password, relationship, story, image, ip, submitted) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s),
GetSQLValueString($_POST['firstname'], text),
GetSQLValueString($_POST['lastname'], text),
GetSQLValueString($_POST['email'], text),
GetSQLValueString($_POST['password'], text),
GetSQLValueString($_POST['relationship'], text),
GetSQLValueString($_POST['story'], text),
GetSQLValueString($_POST['image'], ), GetSQLValueString($_POST['ip'],
text), GetSQLValueString($_POST['submitted'], date));

mysql_select_db($database_local, $local);
$Result1 = mysql_query($insertSQL, $local) or die(mysql_error());

$insertGoTo = family_LogIn.php;
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ?  : ?;
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf(Location: %s, $insertGoTo));
}
?

Thanks again for the help.

Gary



__ Information from ESET Smart Security, version of virus signature 
database 5499 (20101003) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] GD Watermark Question

2010-09-17 Thread Gary
Is there a way to insert a watermark on an image as it is being uploaded to 
the image file, then removed when it is called from a database to be viewed 
on a website?

The rational behind this is I have a photographers site I am doing, and I am 
limiting the size of the images somewhat to reduce pilferage and I would 
like to be able to show the images a little larger, hence with a bit more 
clarity and detail.

Thanks for your input.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: GD Watermark Question-

2010-09-17 Thread Gary

Gary gp...@paulgdesigns.com wrote in message 
news:1f.27.30333.1d5e3...@pb1.pair.com...
 Is there a way to insert a watermark on an image as it is being uploaded 
 to the image file, then removed when it is called from a database to be 
 viewed on a website?

 The rational behind this is I have a photographers site I am doing, and I 
 am limiting the size of the images somewhat to reduce pilferage and I 
 would like to be able to show the images a little larger, hence with a bit 
 more clarity and detail.

 Thanks for your input.

 Gary

More info.

I was asked off board where the watermark would show, so I am sorry if I was 
less than clear.  The watermark would show on an image that is being 
downloaded from the server.  If this were to work, I could let viewers see 
an image with a size of 640px in width to show clarity,  (they are only able 
to see an image now with a width of 250 px now) should they decide to help 
themselves to it, it would download with a watermark on it, but the 
watermark would not appear on the web page itself.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: GD Watermark Question-

2010-09-17 Thread Gary
Tom

No, I had never DD'd an image, however I just did.  So I see your point.

Thanks for your input.

Gary


TR Shaw ts...@oitc.com wrote in message 
news:cff72d3b-52cf-4baf-b60f-6b3709c98...@oitc.com...
Gary

you do realize that if you display the image in a browser without the 
watermark, simple drag and drop can copy the image as is (eg without the 
watermark)

Tom

On Sep 17, 2010, at 6:21 PM, Gary wrote:


 Gary gp...@paulgdesigns.com wrote in message
 news:1f.27.30333.1d5e3...@pb1.pair.com...
 Is there a way to insert a watermark on an image as it is being uploaded
 to the image file, then removed when it is called from a database to be
 viewed on a website?

 The rational behind this is I have a photographers site I am doing, and I
 am limiting the size of the images somewhat to reduce pilferage and I
 would like to be able to show the images a little larger, hence with a 
 bit
 more clarity and detail.

 Thanks for your input.

 Gary

 More info.

 I was asked off board where the watermark would show, so I am sorry if I 
 was
 less than clear.  The watermark would show on an image that is being
 downloaded from the server.  If this were to work, I could let viewers see
 an image with a size of 640px in width to show clarity,  (they are only 
 able
 to see an image now with a width of 250 px now) should they decide to help
 themselves to it, it would download with a watermark on it, but the
 watermark would not appear on the web page itself.

 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5458 (20100917) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: GD Watermark Question-

2010-09-17 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1284763747.12459.40.ca...@localhost...
 On Fri, 2010-09-17 at 18:41 -0400, TR Shaw wrote:

 Gary

 you do realize that if you display the image in a browser without the 
 watermark, simple drag and drop can copy the image as is (eg without the 
 watermark)

 Tom

 On Sep 17, 2010, at 6:21 PM, Gary wrote:

 
  Gary gp...@paulgdesigns.com wrote in message
  news:1f.27.30333.1d5e3...@pb1.pair.com...
  Is there a way to insert a watermark on an image as it is being 
  uploaded
  to the image file, then removed when it is called from a database to 
  be
  viewed on a website?
 
  The rational behind this is I have a photographers site I am doing, 
  and I
  am limiting the size of the images somewhat to reduce pilferage and I
  would like to be able to show the images a little larger, hence with a 
  bit
  more clarity and detail.
 
  Thanks for your input.
 
  Gary
 
  More info.
 
  I was asked off board where the watermark would show, so I am sorry if 
  I was
  less than clear.  The watermark would show on an image that is being
  downloaded from the server.  If this were to work, I could let viewers 
  see
  an image with a size of 640px in width to show clarity,  (they are only 
  able
  to see an image now with a width of 250 px now) should they decide to 
  help
  themselves to it, it would download with a watermark on it, but the
  watermark would not appear on the web page itself.
 
  Gary
 
 
 
  __ Information from ESET Smart Security, version of virus 
  signature database 5458 (20100917) __
 
  The message was checked by ESET Smart Security.
 
  http://www.eset.com
 
 
 
 
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 




 There's no way to do this. Anything you see in your browser has already
 been downloaded in some form onto your computer, and once that happens
 it's out of your control. PHP has no way to detect if the image is being
 requested by the browser to view or download, so can't do what you want.

 Besides which, if an image is displayed in the browser, there are dozens
 of ways to get at it, from right clicking and saving it, using the media
 tab of the file info dialogue (firefox), using firebug to view it,
 saving it from the cache, saving the whole page, using wget to spider
 and save that page, etc.

 The only way to do what you want is to have your own custom browser app
 (possibly written in Java) but even then someone could simply do a print
 screen.

 At the end of the day, if you want to prevent people downloading your
 images, then just don't show them the image.

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


Ashley

When I right click on an image, I assumed it is being called from the 
server, not from the browser, which is why I thought this might work.

Thanks for your help.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: GD Watermark Question

2010-09-17 Thread Gary
Thank you both for your input, my assumption was when an image file is 
gathered from a web page, through whatever method, the image was going to be 
served up from the server, thus if the image file on the server had the 
watermark, then so would the image that is being captured.

Thanks again for your help.

Gary


Gary gp...@paulgdesigns.com wrote in message 
news:1f.27.30333.1d5e3...@pb1.pair.com...
 Is there a way to insert a watermark on an image as it is being uploaded 
 to the image file, then removed when it is called from a database to be 
 viewed on a website?

 The rational behind this is I have a photographers site I am doing, and I 
 am limiting the size of the images somewhat to reduce pilferage and I 
 would like to be able to show the images a little larger, hence with a bit 
 more clarity and detail.

 Thanks for your input.

 Gary


 __ Information from ESET Smart Security, version of virus 
 signature database 5458 (20100917) __

 The message was checked by ESET Smart Security.

 http://www.eset.com



 



__ Information from ESET Smart Security, version of virus signature 
database 5458 (20100917) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] How to set socket_read time out

2010-07-19 Thread Gary .
How can I get calls to scoket_read to timeout if the server stops
responding? It's not clear exactly what's happening, but occasionally
the server simply stops sending data and my php code (client) then sits
there waiting endlessly. I know about set_time_limit but I don't want to
abandon the entire script, just the reading of data from the server (I
can at least give a meaningful error message then, for example).

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



[PHP] Re: How to set socket_read time out

2010-07-19 Thread Gary .
On Mon, Jul 19, 2010 at 9:45 AM, Gary wrote:
 How can I get calls to scoket_read to timeout if the server stops
 responding?

Sorry. Found it:
socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' = 1,
'usec' = 0));

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



[PHP] PHP - MOODLE - WORK IN AUSTRALIA

2010-07-16 Thread Gary Crouch
Hi

We are looking for some one who knows Moodle well and can write for us, web
service's so that we can integrate our application with Moodle.

Expressions of interest are sought from persons or companies who can work on
a project in Australia, pref Brisbane.

Please email me on:-

crouc...@gmail.com

THX|GC
Gary Crouch


[PHP] Serial Numbers

2010-07-12 Thread Gary
I'm sure it is possible, but I am unsure how to do this.  I have created a 
Sale coupon that I was going to put up on a site that I manage, for visitors 
to print out and bring to the store. The coupon is currently a .png, however 
I was planning on converting to a pdf.  I would like to put on the coupon a 
serial number that increases by 1 everytime the page is viewed. I dont 
really care if someone refreshes the page and skews the numbers.

Is this possible and could someone give me some help?

Thanks

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary

Floyd Resler fres...@adex-intl.com wrote in message 
news:e6321b00-590d-4294-9b81-81cc92883...@adex-intl.com...

On Jul 12, 2010, at 2:52 PM, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created a
 Sale coupon that I was going to put up on a site that I manage, for 
 visitors
 to print out and bring to the store. The coupon is currently a .png, 
 however
 I was planning on converting to a pdf.  I would like to put on the coupon 
 a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary


Is there any particular reason you need it to be a PDF?  If not and the GD 
library is installed in your PHP, I would suggest using the GD library to 
draw your serial number on the coupon.  As for keeping track of the counter 
I would do it either in a database table or save the number to file.

Take care,
Floyd


Floyd

Thanks for your reponse.

No real reason that the file has to be a pdf, that was my original plan 
before I came up with the counter idea..  I also thought it might not be as 
difficult to put the script on a pdf.

I have used the GD library in the past, so it is installed on the server, 
however I dont know how to apply to this situation..

After I posted the question, the thought came to me to simply create the 
coupon in html and include a simple counter, like a hit counter, but since I 
had the png already created, I was hoping there was a way to include the 
script on it instead of recreating in html/php.

Gary




__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary




Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278962039.2202.5.ca...@localhost...
 On Mon, 2010-07-12 at 14:52 -0400, Gary wrote:

 I'm sure it is possible, but I am unsure how to do this.  I have created 
 a
 Sale coupon that I was going to put up on a site that I manage, for 
 visitors
 to print out and bring to the store. The coupon is currently a .png, 
 however
 I was planning on converting to a pdf.  I would like to put on the coupon 
 a
 serial number that increases by 1 everytime the page is viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Thanks

 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5273 (20100712) __

 The message was checked by ESET Smart Security.

 http://www.eset.com







 You need some indicator on your server to keep track of the number. To
 me, the ideal solution would appear to be a MySQL database. You can set
 up a table with an auto_increment field and use the id generated from
 that.

 Two things to maybe note:


 1. Don't use MAX(id) in a query to get the next auto value, use
something like mysql_insert_id() instead. The MAX() method is
just a race condition waiting to happen.
 2. If you expect a lot of traffic, then consider setting this table
to use the InnoDB engine instead of MyIsam which is usually the
default. This allows MySQL to apply row-level locking instead of
table-level, which can improve performance when PHP has to wait
for MySQL.


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


Ashley

Thanks for your reply.

I was not going to go to the trouble of calling the AI number from a 
database, although that is an interesting concept.

The question really becomes How to insert into an image I could just write 
a simple hit counter and create a new php/html page, but since the image 
(coupon) was already created, I thought it would be easier, not to mention 
expand my abilities.

It is a small shop and if they get 100 coupons, they will be extatic, so it 
will not kill us if it were too much trouble.

I have gone to using  InnoDB as my standard table, mainly for the foreign 
key ability, but I do keep reading that there are more and more advantage to 
using is over Myisam.

Thanks again for your reply.

Gary
 



__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Serial Numbers

2010-07-12 Thread Gary

Daevid Vincent dae...@daevid.com wrote in message 
news:a380a1570d4c4351b38e1cce2aabe...@mascorp.com...
 -Original Message-
 From: Gary [mailto:gp...@paulgdesigns.com]
 Sent: Monday, July 12, 2010 11:53 AM

 I'm sure it is possible, but I am unsure how to do this.  I
 have created a
 Sale coupon that I was going to put up on a site that I
 manage, for visitors
 to print out and bring to the store. The coupon is currently
 a .png, however
 I was planning on converting to a pdf.  I would like to put
 on the coupon a
 serial number that increases by 1 everytime the page is
 viewed. I dont
 really care if someone refreshes the page and skews the numbers.

 Is this possible and could someone give me some help?

 Is there a reason you need to increment by 1? I mean, are you going to
 validate the coupon someone brings in to see if it's in the database or is
 used already? Since you say you don't care if the number is skewed, it
 sounds as if you don't care about the code either really.

 Point being, why not just use md5(time()) or uniqid() or something and 
 make
 some truly unique code (that you may or may not wish to store in a DB).
 This will be obscure enough the average person won't know that it isn't
 tracked and most likely won't try to make their own. If I saw 123457, I'm
 pretty sure I could make a coupon with 123500 on it. But if I saw
 6ccd780c-baba-1026-9564-0040f4311e29 then I'm not really going to try and
 fudge one of those. Then I'd use the barcode library to print the code
 (again, doesn't have to actually work if you're not going to do a lookup)
 just to add more realizm to it. There are a billion different ways to
 make a unique ID. Even IF you are going to track them, you really 
 shouldn't
 do a sequential code as you originally wanted to do.

 http://us.php.net/manual/en/function.uniqid.php
 http://php.net/manual/en/function.com-create-guid.php
 http://us.php.net/manual/en/function.mssql-guid-string.php
 http://us.php.net/manual/en/function.md5.php
 http://us.php.net/manual/en/function.sha1.php
 http://us.php.net/manual/en/function.hash.php
 http://us.php.net/manual/en/function.time.php
 http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#functio
 n_uuid

 Heck, you could even just use ip2long() on their IP address and then when
 someone redeems the coupon code, a simple long2ip() would tell you if
 it's a valid IP format rather than some hacked up string.
 http://us.php.net/manual/en/function.ip2long.php
 http://us.php.net/manual/en/function.long2ip.php

 Daevid.
 http://daevid.com

 Some people, when confronted with a problem, think 'I know, I'll use
 XML.'
 Now they have two problems.

Daevid

Thanks for your reply.

The numbers are not for show, we are not trying to make it seem like we have 
thousands of coupons.  We are going to use the numbers to guage how many 
times people see the coupon and to see how many it takes before we have 
someone show up to use it, but dont really care if someone gets a kick out 
of hitting the refresh button 10 or 20 times to watch the number go up.

I was going to start the number at 72010001 (July 2010, 001) and if someone 
figured out what it was, we dont really care. As I mentioned, it is a small 
shop (one man show) that the site gets and average of 350 visits per month 
(which he is very happy with over what he had).

Although I do like the idea of using there ip address...

Thanks for your reply and all the links.

Gary




__ Information from ESET Smart Security, version of virus signature 
database 5273 (20100712) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Login In script quesitons

2010-07-09 Thread Gary
I have a log in script that is not working.  It is taken from a lesson book 
that I read about a year or so ago so the lessons are not fresh in my mind.

My questions are.

1. Why is this not working?
2. Does is look secure?
3. In researching the issue, I was reading some older threads that it was a 
better idea to use some commercial ready made scripts.  Are there any 
recommendations?

Here is the code to the script I am trying to get to work.  I get no error 
message, however if it will not log me in with a correct un/pw or if I leave 
it blank, I get the same message and it allows the next page to be viewed 
(which I do not want).  DB is set up with data in it.

Login Page:

?php

  // Start the session
  session_start();
  ?

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
  http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
head
  meta http-equiv=Content-Type content=text/html; charset=utf-8 /
  titlexxx- Log In/title
  link rel=stylesheet type=text/css href=style.css /
/head
body
  h3xxx- Log In/h3

?php
  // If the session var is empty, show any error message and the log-in 
form; otherwise confirm the log-in
  if (empty($_SESSION['username'])) {
echo 'p class=error' . $error_msg . '/p';
?

  form method=post action=story.php
fieldset
  legendLog In/legend
  label for=usernameUsername:/label
  input type=text name=username value=?php if (!empty($username)) 
echo $username; ? /br /
  label for=passwordPassword:/label
  input type=password name=password /
/fieldset
input type=submit value=Log In name=submit /
  /form

?php
  }
  else {
// Confirm the successful log-in
echo('p class=loginYou are logged in as ' . $_SESSION['username'] . 
'./p');
  }
?

/body
/html

Processing page:

?php


  // Start the session
  session_start();

  // Clear the error message
 $error_msg = ;

  // If the user isn't logged in, try to log them in
  if (!isset($_SESSION['username'])) {
if (isset($_POST['submit'])) {
  // Connect to the database
  $dbc = mysqli_connect(host, 'un', 'pw', 'db')//sanitized for board
or die('Error connecting with MySQL Database');

  // Grab the user-entered log-in data
  $username = mysqli_real_escape_string($dbc, trim($_POST['username']));
  $password = mysqli_real_escape_string($dbc, trim($_POST['password']));

  if (!empty($username)  !empty($password)) {
// Look up the username and password in the database
$query = SELECT username, password FROM family WHERE username = 
'$username' AND password = SHA('password');
$data = mysqli_query($dbc, $query)or die(mysqli_error($dbc));

if (mysqli_num_rows($data) == 1) {
  // The log-in is OK so set the user ID and username session vars 
(and cookies), and redirect to the home page
  $row = mysqli_fetch_array($data);

  $_SESSION['username'] = $row['username'];

  setcookie('username', $row['username'], time() + (60 * 60 * 24 * 
30));  // expires in 30 days
  $home_url = 'http://' . $_SERVER['HTTP_HOST'] . 
dirname($_SERVER['PHP_SELF']) . '/index.php';
  header('Location: ' . $home_url);
}
else {
  // The username/password are incorrect so set an error message
  $error_msg = 'Sorry, you must enter a valid username and password 
to log in.';
}
  }
  else {
// The username/password weren't entered so set an error message
$error_msg = 'Sorry, you must enter your username and password to 
log in.';
  }
}
  }
?
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;!-- InstanceBegin 
template=/Templates/blindowl.dwt.php codeOutsideHTMLIsLocked=false --
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
!-- InstanceBeginEditable name=doctitle --
titlexxx/title
!-- InstanceEndEditable --
style type=text/css

/style
link href=p7pmm/p7PMMh03.css rel=stylesheet type=text/css media=all 
/
script type=text/javascript src=p7pmm/p7PMMscripts.js/script
script src=Scripts/AC_RunActiveContent.js 
type=text/javascript/script
link href=xxx.css rel=stylesheet type=text/css /
!-- InstanceBeginEditable name=head --!-- InstanceEndEditable --
/head

body
div id=wrap

div id=header
div id=headercontent/div
/div
div id=menu
  ?php include('includes/menu.inc.php');?
/div


div id=mainwrap!-- InstanceBeginEditable name=main --


?php
  // If the session var is empty, show any error message and the log-in 
form; otherwise confirm the log-in
  if (empty($_SESSION['username'])) {
echo 'p class=error' . $error_msg . '/p';
?

?php
  }
  else {
// Confirm the successful log-in
echo('p class=loginYou are logged in as ' . $_SESSION['username'] . 
'./p');
  }
?
Story//text to let me know if the page opened
!-- InstanceEndEditable --/div
div id=footer?php 

Re: [PHP] Login In script quesitons

2010-07-09 Thread Gary

Richard Quadling rquadl...@gmail.com wrote in message 
news:aanlktilbmyedd8paky9dwgn0q7t6kem4zzutu_49u...@mail.gmail.com...
 On 9 July 2010 16:42, Gary gp...@paulgdesigns.com wrote:
 [snip]

 Take a look at https://code.google.com/p/loginsystem-rd/


Richard

Thank you for your quick reply and the link.  Since I see you are one of the
creators, thank you for that as well.

I am getting the following error and I'm not sure how to correct it.

Warning: Cannot modify header information - headers already sent by (output
started at /home/content/45/6359745/html/login/include/loginGlobals.php:281)
in /home/content/45/6359745/html/login/include/form_token.php on line 15

Warning: Cannot modify header information - headers already sent by (output
started at /home/content/45/6359745/html/login/include/loginGlobals.php:281)
in /home/content/45/6359745/html/login/include/form_token.php on line 22

Line 15 is: setcookie(token, , time()-42000);
Line 22 is :if (setcookie(token, $_SESSION[token], time()+86400)) {

loginGlobals stops at line 278

Again, thank you for all your help.

gary






__ Information from ESET Smart Security, version of virus signature 
database 5266 (20100709) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Login In script quesitons

2010-07-09 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278705035.2295.2.ca...@localhost...
 On Fri, 2010-07-09 at 15:43 -0400, Gary wrote:

 Richard Quadling rquadl...@gmail.com wrote in message
 news:aanlktilbmyedd8paky9dwgn0q7t6kem4zzutu_49u...@mail.gmail.com...
  On 9 July 2010 16:42, Gary gp...@paulgdesigns.com wrote:
  [snip]
 
  Take a look at https://code.google.com/p/loginsystem-rd/
 

 Richard

 Thank you for your quick reply and the link.  Since I see you are one of 
 the
 creators, thank you for that as well.

 I am getting the following error and I'm not sure how to correct it.

 Warning: Cannot modify header information - headers already sent by 
 (output
 started at 
 /home/content/45/6359745/html/login/include/loginGlobals.php:281)
 in /home/content/45/6359745/html/login/include/form_token.php on line 15

 Warning: Cannot modify header information - headers already sent by 
 (output
 started at 
 /home/content/45/6359745/html/login/include/loginGlobals.php:281)
 in /home/content/45/6359745/html/login/include/form_token.php on line 22

 Line 15 is: setcookie(token, , time()-42000);
 Line 22 is :if (setcookie(token, $_SESSION[token], time()+86400)) {

 loginGlobals stops at line 278

 Again, thank you for all your help.

 gary






 __ Information from ESET Smart Security, version of virus 
 signature database 5266 (20100709) __

 The message was checked by ESET Smart Security.

 http://www.eset.com







 My guess is that you've put the login PHP code after some HTML in that
 page? If you output any content at all (even a blank space) it will
 output the default headers. What you need to do is have any logic that
 includes a header() call before any output.

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

Ashley

I am aware of that would cause a problem.  I am not finding any html at all 
on either page.

Thanks for your reply.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5266 (20100709) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Login In script quesitons

2010-07-09 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278705549.2295.4.ca...@localhost...
 On Fri, 2010-07-09 at 15:58 -0400, Gary wrote:

 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message
 news:1278705035.2295.2.ca...@localhost...
  On Fri, 2010-07-09 at 15:43 -0400, Gary wrote:
 
  Richard Quadling rquadl...@gmail.com wrote in message
  news:aanlktilbmyedd8paky9dwgn0q7t6kem4zzutu_49u...@mail.gmail.com...
   On 9 July 2010 16:42, Gary gp...@paulgdesigns.com wrote:
   [snip]
  
   Take a look at https://code.google.com/p/loginsystem-rd/
  
 
  Richard
 
  Thank you for your quick reply and the link.  Since I see you are one 
  of
  the
  creators, thank you for that as well.
 
  I am getting the following error and I'm not sure how to correct it.
 
  Warning: Cannot modify header information - headers already sent by
  (output
  started at
  /home/content/45/6359745/html/login/include/loginGlobals.php:281)
  in /home/content/45/6359745/html/login/include/form_token.php on line 
  15
 
  Warning: Cannot modify header information - headers already sent by
  (output
  started at
  /home/content/45/6359745/html/login/include/loginGlobals.php:281)
  in /home/content/45/6359745/html/login/include/form_token.php on line 
  22
 
  Line 15 is: setcookie(token, , time()-42000);
  Line 22 is :if (setcookie(token, $_SESSION[token], time()+86400)) 
  {
 
  loginGlobals stops at line 278
 
  Again, thank you for all your help.
 
  gary
 
 
 
 
 
 
  __ Information from ESET Smart Security, version of virus
  signature database 5266 (20100709) __
 
  The message was checked by ESET Smart Security.
 
  http://www.eset.com
 
 
 
 
 
 
 
  My guess is that you've put the login PHP code after some HTML in that
  page? If you output any content at all (even a blank space) it will
  output the default headers. What you need to do is have any logic that
  includes a header() call before any output.
 
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk

 Ashley

 I am aware of that would cause a problem.  I am not finding any html at 
 all
 on either page.

 Thanks for your reply.

 Gary



 __ Information from ESET Smart Security, version of virus 
 signature database 5266 (20100709) __

 The message was checked by ESET Smart Security.

 http://www.eset.com






 What does your code look like now?

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


Ashley

This is form_token.php

?php
if (!isset($_SESSION)) {
 session_start();
}
?
?php

function generateToken(){
 
/*
 * Create and set a new token for CSRF protection * on initial entry or after 
form errors and we are going to redisplay theform. 
**/
 $salt=; $tokenStr=; $salt = sha1($_SERVER[HTTP_HOST]); 
setcookie(token, , time()-42000); $_SESSION[salt]=$salt; 
$_SESSION[guid] = getGUID(); $_SESSION[ip] = $_SERVER[REMOTE_ADDR]; 
$_SESSION[time] = time(); $tokenStr = IP: . $_SESSION[ip] . ,SESSIONID: 
. session_id() .,GUID: . $_SESSION[guid]; 
$_SESSION[token]=sha1(($tokenStr.$_SESSION[salt]).$_SESSION[salt]); if 
(setcookie(token, $_SESSION[token], time()+86400)) {  
$_SESSION[usecookie]=True; }}function checkToken() { 
/*
 * Check the posted token for correctness 
**/
 $oldToken=; $testToken=; $tokenStr=; 
$page=basename($_SERVER['PHP_SELF']); $oldToken=$_POST[token]; $tokenStr = 
IP: . $_SESSION[ip] . ,SESSIONID: . session_id() .,GUID: . 
$_SESSION[guid]; 
$testToken=sha1(($tokenStr.$_SESSION[salt]).$_SESSION[salt]); 
$checkToken=False; If ($oldToken===$testToken) { $diff = time() - 
$_SESSION[time];  If ($diff=300) { // Five minutes max  If 
($_SESSION[usecookie]) {   If ($_COOKIE[token]===$oldToken) {
/*
 * Destroy the old form token, then * generate a new token for the 
form, which may or may not be needed. Wewant to do this * before headers 
are written. When writeToken() or writeTokenH() iscalled we are only * 
writing the pre-generated token to the form. The cookie will havealready been 
written. 
**/
 setcookie(token, '', time()-42000); generateToken(); return 
true;}else{ $_SESSION = array();   if 
(isset($_COOKIE[session_name()])) { setcookie(session_name(), '', 
time()-42000); } session_destroy(); header(Location: http://;. 
lg_domain . lg_form_error .?p= . $page .t=ec);}   }else{  return 
True; }}else{ $_SESSION = array(); if 
(isset($_COOKIE[session_name()])) {   setcookie

Re: [PHP] Login In script quesitons

2010-07-09 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278706121.2295.5.ca...@localhost...
 On Fri, 2010-07-09 at 16:04 -0400, Gary wrote:

 ?
 ?php


 That bit of the code has a newline in it, which counts as output :p

 I've not looked over the rest yet, but see if that helps.

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

Ashley

Actually I had added that closing and opening tag in trying to solve the 
problem, I put it back and still have the issue.

I looked at the code as it looks on the board, would it be easier if I sent 
you the files?

Thanks again.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5266 (20100709) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Login In script quesitons

2010-07-09 Thread Gary
Ashley  Richard

I think I found the issue.

In loginGlobals.php, the error was pointing to line 281, when the code 
stopped and 278. (I know most of the time this just means there is a missing 
bracket or semi-colon in the code), however, what I did is put my curser on 
link 281, backspaced to eliminate white space, and it seems to be working.

I will let you know if this is just premature exhuberation.

Thanks again for all your help.

Gary


Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1278706121.2295.5.ca...@localhost...
 On Fri, 2010-07-09 at 16:04 -0400, Gary wrote:

 ?
 ?php


 That bit of the code has a newline in it, which counts as output :p

 I've not looked over the rest yet, but see if that helps.

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





 __ Information from ESET Smart Security, version of virus 
 signature database 5266 (20100709) __

 The message was checked by ESET Smart Security.

 http://www.eset.com

 



__ Information from ESET Smart Security, version of virus signature 
database 5266 (20100709) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] php -l - does it find *anything*?

2010-07-08 Thread Gary .
On 7/6/10, Per Jessen wrote:
 It really is _only_ the syntax. Same goes for e.g. the C lint -

Sorry, but that's not what I remember from my C days, nor what wikipedia
says lint was the name originally given to a particular program that
flagged some suspicious and non-portable constructs (likely to be bugs)
in C language source code. In fact, what would be the point of a C lint
that does that? It's already done by the parsing/syntactical analysis
part of the compiler, there'd be no point writing a separate program
(lint) to do that.

Anyway, yeah, I accept that that (syntax checking only) is what php -l
does, even if I think it's wrong, or at least incorrectly described :)

 --
 Per Jessen, Zürich (24.2°C)

It feels warmer than that today. Maybe it's because my code isn't
working X(

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



[PHP] Simple XML - problem with errors

2010-07-08 Thread Gary .
Why am I still getting an exception when I do this:

libxml_use_internal_errors(true);
$this-xml = new SimpleXMLElement($this-htmlString);

or this
$this-xml = new SimpleXMLElement($this-htmlString,
LIBXML_NOERROR|LIBXML_NOWARNING);

?

The exception says Exception: String could not be parsed as XML. Not
a hint of why not, of course.

I thought the point of those things was to just stuff the content in,
and let user code handle errors? I mean, I *know* the provided HTML is
broken. I also know there's not a chance in hell of it ever being
fixed (completely out of my control).

And yes, I'd rather use DOM, but I can't.

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



Re: [PHP] Simple XML - problem with errors

2010-07-08 Thread Gary .
Richard Quadling writes:
 On 8 July 2010 08:07, Gary wrote:
 Why am I still getting an exception when I do this:

 libxml_use_internal_errors(true);
 $this-xml = new SimpleXMLElement($this-htmlString);

 or this
 $this-xml = new SimpleXMLElement($this-htmlString,
 LIBXML_NOERROR|LIBXML_NOWARNING);

 ?

 The exception says Exception: String could not be parsed as XML.
...
 The XML needs to be well formed [1].

I thought so, thanks. What does libxml_use_internal_errors do then, if
it doesn't allow me to handle those problems in my own code?

 So, if it is junk, you can't
 read it using SimpleXML as the XML is not well formed.

I'm trying to just use xml_parse and so on now.

This problem really should be *so* easy. In fact I've already solved it once X(

 Try putting it through Tidy first - that is, tidy the file first.

Ha ha!

Sorry.

It's almost certainly not available. I don't want to talk about it
*cries*

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



Re: [PHP] Simple XML - problem with errors

2010-07-08 Thread Gary .
Marc Guay writes:
 libxml_use_internal_errors(true);
 $this-xml = new SimpleXMLElement($this-htmlString);

 I have code that looks like this:

 libxml_use_internal_errors(true);
 $xml = simplexml_load_string($val);

Yeah. I tried simplexml_load_string and found that worked (in that it
didn't cause an exception - there are errors which caused the conversion
not to work). I wonder what the difference is between doing new
SimpleXMLElement and calling simplexml_load_string which results in the
libxml_use_internal_errors call being ineffective. Odd.

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



[PHP] Re: Simple XML - problem with errors

2010-07-08 Thread Gary .
Okay. At least one of the problems with this so called HTML seems to
be that the body tag looks like
BODY vlink=#ff ...
and xml_parse complains that  required on that line (i.e. it is
claiming it can't find the end of the tag!).

I'm guessing that those attributes must be quoted in XML and
should be in HTML (but patently aren't)? Is there any way to get
xml_parse to ignore that? My element_handler functions never even get
a chance to see that line.

Regex to insert quotes or remove the attributes entirely, perhaps?
*gulp* I hope there's a better way than that.

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



Re: [PHP] Re: Simple XML - problem with errors

2010-07-08 Thread Gary .
On 7/8/10, Richard Quadling wrote:
 On 8 July 2010 16:15, Gary wrote:
 Okay. At least one of the problems with this so called HTML seems to
 be that the body tag looks like
 BODY vlink=#ff ...
 and xml_parse complains that  required on that line (i.e. it is
 claiming it can't find the end of the tag!).

 I'm guessing that those attributes must be quoted in XML and
 should be in HTML (but patently aren't)? Is there any way to get
 xml_parse to ignore that? My element_handler functions never even get
 a chance to see that line.

 Regex to insert quotes or remove the attributes entirely, perhaps?
 *gulp* I hope there's a better way than that.

 So. Essentially, you want to parse some plain text which may or may
 not be well formed XML.

No. I don't *want* to And it isn't plain text, it's just sh*t html
(no doctype,  missing closing tags in some cases, etc. It's an
absolute mess). Browsers are pretty good at handling it. XML
parsers... less so.

 How badly formed is the file going to be?

It's not a file. It comes from an embedded web server on a device. I
could ask them to change it. I can hear the laughter already.

 If it is things like missing , then this could be managed with regex.
 Essentially you are going to have to do the clean up that Tidy could
 do for you.

Yeah :(

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



Re: [PHP] Simple XML - problem with errors

2010-07-08 Thread Gary .
On 7/8/10, Marc Guay wrote:
 And yes, I'd rather use DOM, but I can't.

 Could you use this: http://simplehtmldom.sourceforge.net/?

Interesting.

Although I can't use DOM or Tidy (because they're normally built in,
but TPTB decided to recompile PHP and exclude them, and I am not
allowed to recompile it with them in), that's external so might be a
possibility.

Thanks.

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



Re: [PHP] Re: Simple XML - problem with errors

2010-07-08 Thread Gary .
On 7/8/10, Nisse Engström wrote:
 On Thu, 8 Jul 2010 17:15:02 +0200, Gary . wrote:

 I'm guessing that those attributes must be quoted in XML and
 should be in HTML (but patently aren't)?

 For that attribute value, it's a must in both cases.

Okay. Please tell L**! :)

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



[PHP] php -l - does it find *anything*?

2010-07-06 Thread Gary .
Or, alternatively put, is there any way to find the kind of problems in
foo2  foo3 (below), at *compile* time?

,[ lint-test.php ]
| ?php
|
| error_reporting(E_ALL | E_STRICT);
|
| function foo1()
| {
| $bar = 'cheese';
| echo $bar;
| }
|
| function foo2()
| {
| $bar = 'cheese';
| echo 'cheese';
| }
|
| function foo3()
| {
| //$bar = 'cheese';
| echo $bar;
| }
|
| foo1();
| foo2();
| foo3();
|
| ?
`

I only get errors displayed when code happens to pass down the code
path, i.e. at runtime:
,
| /home/jg/work $ php -l lint-test.php
| No syntax errors detected in lint-test.php
| /home/jg/work $ php lint-test.php
| cheesecheese
| Notice: Undefined variable: bar in
| /home/jg/work/lint-test.php on line 20
|
| Call Stack:
| 1.  61488   1. {main}()
| /home/jg/work/lint-test.php:0
| 1.  61680   2. foo3()
| /home/jg/work/lint-test.php:25
`

If foo3 never happens to be called when I am doing my testing (for
example if the call is in some if branch that is never exercised) then
it only gets found in production, so I would like to find this kind of
thing using a static analyser. The kind of problem in foo2 I could live
with, but would like to find as well, if possible. (Obviously I am using
these two example problems as indicative of the type of things I want to
find, it isn't an exhaustive list!)

BTW, what problems *does* php -l pick up? I can't find a description
anywhere.

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



Re: [PHP] Question about the Board

2010-07-06 Thread Gary .
On 7/5/10, Gary[1] wrote:
 The last few times I have posted to the board, I recieved an email, which
 has the subject line of  ??? ??? and is written in what appears to
 be greek

Ukrainian or Russian I would guess, looking at the headers.

 Anyone else have this happen?

Yes. Either some spammer harvesting addresses, or some  setting up
filters on his email and getting it wrong.


[1] Another Gary, not this one :)

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



Re: [PHP] php -l - does it find *anything*?

2010-07-06 Thread Gary .
Ashley Sheridan writes:
 On Tue, 2010-07-06 at 10:54 +0200, Gary . wrote:

 If foo3 never happens to be called when I am doing my testing (for
 example if the call is in some if branch that is never exercised) then
 it only gets found in production, so I would like to find this kind of
 thing using a static analyser. The kind of problem in foo2 I could live
 with, but would like to find as well, if possible. (Obviously I am using
 these two example problems as indicative of the type of things I want to
 find, it isn't an exhaustive list!)

 BTW, what problems *does* php -l pick up? I can't find a description
 anywhere.

 According to the man page for php, the -l flag only checks the syntax, so a
 warning wouldn't be displayed, as technically it's not a show-stopper.

Well, I think foo3 is, but yeah, I know what you mean.

 Maybe
 some sort of unit testing would help pick out these sorts of issues?

I do. Actually I posted this by mistake to the phpunit mailing list
first :)

 As PHP
 isn't a compiled language, I guess it's harder for it to pick up on things
 like this.

Yeah. There are static checkers out there, even some FOSS ones. I guess
I'm just a bit frustrated that (as you say) the man page says that -l
checks syntax but doesn't really detail what kind of things that
covers. Actually, I can't even find a decent description of what
E_STRICT covers :( just that Enabling E_STRICT during development has
some benefits. STRICT messages will help you to use the latest and
greatest suggested method of coding, for example warn you about using
deprecated functions.

Some benefits? For example? Telling people exactly what is covered
seems more useful, to me. Meh. Anyway, that's my whine over for the day
:)

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



Re: [PHP] Question about the Board

2010-07-06 Thread Gary .
On 7/6/10, Ashley Sheridan wrote:
 I have had a couple such emails, requesting me to log in somewhere in
 order to have my address 'validated' as non-spam, but I ignored it and
 nothing bad has happened to me yet!

Not yet.

*hides cattle prod behind back*

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



Re: [PHP] Inner join woes... and sweet tea!

2010-07-05 Thread Gary

Richard Quadling rquadl...@gmail.com wrote in message 
news:aanlktinredvfb5cjran9ati-ildvzctlkat-i7amb...@mail.gmail.com...
 On 5 July 2010 14:48, Pete Ford p...@justcroft.com wrote:
 P.S. I don't have an emu.

 Clearly, or you'd know that they can't fly either...
 :)

 GIGO!!!


Does that mean you do have a deathwatch beetle?

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5252 (20100705) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Question about the Board

2010-07-05 Thread Gary
The last few times I have posted to the board, I recieved an email, which 
has the subject line of  ??? ??? and is written in what appears to 
be greek, then english then seemingly some arabic language.  It tells me 
that it has recieved an email from me that it suspects is spam and it has 
held until I confirm the e-mail (which I DO NOT), then my post appears on 
the board. I dont open the email, I view it (if there is a difference) in 
outlook express.

I dont want to post the email address or content, but it does not reference 
the php.net board.

Anyone else have this happen?

Gary






__ Information from ESET Smart Security, version of virus signature 
database 5252 (20100705) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Attachment to email from form.

2010-06-28 Thread Gary
Richard

Thank you again for your kind help.

Gary


Richard Quadling rquadl...@gmail.com wrote in message 
news:aanlktikwujmpbqijd_ee9mbfpxa92ssexjddng2fg...@mail.gmail.com...
 On 26 June 2010 13:14, Gary gp...@paulgdesigns.com wrote:
 Richard

 Please accept my apology in that my response was sent directly to you and
 not the group, I hit 'Reply instead of 'Reply to Group'.

 Gary

 No problem.

 Here is an example of my code using the RMail script from phpguru.org.
 It was previously known as html_mime_mail5.

 ?php
 // Create a new message.
 $o_Mail = new RMail();

 // As we are going to use SMTP to send the email, we need to know
 where to send it.
 // On my setup, the SMTP ini setting is what I'll be using.
 // You can also supply any SMTP AUTH settings needed here.
 $o_Mail-setSMTPParams
 (
 ini_get('SMTP'),
 25,
 Null,
 registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN_REQUIRED),
 registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_LOGIN),
 registrySettings_V2::read(registrySettings_V2::REG_SMTP_AUTH_PASSWORD)
 );


 // Set the From header
 $o_Mail-setHeader('From', 'Richard Quadling r...@nowhere.co.uk');

 // Some other useful headers.
 // $o_Mail-setHeader('Return-Path', 'Return to me
 returnt...@nowhere.co.uk');
 // $o_Mail-setHeader('Return-Receipt-To', 'Delivery Receipt
 deliveryconfirmati...@nowhere.co.uk');
 // $o_Mail-setHeader('Disposition-Notification-To', 'Read or Delete
 Notification disposit...@nowhere.co.uk');

 // Add the subject.
 $o_Mail-setSubject($s_Subject);

 // Add the HTML with a location of the images to be added to the email
 automatically, rather than relying on internet to provide images
 // which is blocked by various security levels of Outlook.
 $o_Mail-setHTML($s_HTMLMessage, 'D:/Global Web Documents/images/');

 // Let's add an attachment.
 // The filename, the mime type, the encoding and the file name to show
 the attachment as.
 $o_Mail-addAttachment(new fileAttachment('D:/Uploaded/content.zip',
 'application/zip', new Base64Encoding(), 'YourContent.zip'));

 // If you want to keep copies of your emails, then setCc is the method to 
 use.
 $o_Mail-setCc('r...@nowhere.co.uk');

 // Finally, send the email to the recipients (held in an array to
 allow for multiple addresses) using SMTP.
 $o_Mail-send(array('Your recipient\'s name
 your_recipient_em...@domain.com'), 'smtp');
 ?


 -- 
 -
 Richard Quadling
 Standing on the shoulders of some very clever giants!
 EE : http://www.experts-exchange.com/M_248814.html
 EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
 Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
 ZOPA : http://uk.zopa.com/member/RQuadling

 __ Information from ESET Smart Security, version of virus 
 signature database 5233 (20100628) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 



__ Information from ESET Smart Security, version of virus signature 
database 5233 (20100628) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Attachment to email from form.

2010-06-26 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1277474393.2787.82.ca...@localhost...
 On Fri, 2010-06-25 at 09:51 -0400, Gary wrote:

 I am trying to have an attachment to an email from a form.  Email is 
 working
 fine, am unable to get attachment. The attachment will be a word.doc.

 I am getting error message

 Warning: file_get_contents(attachment.zip) [function.file-get-contents]:
 failed to open stream: No such file or directory in
 /home/oneonel1/public_html/emailreminderresult.inc.php on line 24
 Mail failed

 Line 24 reads:

 $attachment =
 chunk_split(base64_encode(file_get_contents('attachment.zip')));

 here is the all of the code that I have removed the email addresses  
 such.

 Can someone point me in the right direction?

 Thank you

 Gary

 ?php
 $fname=stripslashes($_POST['fname']);
 $lname=stripslashes($_POST['lname']);
 $email=stripslashes($_POST['email']);
 $comments=stripslashes($_POST['comments']);
 $ip= $_SERVER['REMOTE_ADDR'];
 $attachment = $_POST['attachment'];

 $attachment = $_FILES['attachment']['name'];
 $attachment_type = $_FILES['attachment']['type'];
 $attachment_size = $_FILES['attachment']['size'];

 //create a boundary string. It must be unique
 //so we use the MD5 algorithm to generate a random hash
 $random_hash = md5(date('r', time()));
 //define the headers we want passed. Note that they are separated with 
 \r\n
 $headers = From: myemail\r\nReply-To: myemail.com;
 //add boundary string and mime type specification
 $headers .= \r\nContent-Type: multipart/mixed;
 boundary=\PHP-mixed-.$random_hash.\;
 //read the atachment file contents into a string,
 //encode it with MIME base64,
 //and split it into smaller chunks
 $attachment =
 chunk_split(base64_encode(file_get_contents('attachment.zip'))); //line 
 24
 //define the body of the message.
 ob_start();

 //Turn on output buffering

 //--PHP-mixed-
  echo $random_hash;
 //Content-Type: multipart/alternative; boundary=PHP-alt-
  echo $random_hash;

 //--PHP-alt-
  echo $random_hash;

 /* Content-Type: text/plain; charset=iso-8859-1
 Content-Transfer-Encoding: 7bit */



 //--PHP-alt-
  echo $random_hash;
 /* Content-Type: text/html; charset=iso-8859-1
 Content-Transfer-Encoding: 7bit */


 //--PHP-alt-

  echo $random_hash;

 //--PHP-mixed-


 echo $random_hash;

 /* Content-Type: application/zip; name=attachment.zip
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment  */

  echo $attachment;
 //--PHP-mixed-

  echo $random_hash;


 //copy current buffer contents into $message variable and delete current
 output buffer
 $message = ob_get_clean();
 //send the email
 $mail_sent = @mail( $to, $subject, $message, $headers );
 //if the message is sent successfully print Mail sent. Otherwise print
 Mail failed
 echo $mail_sent ? Mail sent : Mail failed;



 echo Thank you for contacting b888!/bbr /br /;
 echo You have submitted the following information:br /br /;
 echo Name: $fname  $lnamebr /;
 echo E-Mail Address: $emailbr /;
 echo Your comments or request: $commentsbr /br /br /;




  echo We have also sent you an e-mail to $email with the submitted
 information as well as our contact information for your convienience. br
 /br /
  Thank you for the opportunity to serve you!;


 /*This is the email message to submitter*/
 $contact=888\n 888\n 888;
 $from_d=$email;
 $to_d=$email;
 $subject_d='Thank you from 888';
 $msg_d=Thank you $fname for your submission, find our contact 
 information
 listed for your convenience.\n\n
 .$contact\n\n
 . You have submitted the following information\n\n
 . Name:  $fname  $lname \n
 . E-Mail Address: $email\n
 . Comments: $comments\n
 ;
 mail($to_d, $subject_d, $msg_d, 'From:' . $from_d);


 /*this is to form owner, */
 $from=$email;
 $to=myemail;
 $subject=Submission from 888;
 $msg= This is a submission from 888com. \n\n
 . Clients Name: $fname . $lname \n
 . Email Address: $email\n
 . Comments: $comments\n
 ;


 mail($to, $subject, $msg, 'From:' .$from);

 ?



 __ Information from ESET Smart Security, version of virus 
 signature database 5228 (20100625) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



 Your script can't find the attachment.zip file. As you're using a
 relative path to it, it should be in the same directory as your php
 script, or somewhere directly in the path environment variable.

 Also, make sure that the file has read properties set to allow Apache to
 read it.

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

 Ashley

Thank you for your response and I'm sorry for the delay.  I'm not sure I 
understand your answer. I tried changing the 'attahcment.zip' to 
$attachment, even creating a temp folder with reference to the path, however 
it does not seem to work.

Perhaps you could explain a little further?

Again, thank you for your response.

Gary 



__ Information from

Re: [PHP] Attachment to email from form.

2010-06-26 Thread Gary

Bastien Koert phps...@gmail.com wrote in message 
news:aanlktilfxsbs83zaaa6ix32yhurqdg9azd6twq_hn...@mail.gmail.com...
On Fri, Jun 25, 2010 at 9:59 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Fri, 2010-06-25 at 09:51 -0400, Gary wrote:

 I am trying to have an attachment to an email from a form. Email is 
 working
 fine, am unable to get attachment. The attachment will be a word.doc.

 I am getting error message

 Warning: file_get_contents(attachment.zip) [function.file-get-contents]:
 failed to open stream: No such file or directory in
 /home/oneonel1/public_html/emailreminderresult.inc.php on line 24
 Mail failed

 Line 24 reads:

 $attachment =
 chunk_split(base64_encode(file_get_contents('attachment.zip')));

 here is the all of the code that I have removed the email addresses  
 such.

 Can someone point me in the right direction?

 Thank you

 Gary

 ?php
 $fname=stripslashes($_POST['fname']);
 $lname=stripslashes($_POST['lname']);
 $email=stripslashes($_POST['email']);
 $comments=stripslashes($_POST['comments']);
 $ip= $_SERVER['REMOTE_ADDR'];
 $attachment = $_POST['attachment'];

 $attachment = $_FILES['attachment']['name'];
 $attachment_type = $_FILES['attachment']['type'];
 $attachment_size = $_FILES['attachment']['size'];

 //create a boundary string. It must be unique
 //so we use the MD5 algorithm to generate a random hash
 $random_hash = md5(date('r', time()));
 //define the headers we want passed. Note that they are separated with 
 \r\n
 $headers = From: myemail\r\nReply-To: myemail.com;
 //add boundary string and mime type specification
 $headers .= \r\nContent-Type: multipart/mixed;
 boundary=\PHP-mixed-.$random_hash.\;
 //read the atachment file contents into a string,
 //encode it with MIME base64,
 //and split it into smaller chunks
 $attachment =
 chunk_split(base64_encode(file_get_contents('attachment.zip'))); //line 
 24
 //define the body of the message.
 ob_start();

 //Turn on output buffering

 //--PHP-mixed-
 echo $random_hash;
 //Content-Type: multipart/alternative; boundary=PHP-alt-
 echo $random_hash;

 //--PHP-alt-
 echo $random_hash;

 /* Content-Type: text/plain; charset=iso-8859-1
 Content-Transfer-Encoding: 7bit */



 //--PHP-alt-
 echo $random_hash;
 /* Content-Type: text/html; charset=iso-8859-1
 Content-Transfer-Encoding: 7bit */


 //--PHP-alt-

 echo $random_hash;

 //--PHP-mixed-


 echo $random_hash;

 /* Content-Type: application/zip; name=attachment.zip
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment */

 echo $attachment;
 //--PHP-mixed-

 echo $random_hash;


 //copy current buffer contents into $message variable and delete current
 output buffer
 $message = ob_get_clean();
 //send the email
 $mail_sent = @mail( $to, $subject, $message, $headers );
 //if the message is sent successfully print Mail sent. Otherwise print
 Mail failed
 echo $mail_sent ? Mail sent : Mail failed;



 echo Thank you for contacting b888!/bbr /br /;
 echo You have submitted the following information:br /br /;
 echo Name: $fname $lnamebr /;
 echo E-Mail Address: $emailbr /;
 echo Your comments or request: $commentsbr /br /br /;




 echo We have also sent you an e-mail to $email with the submitted
 information as well as our contact information for your convienience. br
 /br /
 Thank you for the opportunity to serve you!;


 /*This is the email message to submitter*/
 $contact=888\n 888\n 888;
 $from_d=$email;
 $to_d=$email;
 $subject_d='Thank you from 888';
 $msg_d=Thank you $fname for your submission, find our contact 
 information
 listed for your convenience.\n\n
 .$contact\n\n
 . You have submitted the following information\n\n
 . Name: $fname $lname \n
 . E-Mail Address: $email\n
 . Comments: $comments\n
 ;
 mail($to_d, $subject_d, $msg_d, 'From:' . $from_d);


 /*this is to form owner, */
 $from=$email;
 $to=myemail;
 $subject=Submission from 888;
 $msg= This is a submission from 888com. \n\n
 . Clients Name: $fname . $lname \n
 . Email Address: $email\n
 . Comments: $comments\n
 ;


 mail($to, $subject, $msg, 'From:' .$from);

 ?



 __ Information from ESET Smart Security, version of virus 
 signature database 5228 (20100625) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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



 Your script can't find the attachment.zip file. As you're using a
 relative path to it, it should be in the same directory as your php
 script, or somewhere directly in the path environment variable.

 Also, make sure that the file has read properties set to allow Apache to
 read it.

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




Consider using something like phpmailer to handle the emails. Makes
attaching things really simple.

http://phpmailer.worxware.com/

-- 

Bastien

Cat, the other other white meat



Bastien

How could anyone not love your advice when you seem to enjoy cats so much! 
I did download

[PHP] in_array - what the...

2010-06-25 Thread Gary .
If I have an array that looks like
  array(1) {
[mac_address]=
string(2) td
  }

and I call
  if (in_array($name, self::$aboveArray))
with $name as
  string(11) mac_address

what should be the result?

Because it is *false* and it is driving me nuts! This despite the fact
that if I do
  $foo = self::$aboveArray[$name];
$foo then has the value
  string(2) td

Am I not understanding what in_array does? Is there some bug in php that
has been present since 5.2.12 and still is? *bangs head against desk*

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



Re: [PHP] in_array - what the...

2010-06-25 Thread Gary .
Ford, Mike writes:
 -Original Message-
 If I have an array that looks like
   array(1) {
 [mac_address]=
 string(2) td
   }

 and I call
   if (in_array($name, self::$aboveArray))
 with $name as
   string(11) mac_address

 what should be the result?

 FALSE -- in_array checks the *values*, not the keys, so would be
 looking at the td for this element.

Agh! So it does.

You know what's worse? I even looked at the documentation of the
function this morning wondering if that's what the problem was and
*still* didn't see it!

*slinks away in embarrassment*

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



[PHP] Attachment to email from form.

2010-06-25 Thread Gary
I am trying to have an attachment to an email from a form.  Email is working 
fine, am unable to get attachment. The attachment will be a word.doc.

I am getting error message

Warning: file_get_contents(attachment.zip) [function.file-get-contents]: 
failed to open stream: No such file or directory in 
/home/oneonel1/public_html/emailreminderresult.inc.php on line 24
Mail failed

Line 24 reads:

$attachment = 
chunk_split(base64_encode(file_get_contents('attachment.zip')));

here is the all of the code that I have removed the email addresses  such.

Can someone point me in the right direction?

Thank you

Gary

?php
$fname=stripslashes($_POST['fname']);
$lname=stripslashes($_POST['lname']);
$email=stripslashes($_POST['email']);
$comments=stripslashes($_POST['comments']);
$ip= $_SERVER['REMOTE_ADDR'];
$attachment = $_POST['attachment'];

$attachment = $_FILES['attachment']['name'];
$attachment_type = $_FILES['attachment']['type'];
$attachment_size = $_FILES['attachment']['size'];

//create a boundary string. It must be unique
//so we use the MD5 algorithm to generate a random hash
$random_hash = md5(date('r', time()));
//define the headers we want passed. Note that they are separated with \r\n
$headers = From: myemail\r\nReply-To: myemail.com;
//add boundary string and mime type specification
$headers .= \r\nContent-Type: multipart/mixed; 
boundary=\PHP-mixed-.$random_hash.\;
//read the atachment file contents into a string,
//encode it with MIME base64,
//and split it into smaller chunks
$attachment = 
chunk_split(base64_encode(file_get_contents('attachment.zip'))); //line 24
//define the body of the message.
ob_start();

//Turn on output buffering

//--PHP-mixed-
 echo $random_hash;
//Content-Type: multipart/alternative; boundary=PHP-alt-
 echo $random_hash;

//--PHP-alt-
 echo $random_hash;

/* Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 7bit */



//--PHP-alt-
 echo $random_hash;
/* Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 7bit */


//--PHP-alt-

 echo $random_hash;

//--PHP-mixed-


echo $random_hash;

/* Content-Type: application/zip; name=attachment.zip
Content-Transfer-Encoding: base64
Content-Disposition: attachment  */

 echo $attachment;
//--PHP-mixed-

 echo $random_hash;


//copy current buffer contents into $message variable and delete current 
output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print Mail sent. Otherwise print 
Mail failed
echo $mail_sent ? Mail sent : Mail failed;



echo Thank you for contacting b888!/bbr /br /;
echo You have submitted the following information:br /br /;
echo Name: $fname  $lnamebr /;
echo E-Mail Address: $emailbr /;
echo Your comments or request: $commentsbr /br /br /;




 echo We have also sent you an e-mail to $email with the submitted 
information as well as our contact information for your convienience. br 
/br /
 Thank you for the opportunity to serve you!;


/*This is the email message to submitter*/
$contact=888\n 888\n 888;
$from_d=$email;
$to_d=$email;
$subject_d='Thank you from 888';
$msg_d=Thank you $fname for your submission, find our contact information 
listed for your convenience.\n\n
.$contact\n\n
. You have submitted the following information\n\n
. Name:  $fname  $lname \n
. E-Mail Address: $email\n
. Comments: $comments\n
;
mail($to_d, $subject_d, $msg_d, 'From:' . $from_d);


/*this is to form owner, */
$from=$email;
$to=myemail;
$subject=Submission from 888;
$msg= This is a submission from 888com. \n\n
. Clients Name: $fname . $lname \n
. Email Address: $email\n
. Comments: $comments\n
;


mail($to, $subject, $msg, 'From:' .$from);

? 



__ Information from ESET Smart Security, version of virus signature 
database 5228 (20100625) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Re: function within a class function

2010-06-21 Thread Gary .
On Mon, Jun 21, 2010 at 10:49 AM, Pete Ford wrote:
 On 21/06/10 00:45, Rick Pasotto wrote:

 I think that's right - doesn't the manual describe this sort of thing about
 using callback functions that are class members?

Yes. 
http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback

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



[PHP] PHP Udate MySQL command

2010-06-04 Thread Gary
I am trying to get an update command to work in PHP.  I am able to update 
records going directly to phpmyadmin command line. I have even let it 
produce the php code to insert, but have not been able to get it to work.

I have it stripped down to one command hoping to get it to work then 
replicate entire forms for clients to use direct.I get no error codes, I 
only get my message It did not enter into DB;

Anyone see where I am going wrong?

Gary

!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml;
head
meta http-equiv=Content-Type content=text/html; charset=utf-8 /
titleUntitled Document/title
/head

body
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
testinput name=test type=text /
input name=submit type=submit value=submit /
/form

?php


$batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for board
or die('Error connecting with MySQL Database');

$test=$_POST['test'];

//$sql=update contact set type = \'$test\' where item_id = \'164\'; //this 
is the code created by phpmyadmin

 $sql = INSERT INTO contact  comments, VALUES = $test WHERE contact_id = 
33;

mysql_query($sql,$batchconnetion);

$result = mysql_query($sql,$batchconnetion);

if($result == true) {
   echo Successfully Inserted Records;
   } else {
   echo It did not enter into DB;
}

mysql_close($batchconnetion);

?


/body
/html 



__ Information from ESET Smart Security, version of virus signature 
database 5171 (20100604) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] Re: PHP Udate MySQL command

2010-06-04 Thread Gary

Sorry, just noticed that I had this line in the post.  (should not post 
before coffee).

 $sql = INSERT INTO contact  comments, VALUES = $test WHERE contact_id = 
 33;

It is supposed to be

$sql = UPDATE contact comments = '$test' WHERE contact_id = '33'


Gary gwp...@ptd.net wrote in message 
news:49.e6.07323.599d8...@pb1.pair.com...
I am trying to get an update command to work in PHP.  I am able to update 
records going directly to phpmyadmin command line. I have even let it 
produce the php code to insert, but have not been able to get it to work.

 I have it stripped down to one command hoping to get it to work then 
 replicate entire forms for clients to use direct.I get no error codes, I 
 only get my message It did not enter into DB;

 Anyone see where I am going wrong?

 Gary

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 meta http-equiv=Content-Type content=text/html; charset=utf-8 /
 titleUntitled Document/title
 /head

 body
 form action=?php echo $_SERVER['PHP_SELF']; ? method=post
 testinput name=test type=text /
 input name=submit type=submit value=submit /
 /form

 ?php


 $batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for 
 board
 or die('Error connecting with MySQL Database');

 $test=$_POST['test'];

 //$sql=update contact set type = \'$test\' where item_id = \'164\'; 
 //this is the code created by phpmyadmin

 $sql = INSERT INTO contact  comments, VALUES = $test WHERE contact_id = 
 33;

 mysql_query($sql,$batchconnetion);

 $result = mysql_query($sql,$batchconnetion);

 if($result == true) {
   echo Successfully Inserted Records;
   } else {
   echo It did not enter into DB;
 }

 mysql_close($batchconnetion);

 ?


 /body
 /html


 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com



 



__ Information from ESET Smart Security, version of virus signature 
database 5171 (20100604) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



[PHP] xml_set_element_handler and equivalents

2010-06-04 Thread Gary .
I need to do essentially do what can be found in the XML Tag Mapping
example (http://www.php.net/manual/en/example.xml-map-tags.php) -
transform the names of some XML elements. Normally I'd use XSLT for
this kind of thing, but due to environmental considerations I can't. I
would prefer to do this in a somewhat OO manner so I can hide this
nastiness from the rest of the code.

Obviously I can't pass any of my XML handler's to
xml_set_element_handler as handlers. Nor can I find a way of
encapsulating the map_array (at least not without duplicating the
map).

Any ideas? Is there an equivalent for DOM or SimpleXML or something?

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



Re: [PHP] PHP Udate MySQL command

2010-06-04 Thread Gary

Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
news:1275649100.2217.45.ca...@localhost...
 On Fri, 2010-06-04 at 06:46 -0400, Gary wrote:

 I am trying to get an update command to work in PHP.  I am able to update
 records going directly to phpmyadmin command line. I have even let it
 produce the php code to insert, but have not been able to get it to work.

 I have it stripped down to one command hoping to get it to work then
 replicate entire forms for clients to use direct.I get no error codes, I
 only get my message It did not enter into DB;

 Anyone see where I am going wrong?

 Gary

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 meta http-equiv=Content-Type content=text/html; charset=utf-8 /
 titleUntitled Document/title
 /head

 body
 form action=?php echo $_SERVER['PHP_SELF']; ? method=post
 testinput name=test type=text /
 input name=submit type=submit value=submit /
 /form

 ?php


 $batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for 
 board
 or die('Error connecting with MySQL Database');

 $test=$_POST['test'];

 //$sql=update contact set type = \'$test\' where item_id = \'164\'; 
 //this
 is the code created by phpmyadmin

  $sql = INSERT INTO contact  comments, VALUES = $test WHERE contact_id =
 33;

 mysql_query($sql,$batchconnetion);

 $result = mysql_query($sql,$batchconnetion);

 if($result == true) {
echo Successfully Inserted Records;
} else {
echo It did not enter into DB;
 }

 mysql_close($batchconnetion);

 ?


 /body
 /html



 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com






 Your problem is the way you're trying to connect to the DB:

 $batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for
 board
 or die('Error connecting with MySQL Database');

 The 4th argument to this function isn't a database name, it's a boolean
 value for whether PHP should create a new link or reuse the old one. You
 have to use the mysql_select_db() function to select the database to use
 on that connection in order for your queries to run the way you have
 them.

 There does seem to be a bit of an inconsistency with the way you're
 using quotation marks on your query strings as well. Your first
 commented out query is escaping the single quotes within a double quoted
 string (which isn't necessary), you've omitted the single quotes on your
 insert line, and then on your amended email you've omitted the double
 quotes. If this is your actual code and not a mistake made when copying
 it into an email, then it would also be a second reason why things
 aren't working as expected even once you get PHP to connect properly.

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





 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com



Ashley

Thank you for your quick reply.

The $batchconnection works fine in numerous other files (the insert files) 
and is a c/p from one of those files. The db noted in my post was just to 
specify that the name of the database at this point, I thought it was a 
standard practice.  I will try your suggestion.

I will admit that I dont have the full grasp of the quotes, single or 
double.  Typically in a mysql command I start with a , however if I get a 
script that is not working, I will try to resolve the issue with switching 
up the singles with the doubles as well and adding parenthsis.

The mistake in the copying the code was I was trying to see if the insert 
command would work in place of the update.it did not..

Aside from that, do you see a problem with my update commands?

Thanks for your help.

gary




__ Information from ESET Smart Security, version of virus signature 
database 5171 (20100604) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] PHP Udate MySQL command Success

2010-06-04 Thread Gary

Gary gwp...@ptd.net wrote in message 
news:a9.ea.07323.381e8...@pb1.pair.com...

 Ashley Sheridan a...@ashleysheridan.co.uk wrote in message 
 news:1275649100.2217.45.ca...@localhost...
 On Fri, 2010-06-04 at 06:46 -0400, Gary wrote:

 I am trying to get an update command to work in PHP.  I am able to 
 update
 records going directly to phpmyadmin command line. I have even let it
 produce the php code to insert, but have not been able to get it to 
 work.

 I have it stripped down to one command hoping to get it to work then
 replicate entire forms for clients to use direct.I get no error codes, I
 only get my message It did not enter into DB;

 Anyone see where I am going wrong?

 Gary

 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 meta http-equiv=Content-Type content=text/html; charset=utf-8 /
 titleUntitled Document/title
 /head

 body
 form action=?php echo $_SERVER['PHP_SELF']; ? method=post
 testinput name=test type=text /
 input name=submit type=submit value=submit /
 /form

 ?php


 $batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for 
 board
 or die('Error connecting with MySQL Database');

 $test=$_POST['test'];

 //$sql=update contact set type = \'$test\' where item_id = \'164\'; 
 //this
 is the code created by phpmyadmin

  $sql = INSERT INTO contact  comments, VALUES = $test WHERE contact_id 
 =
 33;

 mysql_query($sql,$batchconnetion);

 $result = mysql_query($sql,$batchconnetion);

 if($result == true) {
echo Successfully Inserted Records;
} else {
echo It did not enter into DB;
 }

 mysql_close($batchconnetion);

 ?


 /body
 /html



 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com






 Your problem is the way you're trying to connect to the DB:

 $batchconnetion = mysql_connect(host, 'un', 'pw', 'db')//sanatized for
 board
 or die('Error connecting with MySQL Database');

 The 4th argument to this function isn't a database name, it's a boolean
 value for whether PHP should create a new link or reuse the old one. You
 have to use the mysql_select_db() function to select the database to use
 on that connection in order for your queries to run the way you have
 them.

 There does seem to be a bit of an inconsistency with the way you're
 using quotation marks on your query strings as well. Your first
 commented out query is escaping the single quotes within a double quoted
 string (which isn't necessary), you've omitted the single quotes on your
 insert line, and then on your amended email you've omitted the double
 quotes. If this is your actual code and not a mistake made when copying
 it into an email, then it would also be a second reason why things
 aren't working as expected even once you get PHP to connect properly.

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





 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com



 Ashley

 Thank you for your quick reply.

 The $batchconnection works fine in numerous other files (the insert files) 
 and is a c/p from one of those files. The db noted in my post was just to 
 specify that the name of the database at this point, I thought it was a 
 standard practice.  I will try your suggestion.

 I will admit that I dont have the full grasp of the quotes, single or 
 double.  Typically in a mysql command I start with a , however if I get a 
 script that is not working, I will try to resolve the issue with switching 
 up the singles with the doubles as well and adding parenthsis.

 The mistake in the copying the code was I was trying to see if the insert 
 command would work in place of the update.it did not..

 Aside from that, do you see a problem with my update commands?

 Thanks for your help.

 gary




 __ Information from ESET Smart Security, version of virus 
 signature database 5171 (20100604) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





Ashley

Thanks for your input, I think what corrected the problem was I added single
qoutes to the $test variable.

I did also change to your suggestion.

The working code is

body
form action=?php echo $_SERVER['PHP_SELF']; ? method=post
testinput name=test type=text /
input name=submit type=submit value=submit /
/form

?php


$batchconnetion = mysql_connect(sanatized)
or die('Error connecting with MySQL Database');
mysql_select_db('sanatized', $batchconnetion)or die('Error connecting with
MySQL Database2');;
$test=$_POST['test'];

//$sql=update contact set type = \'$test\' where item_id = \'164\';

 $sql = UPDATE contact  SET comments = '$test' WHERE contact_id = 33;

mysql_query($sql,$batchconnetion);


$result

[PHP] Re: xml_set_element_handler and equivalents

2010-06-04 Thread Gary .
On 6/4/10, Gary wrote:
 I need to do essentially do what can be found in the XML Tag Mapping
 example (http://www.php.net/manual/en/example.xml-map-tags.php)
...
 I would prefer to do this in a somewhat OO manner so I can hide this
 nastiness from the rest of the code.

 Obviously I can't pass any of my XML handler's to
 xml_set_element_handler as handlers.

Oh. Hum. Of course, I can (where //... == elided code):
class Foo {
  //...
  public function bar() {
//...
xml_set_element_handler($parser,
  array($this, startElement),
  array($this, endElement));
//...
  }

  public function startElement($parser, $name, $attrs) {
//...
  }
}
So just ignore me, I'm having a bad day.

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



Re: [PHP] Remove blank lines from a file

2010-05-21 Thread Gary
Anton Heuschen writes:

 Hi Im trying do something like this, have a function which uploads my
 file and returns file pointer ... but at same time ... I want to
 remove all Blank lines in a file and update it

sed -i '/^$/d' yourFile

-- 
Gary

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



Re: [PHP] Email from php

2010-05-19 Thread Gary
Ferdi writes:

 I have met with little success sending mail from PHP. I have used mainly the
 mail() function but have also tried imap_mail() which the documentation says
 is just a wrapper around mail().

IMAP is only incoming (at least, the protocol is - the clue is in the
name Internet Message Access Protocol - I can't say anything about
imap_mail). I agree with others, the easiest solution is a local MTA
such as sendmail, or, preferably, something more simple.

 Here is my understanding of the situation:
 On Windows (WampServer 2.0i ) I manage to send email after setting SMTP =
 smtp.someserver.com. I guess this works because the server I use relays all
 mail received; it does not check if the user has been registered or
 not.

Oof. Yes, most remote/ISP MTAs these days will require some kind of
authentication, which is why it is best (IMO) to use a local MTA. It
won't mean you don't have to authenticate to the remote MTA, but it will
push the responsibility of configuring the MTA onto someone who knows
what it's all about.

 On Linux (Centos 5.XX, XAMPP 1.7.2), the above function [mail()] does not
 work. On Linux, what I have understood, is that the smtp server settings in
 php.ini do not matter. The sendmail / mail (something like that)

What happens if you type 'man mail'?

 utility is
 called which sends the mail. I have put in the correct sendmail_path setting
 in php.ini, but, I guess this utility is not configured since I don't
 receive the mail and running the code does not throw up errors or warnings.

You can try sending email from the commandline using 'mail' or even
sendmail, to see if it works.

You could try installing something simple locally (i.e. as your user),
perhaps msmtp, which is a piece of cake to setup, especially compared
with stuff like sendmail (which it is, anyway, compatible with, to a
large extent).

 What I need to achieve is the ability to send attachments in an email from
 PHP. I would like one of the following options (in order of preference):

 1. Create an email account (specifically Google Apps Mail) and send email as
 that user. This will not be trivial. I will need to get a fix on
 authenticating, logging in etc.

A simple config to send mail through Google Apps for Domains via a local
msmtp installation follows:
#--
defaults
host smtp.googlemail.com
tls on
tls_starttls on
port 587
tls_trust_file /home/YOUR_USER/.certs/equifax.pem
tls_cert_file
tls_key_file
auth on
logfile ~/.logfiles/msmtp.log

account foo
from f...@yourdomain
user f...@yourdomain
password YOUR_PASSWORD_HERE
#--

You'll need to get the referenced tls_trust_file but I forget where
from. It will be different anyway, depending on the system - for example
from looking at the msmtp docs it seems you can simply install a package
on Debian.

 3. Configuring the sendmail utility on Linux

From what I remember, I wouldn't recommend sendmail :) It's really
complicated, and probably overkill for what you want.

-- 
Gary

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



[PHP] Generating PHP from WSDL

2010-05-12 Thread Gary .
Let's if anyone can come up with a non-brittle solution to this.

In order to create the framework code for a webservice client I
have generated it from the server's wsdl. Unfortunately the wsdl
(which is out of my control) tries to use extension base=...
to say that 'B' extends/inherits from  'A', and the tool I
use doesn't understand it, with the result that the generated
code doesn't include that relatonship, and so sending a 'B' to
the webservice doesn't work because it doesn't also include the
expected properties of 'A'.

Possible solutions I have thought of are:

* create 'C', inheriting from 'A' and 'B' and send one of those
  instead, but of course php doesn't support multiple-inheritance;

* manually change 'B' so that it does inherit from 'A'. I don't
  like this because if the wsdl changes then that client-side
  code needs to again be changed manually.

* use composition instead. Doesn't seem it will work because the
  marshalling of the objects seems to want to use the properties
  directly (i.e. instead of using getters as it should do).

Does anyone have any other ideas?

Are there any generators out there that handle something like:
s:complexType name=B
 s:complexContent mixed=false
 s:extension base=tns:A
...
/s:complexType
and produce nusoap client code?

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



Re: [PHP] xpath help

2010-05-10 Thread Gary .
On 5/9/10, Peter Lind wrote:
 On 9 May 2010 10:31, Gary wrote:
 If I have a document containing, say:
 html
...

 How do I get at bar2? I tried everything, based on an xpath from
 Firebug (Firefox plugin), but kept getting NULL.


 try //table//font - that should give you all the font elements in
 table elements. Given your layout, you're then looking for
 $list-item(3)

I found out what my problem was. Something, somewhere - the plugin,
Firefox itself, something - decided to help me by inserting TBODY
elements into the xpath which just plain did not exist in the original
HTML.

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



[PHP] xpath help

2010-05-09 Thread Gary
If I have a document containing, say:
html
 body
  table
   tbody
tr
 tdfont ...foo1/font/td
 tdfont ...bar1/font/td
/tr
tr
 td
  font ...foo2/font
 /td
 td
  font ...bar2/font
 /td
/tr
...

How do I get at bar2? I tried everything, based on an xpath from
Firebug (Firefox plugin), but kept getting NULL.

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



Re: [PHP] Any One See where this is going wrong?

2010-05-02 Thread Gary

Adam Richardson simples...@gmail.com wrote in message 
news:aanlktikuqehnrjcannzq8ezvmx5pneg_bjvezglj0...@mail.gmail.com...
 On Sat, May 1, 2010 at 6:54 PM, Gary gwp...@ptd.net wrote:


 Adam Richardson simples...@gmail.com wrote in message
 news:aanlktinqixxb9oipu4op2xztrze_vwpbymaywziwb...@mail.gmail.com...
  
   $sqlStatements = INSERT INTO guns (manufacturer, type, model, 
  caliber,
 
  condition, price, description, image_file_name, available) VALUES
 
  ('$manufacturer',
  '$type',
 
 '$model','$caliber','$condition','$price','$description','$image_file_name','$available');
 
  INSERT INTO images(id, image_file) VALUES ('', '$image_file');
 
 
  Gary, the second insert has what appears to be a troublesome bit of 
  code:
 
  VALUES ('', '$image_file');
 
  Shouldn't it read:
 
  INSERT INTO images(image_file) VALUES ('$image_file');
 
  That's assuming you have id set to auto-increment, so no id in the 
  first
  or
  second set of parentheses.  Additionally, the , before the $image_file
  var
  would cause issues, too.
 
  Adam
  --
  Nephtali:  PHP web framework that functions beautifully
  http://nephtaliproject.com
 
 
 
  __ Information from ESET Smart Security, version of virus
  signature database 5078 (20100501) __
 
  The message was checked by ESET Smart Security.
 
  http://www.eset.com
 
 

 Adam

 The second INSERT is part of a multi_query, and yes there is a
 auto-increment field in front named id,  it is the foreign key that links
 the tables.

 I had removed, and just tried again, but the same result.

 I have tried it so many ways my fingers and eyes are about to bleed. It
 makes not sense how it works in one but not the other.

 I cant see to get the error called out.

 Thanks again.

 Gary




 __ Information from ESET Smart Security, version of virus 
 signature
 database 5078 (20100501) __

 The message was checked by ESET Smart Security.

 http://www.eset.com





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


 And you also removed the double quote and the comma next to it (sorry, 
 just
 making sure?)  That is to say, you copied the line of code I sent?

 $sqlStatements = INSERT INTO guns( *id,*manufacturer, type, model, //
 *id,*should be removed
 caliber, condition, price, description, image_file_name,submitted
 ,available) VALUES ('*',*'$manufacturer', '$type', '$model', '$caliber',
   // the *,* combo should be removed
 '$condition', '$price', '$description','$image_file_name', ' ',
 '$available');

 INSERT INTO images (*id,* image_file) VALUES('','$image_file'); 
 //
 the *id,* should be removed AND the *,* combo should be removed

 Also, have you tried directly echoing out the error (e.g., *echo
 mysql_error();*  if it's mysql you're using, or the comparable method in 
 the
 library you're using.)

 If that didn't work, I'd break up the multi-query into 2 separate queries 
 to
 better troubleshoot the issue.  I like using PDO and setting it up so it
 throws exceptions when something goes wrong (additionally, I like using 
 the
 prepared statements, too.)  Have you been trying that?

 I'm still hopeful you'll get this figured out before there's any 
 blood-loss
 ;)

 Feel free to send back the new code after the edits if you still have
 issues.

 Adam

 -- 
 Nephtali:  PHP web framework that functions beautifully
 http://nephtaliproject.com



 __ Information from ESET Smart Security, version of virus 
 signature database 5078 (20100501) __

 The message was checked by ESET Smart Security.

 http://www.eset.com



Adam

What I ended up doing was I rebuilt the entire thing from start.  I created 
one table with one column, made sure it worked, then added a few more, then 
added the child table.

The only thing that I can think of is that I had one of the columns named 
id, and maybe that is not allowed.

I also just had the form processed on itself, but I cant really imagine that 
would have anything to do with it.

I'll post the code later if interested, I am still adding columns, but the 
child is working so that would seem to be the only real challenge.

Thanks for all your input.

Gary 



__ Information from ESET Smart Security, version of virus signature 
database 5080 (20100502) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



Re: [PHP] Any One See where this is going wrong?

2010-05-01 Thread Gary
Jim

Thanks for your reponse.  With the variable defined. it is supposed to 
reduce the size of the image before upload.

Thanks again.

Gary

Jim Lucas li...@cmsws.com wrote in message 
news:4bdc311b.4060...@cmsws.com...
 Gary wrote:
 I have this duplicate code on another site and it works fine.  The image 
 is uploaded to the images folder, the information is not submitted to the 
 database.  I get the error

 Some Error Occured While Inserting Records

 This is only on a local machine so I have not yet included and safegaurds 
 like stripslashes or my_real_escape_string.

 Thanks for your help

 Gary

 ?php
 if (isset($_POST['submit']))  {
 $manufacturer=($_POST['manufacturer']);
 $type=($_POST['type']);
 $model=($_POST['model']);
 $caliber=($_POST['caliber']);
 $condition=($_POST['condition']);
 $price=($_POST['price']);
 $description=($_POST['description']);
 $image_file_name=($_POST['image_file_name']);
 $image_file=($_FILES['image_file']);
 $available=($_POST['available']);

 $image_file = $_FILES['image_file']['name'];
 $image_type = $_FILES['image_file']['type'];
 $image_size = $_FILES['image_file']['size'];

 include ('includes/connect_local.inc.php');


 Is the following line suppose to be working with a constant or the 
 variable that you defined/extracted just above here?

 if(image_size 300) {

 class ImgResizer {
  private $originalFile = 'image_file';
  public function __construct($originalFile = 'image_file') {
   $this - originalFile = $originalFile;
  }
  public function resize($newWidth, $targetFile) {
   if (empty($newWidth) || empty($targetFile)) {
return false;
   }
   $src = imagecreatefromjpeg($this - originalFile);
   list($width, $height) = getimagesize($this - originalFile);
   $newHeight = ($height / $width) * $newWidth;
   $tmp = imagecreatetruecolor($newWidth, $newHeight);
   imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, 
 $width, $height);
   if (file_exists($targetFile)) {
unlink($targetFile);
   }
   imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 
 0 - 100 for output image quality with 100 being the most luxurious
  }
 }
 }
 if (!empty($type)  !empty($image_file)) {
   if (($image_type == 'image/gif') || ($image_type == 'image/jpeg') 
 || ($image_type == 'image/pjpeg') || ($image_type == 'image/png') 

 By the use of a variable below, I'm guessing it was suppose to be a 
 variable.

 ($image_size 300))  {
 if ($_FILES['image_file']['error'] == 0) {
   // Move the file to the target upload folder
   $target = 'images/' . $image_file;
   if (move_uploaded_file($_FILES['image_file']['tmp_name'], 
 $target)){
 $batchconnection;

  $sqlStatements = INSERT INTO guns( id,manufacturer, type, model, 
 caliber, condition, price, description, image_file_name,submitted 
 ,available) VALUES ('','$manufacturer', '$type', '$model', '$caliber', 
 '$condition', '$price', '$description','$image_file_name', ' ', 
 '$available');

 INSERT INTO images (id, image_file) VALUES('','$image_file');

  $sqlResult = $batchconnection-multi_query($sqlStatements);
if($sqlResult == true) {
echo Successfully Inserted Records;
} else {
echo Some Error Occured While Inserting Records;
 }



}

 }
  }
 }
 mysqli_close($batchconnection);
 }
 ? __ Information from ESET Smart Security, version of virus 
 signature database 5076 (20100430) __

 The message was checked by ESET Smart Security.

 http://www.eset.com







 -- 
 Jim Lucas

 A: Maybe because some people are too annoyed by top-posting.
 Q: Why do I not get an answer to my question(s)?
 A: Because it messes up the order in which people normally read text.
 Q: Why is top-posting such a bad thing?

 __ Information from ESET Smart Security, version of virus 
 signature database 5077 (20100501) __

 The message was checked by ESET Smart Security.

 http://www.eset.com


 



__ Information from ESET Smart Security, version of virus signature 
database 5077 (20100501) __

The message was checked by ESET Smart Security.

http://www.eset.com





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



  1   2   3   4   5   6   >