Re: [PHP] syntax question

2013-07-10 Thread Přemysl Fiala

Hello,

is an alternative syntax.

http://php.net/manual/en/control-structures.alternative-syntax.php

Premek.


On Wed, 10 Jul 2013 13:15:22 +0200, Jim Giner  
jim.gi...@albanyhandball.com wrote:


Can someone tell me what this syntax is?  I looked around but don't see  
any mention of it.


while(condition) : (statement);






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



Re: [PHP] syntax question

2013-07-10 Thread Jim Giner

Thanks!

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-27 Thread Tedd Sperling
On Aug 26, 2012, at 1:36 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 Well, it turns out that I'm just an idiot...
 -- 
 Thanks,
 Ash

That was easy -- anyone of us could have told you that. :-)

Cheers,

tedd

PS: We all have our time in the barrel.

_
t...@sperling.com
http://sperling.com


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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread tamouse mailing lists
On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:

 Can you tell us what is the error shown in browser or CLI?

 On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:

  I've just inherited some (pretty awful code) that I have to make some
  edits to, and came across a bit of a problem. A lot of the code breaks
  in and out of PHP and into HTML code:
 
   ?php
  while(condition)
  {
  ?
  lisome html here/li
  ?php
  }
  ?
 
  But when I check this my PHP parser is saying that this is a syntax
  error (checked in the browser and CLI). I know this is code from a
  working site, so it must be a setting within my PHP configuration.
 
  Now, I'm intending to re-write this anyway, as the logic is all over the
  place (SQL queries within the HTML, no separation of code and content,
  dozens of warnings all over the place) but I was wondering what setting
  causes this. It's mostly a curiosity thing really, as this thing is
  going to be re-written faster than an school project the eve before
  hand-in.
 
  --
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 




 Through the browser I get:

 Parse error: syntax error, unexpected $end
 in /var/www/html/siteinquestion/index.php on line 356

 Through the CLI I get:

 PHP Parse error:  syntax error, unexpected $end in index.php on line 356

 Parse error: syntax error, unexpected $end in index.php on line 356

 Errors parsing index.php

 I've narrowed it down to the lines that used the breaking in and out of
 PHP style. As soon as I comment out those it runs fine, albeit without
 the content that code was intended to add.

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



I guess I would suspect errant spaces, or a missing closing tag, or
even maybe a short code or something... very hard to say...

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Ashley Sheridan
On Sun, 2012-08-26 at 04:36 -0500, tamouse mailing lists wrote:

 On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
  On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:
 
  Can you tell us what is the error shown in browser or CLI?
 
  On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
  a...@ashleysheridan.co.ukwrote:
 
   I've just inherited some (pretty awful code) that I have to make some
   edits to, and came across a bit of a problem. A lot of the code breaks
   in and out of PHP and into HTML code:
  
?php
   while(condition)
   {
   ?
   lisome html here/li
   ?php
   }
   ?
  
   But when I check this my PHP parser is saying that this is a syntax
   error (checked in the browser and CLI). I know this is code from a
   working site, so it must be a setting within my PHP configuration.
  
   Now, I'm intending to re-write this anyway, as the logic is all over the
   place (SQL queries within the HTML, no separation of code and content,
   dozens of warnings all over the place) but I was wondering what setting
   causes this. It's mostly a curiosity thing really, as this thing is
   going to be re-written faster than an school project the eve before
   hand-in.
  
   --
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
  
 
 
 
 
  Through the browser I get:
 
  Parse error: syntax error, unexpected $end
  in /var/www/html/siteinquestion/index.php on line 356
 
  Through the CLI I get:
 
  PHP Parse error:  syntax error, unexpected $end in index.php on line 356
 
  Parse error: syntax error, unexpected $end in index.php on line 356
 
  Errors parsing index.php
 
  I've narrowed it down to the lines that used the breaking in and out of
  PHP style. As soon as I comment out those it runs fine, albeit without
  the content that code was intended to add.
 
  --
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 I guess I would suspect errant spaces, or a missing closing tag, or
 even maybe a short code or something... very hard to say...
 


None of the above. This is a working copy of code. It's just to do with
these lines breaking in and out of PHP.

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




Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Stuart Dallas
On 26 Aug 2012, at 03:56, Ashley Sheridan a...@ashleysheridan.co.uk wrote:

 Through the browser I get:
 
 Parse error: syntax error, unexpected $end
 in /var/www/html/siteinquestion/index.php on line 356
 
 Through the CLI I get:
 
 PHP Parse error:  syntax error, unexpected $end in index.php on line 356
 
 Parse error: syntax error, unexpected $end in index.php on line 356
 
 Errors parsing index.php
 
 I've narrowed it down to the lines that used the breaking in and out of
 PHP style. As soon as I comment out those it runs fine, albeit without
 the content that code was intended to add.


Let me guess, line 356 is the last line of the file? That error is only caused 
by mis-matched braces, so the code you are deleting *must* contain either an 
errant opening brace or be missing a closing brace.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Ashley Sheridan
On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote:

 On 26 Aug 2012, at 03:56, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 
  Through the browser I get:
  
  Parse error: syntax error, unexpected $end
  in /var/www/html/siteinquestion/index.php on line 356
  
  Through the CLI I get:
  
  PHP Parse error:  syntax error, unexpected $end in index.php on line 356
  
  Parse error: syntax error, unexpected $end in index.php on line 356
  
  Errors parsing index.php
  
  I've narrowed it down to the lines that used the breaking in and out of
  PHP style. As soon as I comment out those it runs fine, albeit without
  the content that code was intended to add.
 
 
 Let me guess, line 356 is the last line of the file? That error is only 
 caused by mis-matched braces, so the code you are deleting *must* contain 
 either an errant opening brace or be missing a closing brace.
 
 -Stuart
 
 -- 
 Stuart Dallas
 3ft9 Ltd
 http://3ft9.com/


It is the last line of the file, but it's not caused by a mismatched
brace. I've tested by deleting just the code in the section where it
breaks out of PHP and it runs without errors. It's a very weird issue,
because this is code that is currently working on another server (which
I don't have access to to match my own setup)

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




Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Samuel Lopes Grigolato
Maybe you have a ? inside the HTML code and your php configuration
allows short open tags? In production that setting could be disabled.

On Sun, Aug 26, 2012 at 9:20 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote:

  On 26 Aug 2012, at 03:56, Ashley Sheridan a...@ashleysheridan.co.uk
 wrote:
 
   Through the browser I get:
  
   Parse error: syntax error, unexpected $end
   in /var/www/html/siteinquestion/index.php on line 356
  
   Through the CLI I get:
  
   PHP Parse error:  syntax error, unexpected $end in index.php on line
 356
  
   Parse error: syntax error, unexpected $end in index.php on line 356
  
   Errors parsing index.php
  
   I've narrowed it down to the lines that used the breaking in and out of
   PHP style. As soon as I comment out those it runs fine, albeit without
   the content that code was intended to add.
 
 
  Let me guess, line 356 is the last line of the file? That error is only
 caused by mis-matched braces, so the code you are deleting *must* contain
 either an errant opening brace or be missing a closing brace.
 
  -Stuart
 
  --
  Stuart Dallas
  3ft9 Ltd
  http://3ft9.com/


 It is the last line of the file, but it's not caused by a mismatched
 brace. I've tested by deleting just the code in the section where it
 breaks out of PHP and it runs without errors. It's a very weird issue,
 because this is code that is currently working on another server (which
 I don't have access to to match my own setup)

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





Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Ashley Sheridan
On Sun, 2012-08-26 at 09:21 -0300, Samuel Lopes Grigolato wrote:

 Maybe you have a ? inside the HTML code and your php configuration
 allows short open tags? In production that setting could be disabled.
 
 
 On Sun, Aug 26, 2012 at 9:20 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
 On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote:
 
  On 26 Aug 2012, at 03:56, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
   Through the browser I get:
  
   Parse error: syntax error, unexpected $end
   in /var/www/html/siteinquestion/index.php on line 356
  
   Through the CLI I get:
  
   PHP Parse error:  syntax error, unexpected $end in
 index.php on line 356
  
   Parse error: syntax error, unexpected $end in index.php on
 line 356
  
   Errors parsing index.php
  
   I've narrowed it down to the lines that used the breaking
 in and out of
   PHP style. As soon as I comment out those it runs fine,
 albeit without
   the content that code was intended to add.
 
 
  Let me guess, line 356 is the last line of the file? That
 error is only caused by mis-matched braces, so the code you
 are deleting *must* contain either an errant opening brace or
 be missing a closing brace.
 
  -Stuart
 
  --
  Stuart Dallas
  3ft9 Ltd
  http://3ft9.com/
 
 
 
 
 It is the last line of the file, but it's not caused by a
 mismatched
 brace. I've tested by deleting just the code in the section
 where it
 breaks out of PHP and it runs without errors. It's a very
 weird issue,
 because this is code that is currently working on another
 server (which
 I don't have access to to match my own setup)
 
 
 --
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk
 
 
 
 
 


I don't see any, but it could be something along those lines. I turn off
short open tags on my machine, they cause more problems than they solve,
but it's probable that this setting is enabled on the server.

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




Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Daniel Brown
On Sat, Aug 25, 2012 at 6:54 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 I've just inherited some (pretty awful code) that I have to make some
 edits to, and came across a bit of a problem. A lot of the code breaks
 in and out of PHP and into HTML code:

  ?php
 while(condition)
 {
 ?
 lisome html here/li
 ?php
 }
 ?

 But when I check this my PHP parser is saying that this is a syntax
 error (checked in the browser and CLI). I know this is code from a
 working site, so it must be a setting within my PHP configuration.

 Now, I'm intending to re-write this anyway, as the logic is all over the
 place (SQL queries within the HTML, no separation of code and content,
 dozens of warnings all over the place) but I was wondering what setting
 causes this. It's mostly a curiosity thing really, as this thing is
 going to be re-written faster than an school project the eve before
 hand-in.

If it's not a violation of your arrangement with the owner of the
code, Ash, you can send it to me directly, off-list, and I'll take a
look at it.  I'm curious to see what might be causing the syntax
errors between PHP deployments as well.

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread tamouse mailing lists
On Sun, Aug 26, 2012 at 5:02 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:

 On Sun, 2012-08-26 at 04:36 -0500, tamouse mailing lists wrote:

 On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
  On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:
 
  Can you tell us what is the error shown in browser or CLI?
 
  On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
  a...@ashleysheridan.co.ukwrote:
 
   I've just inherited some (pretty awful code) that I have to make some
   edits to, and came across a bit of a problem. A lot of the code
   breaks
   in and out of PHP and into HTML code:
  
?php
   while(condition)
   {
   ?
   lisome html here/li
   ?php
   }
   ?
  
   But when I check this my PHP parser is saying that this is a syntax
   error (checked in the browser and CLI). I know this is code from a
   working site, so it must be a setting within my PHP configuration.
  
   Now, I'm intending to re-write this anyway, as the logic is all over
   the
   place (SQL queries within the HTML, no separation of code and
   content,
   dozens of warnings all over the place) but I was wondering what
   setting
   causes this. It's mostly a curiosity thing really, as this thing is
   going to be re-written faster than an school project the eve before
   hand-in.
  
   --
   Thanks,
   Ash
   http://www.ashleysheridan.co.uk
  
  
  
 
 
 
 
  Through the browser I get:
 
  Parse error: syntax error, unexpected $end
  in /var/www/html/siteinquestion/index.php on line 356
 
  Through the CLI I get:
 
  PHP Parse error:  syntax error, unexpected $end in index.php on line 356
 
  Parse error: syntax error, unexpected $end in index.php on line 356
 
  Errors parsing index.php
 
  I've narrowed it down to the lines that used the breaking in and out of
  PHP style. As soon as I comment out those it runs fine, albeit without
  the content that code was intended to add.
 
  --
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 

 I guess I would suspect errant spaces, or a missing closing tag, or
 even maybe a short code or something... very hard to say...


 None of the above. This is a working copy of code. It's just to do with
 these lines breaking in and out of PHP.


Byte encodings? Line endings? Sorry, I'm sure you've thought of all this..

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-26 Thread Ashley Sheridan
On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:

 Can you tell us what is the error shown in browser or CLI?
 
 On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:
 
  I've just inherited some (pretty awful code) that I have to make some
  edits to, and came across a bit of a problem. A lot of the code breaks
  in and out of PHP and into HTML code:
 
   ?php
  while(condition)
  {
  ?
  lisome html here/li
  ?php
  }
  ?
 
  But when I check this my PHP parser is saying that this is a syntax
  error (checked in the browser and CLI). I know this is code from a
  working site, so it must be a setting within my PHP configuration.
 
  Now, I'm intending to re-write this anyway, as the logic is all over the
  place (SQL queries within the HTML, no separation of code and content,
  dozens of warnings all over the place) but I was wondering what setting
  causes this. It's mostly a curiosity thing really, as this thing is
  going to be re-written faster than an school project the eve before
  hand-in.
 
  --
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 


Well, it turns out that I'm just an idiot. I'd missed where a couple of
short tags had been used!
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] syntax error breaking in and out of php into html code

2012-08-25 Thread Adam Richardson
On Sat, Aug 25, 2012 at 6:54 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 I've just inherited some (pretty awful code) that I have to make some
 edits to, and came across a bit of a problem. A lot of the code breaks
 in and out of PHP and into HTML code:

  ?php
 while(condition)
 {
 ?
 lisome html here/li
 ?php
 }
 ?

 But when I check this my PHP parser is saying that this is a syntax
 error (checked in the browser and CLI). I know this is code from a
 working site, so it must be a setting within my PHP configuration.

I honestly can't think of a config setting that would cause a syntax
error for this type of example.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

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



Re: [PHP] syntax error breaking in and out of php into html code

2012-08-25 Thread Duken Marga
Can you tell us what is the error shown in browser or CLI?

On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 I've just inherited some (pretty awful code) that I have to make some
 edits to, and came across a bit of a problem. A lot of the code breaks
 in and out of PHP and into HTML code:

  ?php
 while(condition)
 {
 ?
 lisome html here/li
 ?php
 }
 ?

 But when I check this my PHP parser is saying that this is a syntax
 error (checked in the browser and CLI). I know this is code from a
 working site, so it must be a setting within my PHP configuration.

 Now, I'm intending to re-write this anyway, as the logic is all over the
 place (SQL queries within the HTML, no separation of code and content,
 dozens of warnings all over the place) but I was wondering what setting
 causes this. It's mostly a curiosity thing really, as this thing is
 going to be re-written faster than an school project the eve before
 hand-in.

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





-- 
Duken Marga


Re: [PHP] syntax error breaking in and out of php into html code

2012-08-25 Thread Ashley Sheridan
On Sun, 2012-08-26 at 09:41 +0700, Duken Marga wrote:

 Can you tell us what is the error shown in browser or CLI?
 
 On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
 a...@ashleysheridan.co.ukwrote:
 
  I've just inherited some (pretty awful code) that I have to make some
  edits to, and came across a bit of a problem. A lot of the code breaks
  in and out of PHP and into HTML code:
 
   ?php
  while(condition)
  {
  ?
  lisome html here/li
  ?php
  }
  ?
 
  But when I check this my PHP parser is saying that this is a syntax
  error (checked in the browser and CLI). I know this is code from a
  working site, so it must be a setting within my PHP configuration.
 
  Now, I'm intending to re-write this anyway, as the logic is all over the
  place (SQL queries within the HTML, no separation of code and content,
  dozens of warnings all over the place) but I was wondering what setting
  causes this. It's mostly a curiosity thing really, as this thing is
  going to be re-written faster than an school project the eve before
  hand-in.
 
  --
  Thanks,
  Ash
  http://www.ashleysheridan.co.uk
 
 
 
 
 


Through the browser I get:

Parse error: syntax error, unexpected $end
in /var/www/html/siteinquestion/index.php on line 356

Through the CLI I get:

PHP Parse error:  syntax error, unexpected $end in index.php on line 356

Parse error: syntax error, unexpected $end in index.php on line 356

Errors parsing index.php

I've narrowed it down to the lines that used the breaking in and out of
PHP style. As soon as I comment out those it runs fine, albeit without
the content that code was intended to add.

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




Re: [PHP] syntax question

2012-02-07 Thread Louis Huppenbauer
Generally... Wouldn't grouping by an id (which is normally unique) have no
real benefit... Except some strange behaviour?

Just to clarify: Why aren't you sticking to the LIMIT 1?

2012/2/7 ad...@buskirkgraphics.com

 I have been struggling with this issue for an hour and honestly I am not
 sure why.

 I consider myself to be pretty savvy with MySQL but I am running into an
 syntax error that is just flat out eluding me.



 $query = SELECT `table2`.`name` from `table1` ,`table2` WHERE
 `table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
 Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1;

 This query works!!



 But If I try to add a GROUP BY to the query, complete failure.

 $query = SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
 `table2`.`user_id`=`table1`.`seller_id` AND IF(`table2`.`name`='juice','No
 Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY `table1`.`ID`
 LIMIT 1;



 The main goal here is to get only 1 return but MySQL is returning the same
 row 2 times.

 Before I beat my head in anymore I will toss this out to you guys and beat
 myself up later for not drinking enough coffee or something .












RE: [PHP] syntax question

2012-02-07 Thread admin

 -Original Message-
 From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com]
 Sent: Tuesday, February 07, 2012 9:24 AM
 To: ad...@buskirkgraphics.com
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] syntax question
 
 Generally... Wouldn't grouping by an id (which is normally unique) have
 no
 real benefit... Except some strange behaviour?
 
 Just to clarify: Why aren't you sticking to the LIMIT 1?
 
 2012/2/7 ad...@buskirkgraphics.com
 
  I have been struggling with this issue for an hour and honestly I am
 not
  sure why.
 
  I consider myself to be pretty savvy with MySQL but I am running into
 an
  syntax error that is just flat out eluding me.
 
 
 
  $query = SELECT `table2`.`name` from `table1` ,`table2` WHERE
  `table2`.`user_id`=`table1`.`seller_id` AND
 IF(`table2`.`name`='juice','No
  Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1;
 
  This query works!!
 
 
 
  But If I try to add a GROUP BY to the query, complete failure.
 
  $query = SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
  `table2`.`user_id`=`table1`.`seller_id` AND
 IF(`table2`.`name`='juice','No
  Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY
 `table1`.`ID`
  LIMIT 1;
 
 
 
  The main goal here is to get only 1 return but MySQL is returning the
 same
  row 2 times.
 
  Before I beat my head in anymore I will toss this out to you guys and
 beat
  myself up later for not drinking enough coffee or something .
 
 



There is no real reason to have a LIMIT It was just yet another attempt to 
limit the results during the testing.
After reading my post back I see an error in the IF statement but not the 
resolution to the issue.

The IF should read
IF(`table2`.`name`='juice',`table2`.`name`=`table1`.`code`, 
`table2`.`name`=`table1`.`ref`)




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



Re: [PHP] syntax question

2012-02-07 Thread ma...@behnke.biz


ad...@buskirkgraphics.com hat am 7. Februar 2012 um 15:11 geschrieben:

 I have been struggling with this issue for an hour and honestly I am not
 sure why.

 I consider myself to be pretty savvy with MySQL but I am running into an
 syntax error that is just flat out eluding me.

 

 $query = SELECT `table2`.`name` from `table1` ,`table2` WHERE
 `table2`.`user_id`=`table1`.`seller_id` AND
IF(`table2`.`name`='juice','No
 Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1;

 This query works!!

 

 But If I try to add a GROUP BY to the query, complete failure.

 $query = SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
 `table2`.`user_id`=`table1`.`seller_id` AND
IF(`table2`.`name`='juice','No
 Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY `table1`.`ID`
 LIMIT 1;


This is a nice query but I am not sure if I understand what you want to do?
Maybe we could start with your error message and a table structure :-) That
would be handy.

You wanna get all users that have at least on sell? But only once?

Maybe something like that?

SELECT table2.name
FROM
  table2,
  (SELECT seller_id FROM table1 GROUP BY seller_id) as table1
WHERE
  table2.user_id = table1.seller_id
  AND IF(table2.name = 'juice','No Juice for YOU', table2.name =
table2.name)
;




Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

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



RE: [PHP] syntax question

2012-02-07 Thread admin

 -Original Message-
 From: ma...@behnke.biz [mailto:ma...@behnke.biz]
 Sent: Tuesday, February 07, 2012 10:47 AM
 To: php-general@lists.php.net; ad...@buskirkgraphics.com
 Subject: Re: [PHP] syntax question
 
 
 
 ad...@buskirkgraphics.com hat am 7. Februar 2012 um 15:11 geschrieben:
 
  I have been struggling with this issue for an hour and honestly I am
 not
  sure why.
 
  I consider myself to be pretty savvy with MySQL but I am running into
 an
  syntax error that is just flat out eluding me.
 
 
 
  $query = SELECT `table2`.`name` from `table1` ,`table2` WHERE
  `table2`.`user_id`=`table1`.`seller_id` AND
 IF(`table2`.`name`='juice','No
  Juice for YOU', `table2`.`name`=`table2`.`name`) LIMIT 1;
 
  This query works!!
 
 
 
  But If I try to add a GROUP BY to the query, complete failure.
 
  $query = SELECT `table2`.`name`  FROM `table1` ,`table2` WHERE
  `table2`.`user_id`=`table1`.`seller_id` AND
 IF(`table2`.`name`='juice','No
  Juice for YOU', `table2`.`name`=`table2`.`name`) GROUP BY
 `table1`.`ID`
  LIMIT 1;
 
 
 This is a nice query but I am not sure if I understand what you want to
 do?
 Maybe we could start with your error message and a table structure :-)
 That
 would be handy.
 
 You wanna get all users that have at least on sell? But only once?
 
 Maybe something like that?
 
 SELECT table2.name
 FROM
   table2,
   (SELECT seller_id FROM table1 GROUP BY seller_id) as table1
 WHERE
   table2.user_id = table1.seller_id
   AND IF(table2.name = 'juice','No Juice for YOU', table2.name =
 table2.name)
 ;
 
 
 
 
 Marco Behnke
 Dipl. Informatiker (FH), SAE Audio Engineer Diploma
 Zend Certified Engineer PHP 5.3
 
 Tel.: 0174 / 9722336
 e-Mail: ma...@behnke.biz
 
 Softwaretechnik Behnke
 Heinrich-Heine-Str. 7D
 21218 Seevetal
 
 http://www.behnke.biz



Marco,
Thank you but the whole issue stemed from the 2nd table in the FROM.
I just did an inner join using the If statement and it resolved the whole issue.
Maybe it was just a coffee thing because 2 cups later I seen it very clearly :)

Thanks so much.
 



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



Re: [PHP] Syntax problem PDO and bindvalue

2011-12-12 Thread FeIn
I don't think you're suppose to end your queries with a semicolon. Try:

$sql = SELECT * FROM photographs WHERE
 photo_filename LIKE '%2%' LIMIT 0, :q;


On Mon, Dec 12, 2011 at 1:49 PM, Stephen stephe...@rogers.com wrote:

 So I am getting this SQL error:

 Error selecting photographs: SQLSTATE[42000]: Syntax error or access
 violation: 1064 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
 ''4'' at line 2

 My code is:

 function updatephotos($dbh, $x) {

 echo $x['number'] . br /;  this echo is 4

  $sql = SELECT * FROM photographs WHERE
  photo_filename LIKE '%2%' LIMIT 0, :q;;

  $stmt = $dbh-prepare($sql);

  try {

$stmt-bindValue( ':q', $x['number'], PDO::PARAM_INT );
$stmt-execute();

  } catch (PDOException $e) {
return 'Error selecting photographs: ' . $e-getMessage();
}

 while ( list( $id, $name, $alt, $caption) = $stmt-fetch(PDO::FETCH_NUM)) {
 echo $name . br /;
}


  return test worked ;
 }

 If I hard code the SQL as:

 $sql = SELECT * FROM photographs WHERE
  photo_filename LIKE '%2%' LIMIT 0, 4;

 all works well.

 Can anyone see what is wrong?

 How can I see the prepared SQL statement before it is executed?

 Thanks
 Stephen

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




Re: [PHP] Syntax problem PDO and bindvalue

2011-12-12 Thread Fatih P.
On Mon, Dec 12, 2011 at 4:22 PM, FeIn aci...@gmail.com wrote:

 I don't think you're suppose to end your queries with a semicolon. Try:


you can end your queries with semicolon in prepared statements.

How can I see the prepared SQL statement before it is executed?
try-  var_dump ($statement);


RE: [PHP] Syntax Question

2011-08-03 Thread admin
 -Original Message-
 From: Gates, Jeff [mailto:gat...@si.edu]
 Sent: Wednesday, August 03, 2011 10:23 AM
 To: php-general@lists.php.net
 Subject: [PHP] Syntax Question
 
 I, too, am a super newbie. I have a beginning knowledge of being able
 to
 read php and understand its syntax but I can¹t write it. This is a
 bit
 complicated but here¹s my problem:
 
 I want to create a variable in PHP that I can use to link to an image
 in our
 museum's image website. We have done it with ColdFusion here but I need
 the
 same thing for PHP because I¹m building a site using a php-based CMS
 called
 Omeka.
 
 In ColdFusion the variable is written:
 cfset tmpImageDirectory = getToken(artwork.accessionNumber, 1, .)
 
 Basically, it¹s saying find the image on our server by looking for its
 accession number within the year directory. Since the first part of the
 accession number is the year we got the artwork this variable is saying
 look
 for the accession number in the year directory by first looking at the
 first
 part of that accession number (the year), look in that year directory
 and
 then use the entire accession number to find the image within that
 directory.  An example of an accession number is 2011.15. That¹s saying
 that
 artwork was the 15th artwork brought into our collection in 2011. On
 our
 image server it will be found in a directory called 2011. (Am I making
 sense?)
 
 Then the Coldfusion call is:
 
 a
 href=http://ids.si.edu/ids/dynamic?container.fullpageid=http://americ
 anart
 .si.edu/images/#tmpImageDirectory#/#artwork.accessionNumber#_1a.jpg
 (the
 1a.jpg is simply the size image we want to call).
 
 I need to be able to do the same thing with PHP but have no idea how.
 
 More information: within my site I¹m housing the accession number in a
 mySQL
 database. I¹ve gotten a bit of help on this already (but not enough,
 that¹s
 why I¹m turning to you).
 
 I was told I need to create two variables [('Dublin Core','Identifier')
 is
 the name of the field that houses the accession number):
 
 $accessionNumber =  item('Dublin Core','Identifier');
 $tmpImageDirectory = strtok($accessionNumber,.);
 
 And then create a third variable to create a url variable
 
 $url =
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart
 .si.e
 du/images/
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart
 .si.e
 du/images/$tmpImageDirectory/$artwork.accessionNumber_1a.jpg  +
 $tmpImageDirectory + / + $accessionNumber + _1ajpg;
 
 That's as far as I've gotten. I don't know how to put all of these
 together
 using proper PHP syntax. Can someone help me with this? Thanks.
 
 Best, Jeff
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




$url =
http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.si.e
du/images/
http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.si.e
du/images/. $tmpImageDirectory ./. $artwork .accessionNumber_1a.jpg .
$tmpImageDirectory ./. $accessionNumber ._1ajpg;

I am not sure I agree with the way you are setting the $url it looks like
you have mashed and a url hyperlink partially into 1.
Like you are trying to set the $url as a image with a link are you trying to
set a link or an image as the $url?

If you are trying to set a image as the $url do this.

$url = image
src=http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.s
i.edu/images/. $tmpImageDirectory ./. $accessionNumber ._1ajpg ALT='';

Sorry if this is not correct for what you are trying to do. I just do not
understand the intent.















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



Re: [PHP] Syntax Question

2011-08-03 Thread Gates, Jeff
On 8/3/11 10:41 AM, ad...@buskirkgraphics.com ad...@buskirkgraphics.com
wrote:

 -Original Message-
 From: Gates, Jeff [mailto:gat...@si.edu]
 Sent: Wednesday, August 03, 2011 10:23 AM
 To: php-general@lists.php.net
 Subject: [PHP] Syntax Question
 
 I, too, am a super newbie. I have a beginning knowledge of being able
 to
 read php and understand its syntax but I can¹t write it. This is a
 bit
 complicated but here¹s my problem:
 
 I want to create a variable in PHP that I can use to link to an image
 in our
 museum's image website. We have done it with ColdFusion here but I need
 the
 same thing for PHP because I¹m building a site using a php-based CMS
 called
 Omeka.
 
 In ColdFusion the variable is written:
 cfset tmpImageDirectory = getToken(artwork.accessionNumber, 1, .)
 
 Basically, it¹s saying find the image on our server by looking for its
 accession number within the year directory. Since the first part of the
 accession number is the year we got the artwork this variable is saying
 look
 for the accession number in the year directory by first looking at the
 first
 part of that accession number (the year), look in that year directory
 and
 then use the entire accession number to find the image within that
 directory.  An example of an accession number is 2011.15. That¹s saying
 that
 artwork was the 15th artwork brought into our collection in 2011. On
 our
 image server it will be found in a directory called 2011. (Am I making
 sense?)
 
 Then the Coldfusion call is:
 
 a
 href=http://ids.si.edu/ids/dynamic?container.fullpageid=http://americ
 anart
 .si.edu/images/#tmpImageDirectory#/#artwork.accessionNumber#_1a.jpg
 (the
 1a.jpg is simply the size image we want to call).
 
 I need to be able to do the same thing with PHP but have no idea how.
 
 More information: within my site I¹m housing the accession number in a
 mySQL
 database. I¹ve gotten a bit of help on this already (but not enough,
 that¹s
 why I¹m turning to you).
 
 I was told I need to create two variables [('Dublin Core','Identifier')
 is
 the name of the field that houses the accession number):
 
 $accessionNumber =  item('Dublin Core','Identifier');
 $tmpImageDirectory = strtok($accessionNumber,.);
 
 And then create a third variable to create a url variable
 
 $url =
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart
 .si.e
 du/images/
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart
 .si.e
 du/images/$tmpImageDirectory/$artwork.accessionNumber_1a.jpg  +
 $tmpImageDirectory + / + $accessionNumber + _1ajpg;
 
 That's as far as I've gotten. I don't know how to put all of these
 together
 using proper PHP syntax. Can someone help me with this? Thanks.
 
 Best, Jeff
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 $url =
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.si.e
 du/images/
 http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.si.e
 du/images/. $tmpImageDirectory ./. $artwork .accessionNumber_1a.jpg .
 $tmpImageDirectory ./. $accessionNumber ._1ajpg;
 
 I am not sure I agree with the way you are setting the $url it looks like
 you have mashed and a url hyperlink partially into 1.
 Like you are trying to set the $url as a image with a link are you trying to
 set a link or an image as the $url?
 
 If you are trying to set a image as the $url do this.
 
 $url = image
 src=http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.s
 i.edu/images/. $tmpImageDirectory ./. $accessionNumber ._1ajpg ALT='';
 
 Sorry if this is not correct for what you are trying to do. I just do not
 understand the intent.
 

To be honest with you, I'm not sure what that $url is supposed to do. This
is the info (albeit without any explanation) someone told me to use. But he
didn't tell me how to use it.

Basically, I need to be able to link to an image on our web server
dynamically. The structure of the web server is as I described: each image
has an accession number and each image is housed in a directory on that
server that is named the year that artwork was accessioned. We can retrieve
the accession number that is stored in the data field ('Dublin
Core','Identifier')

An example of an actual (non-dynamic) link to the image server might look
like this: 
http://ids.si.edu/ids/dynamic?container.fullpageid=http://americanart.si.ed
u/images/2011/2011.15_1a.jpg

I just need to be able to build that link dynamically for each artwork on
the site. (Personally, I'm not wedded to the code I posted earlier if
someone can find a better way of doing it. This is just what I was told to
use. Again, I'm a newbie.)


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



Re: [PHP] Syntax Error

2010-10-04 Thread kranthi
As pointed out echo $insertSQl should help you locate many trivial
problems. But using PDO will avoid these kind of problems

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



Re: [PHP] Syntax Error

2010-10-04 Thread a...@ashleysheridan.co.uk
Switching to pdo won't necessarily remove sql errors any more than using a php 
framework will remove php errors.

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

- Reply message -
From: kranthi kranthi...@gmail.com
Date: Mon, Oct 4, 2010 09:04
Subject: [PHP] Syntax Error
To: a...@ashleysheridan.co.uk
Cc: chris h chris...@gmail.com, Gary gp...@paulgdesigns.com, 
php-general@lists.php.net


As pointed out echo $insertSQl should help you locate many trivial
problems. But using PDO will avoid these kind of problems

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



Re: [PHP] Syntax Error

2010-10-03 Thread chris h
On Sun, Oct 3, 2010 at 12:47 PM, Gary gp...@paulgdesigns.com wrote:

 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



MySQL is not liking a query.  It looks to be this one:

$insertSQL = sprintf(INSERT INTO family (firstname, lastname, email,
password, relationship, story, image, ip, submitted) VALUES (%s, %s, %s, %s,
%s, %s, %s, %s, %s),

I would echo or log $insertSQL just before you pass it to mysql_query() and
see if the SQL syntax looks right.


Chris.


Re: [PHP] Syntax Error

2010-10-03 Thread Ashley Sheridan
On Sun, 2010-10-03 at 13:14 -0400, chris h wrote:

 On Sun, Oct 3, 2010 at 12:47 PM, Gary gp...@paulgdesigns.com wrote:
 
  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
 
 
 
 MySQL is not liking a query.  It looks to be this one:
 
 $insertSQL = sprintf(INSERT INTO family (firstname, lastname, email,
 password, relationship, story, image, ip, submitted) VALUES (%s, %s, %s, %s,
 %s, %s, %s, %s, %s),
 
 I would echo or log $insertSQL just before you pass it to mysql_query() and
 see if the SQL syntax looks right.
 
 
 Chris.


Does sprintf enclose the replacement strings in single quotes, as I
don't believe it does, so it could be that it is choking on.

Try running the SQL through something like phpMyAdmin, or a dedicated
tool like MySQL Workbench, which should be able to pin-point the issue
if it's not immediately obvious.

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




Re: [PHP] syntax error in class

2010-02-10 Thread Jim Lucas

Dasn wrote:

I got the syntax error. Why?


Read the first paragraph on the following page.

http://us3.php.net/manual/en/language.oop5.properties.php

[quote]
...  This declaration may include an initialization, but this initialization must be a constant 
value--that is, it must be able to be evaluated at compile time and must not depend on run-time 
information in order to be evaluated.

[/quote]

Basically, anything that requires the concatenation of string parts or usage of variables is not 
allowed.


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] syntax error in class

2010-02-10 Thread Eric Lee
2010/2/11 Jim Lucas li...@cmsws.com

 Dasn wrote:

 I got the syntax error. Why?



only constant literal is allowed.
You can think that it is static complie but not on runtime .


Regards,
Eric,




 Read the first paragraph on the following page.

 http://us3.php.net/manual/en/language.oop5.properties.php

 [quote]
 ...  This declaration may include an initialization, but this
 initialization must be a constant value--that is, it must be able to be
 evaluated at compile time and must not depend on run-time information in
 order to be evaluated.
 [/quote]

 Basically, anything that requires the concatenation of string parts or
 usage of variables is not allowed.

 --
 Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

 Twelfth Night, Act II, Scene V
by William Shakespeare


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




RE: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Bob McConnell
From: Miller, Terion

 I'm almost there with my little pagination script but now I'm hung on
the
 Unexpected T_Variable error...which in the past has been a
semi-colon
 missing so I'm not sure why this is throwing it...eyes please:
 
  printf('a 

href=view.php?name=$row['name']b%s/bbr%s/brbr/a',$row['na
me']
 ,$row['address']);

It looks like you have nested single quotes. You probably need to escape
the inside set.

Bob McConnell

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



Re: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Jim Lucas
Miller, Terion wrote:
 I'm almost there with my little pagination script but now I'm hung on the
 Unexpected T_Variable error...which in the past has been a semi-colon
 missing so I'm not sure why this is throwing it...eyes please:
 
  printf('a 
 href=view.php?name=$row['name']b%s/bbr%s/brbr/a',$row['name']
 ,$row['address']);
 
 

The single ticks in your array() variable is causing the problem.

plus, since you are using single quotes for the entire string, the
variable isn't going to be interpreted as a variable.  It will simply
print the string $row['name']

Also, this is the wrong way to use printf().  Please go read the manual
page for this function.

Try:

printf(
'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
$row['name'],
$row['name'],
$row['address']
);

This is the correct way to use printf()


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



Re: [PHP] Syntax Snag need extra eyes (RESOLVED)

2009-07-16 Thread Miller, Terion
Thanks Jim!! I did read the manual and don't get it, like why is printf used 
and not echo...how do you decided which to use?



On 7/16/09 11:25 AM, Jim Lucas li...@cmsws.com wrote:

printf(
'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
$row['name'],
$row['name'],
$row['address']
);


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



Re: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Andrew Ballard
On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas li...@cmsws.com wrote:

 Miller, Terion wrote:
  I'm almost there with my little pagination script but now I'm hung on the
  Unexpected T_Variable error...which in the past has been a semi-colon
  missing so I'm not sure why this is throwing it...eyes please:
 
   printf('a
 
 href=view.php?name=$row['name']b%s/bbr%s/brbr/a',$row['name']
  ,$row['address']);
 
 

 The single ticks in your array() variable is causing the problem.

 plus, since you are using single quotes for the entire string, the
 variable isn't going to be interpreted as a variable.  It will simply
 print the string $row['name']

 Also, this is the wrong way to use printf().  Please go read the manual
 page for this function.

 Try:

 printf(
'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
$row['name'],
$row['name'],
$row['address']
 );

 This is the correct way to use printf()



I like this, just because I don't need to repeat $row['name'] (but it is the
same thing):

printf(
   'a href=view.php?name=%1$sb%1$s/bbr /%2$sbr /br //a',
   $row['name'],
   $row['address']
);

Andrew


Re: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Jim Lucas
Andrew Ballard wrote:
 On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas li...@cmsws.com wrote:
 
 Miller, Terion wrote:
 I'm almost there with my little pagination script but now I'm hung on the
 Unexpected T_Variable error...which in the past has been a semi-colon
 missing so I'm not sure why this is throwing it...eyes please:

  printf('a

 href=view.php?name=$row['name']b%s/bbr%s/brbr/a',$row['name']
 ,$row['address']);


 The single ticks in your array() variable is causing the problem.

 plus, since you are using single quotes for the entire string, the
 variable isn't going to be interpreted as a variable.  It will simply
 print the string $row['name']

 Also, this is the wrong way to use printf().  Please go read the manual
 page for this function.

 Try:

 printf(
'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
$row['name'],
$row['name'],
$row['address']
 );

 This is the correct way to use printf()



 I like this, just because I don't need to repeat $row['name'] (but it is the
 same thing):
 
 printf(
'a href=view.php?name=%1$sb%1$s/bbr /%2$sbr /br //a',
$row['name'],
$row['address']
 );
 
 Andrew
 


I was wondering if that was possible.

Thanks for the tip.

Jim Lucas


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



Re: [PHP] Syntax Snag need extra eyes (RESOLVED)

2009-07-16 Thread Jim Lucas
Miller, Terion wrote:
 Thanks Jim!! I did read the manual and don't get it, like why is printf used 
 and not echo...how do you decided which to use?
 
 
 
 On 7/16/09 11:25 AM, Jim Lucas li...@cmsws.com wrote:
 
 printf(
 'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
 $row['name'],
 $row['name'],
 $row['address']
 );
 

I would say personal preference is the main factor.

I use echo mostly.  Some people like print() and some line printf() 
sprintf().  Probably depends mostly on where you learned to program.

Honestly, echo and print() use the same internal PHP construct.  From
what I understand, one links to the other as an alias or something to
that affect.  Also, the parenthesis are optional when using echo and print.

Back in the day, to be consistent, most people used printf() in C or
other similar programming languages.

Jim Lucas


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



Re: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Bastien Koert
On Thu, Jul 16, 2009 at 12:43 PM, Andrew Ballardaball...@gmail.com wrote:
 On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas li...@cmsws.com wrote:

 Andrew Ballard wrote:
  On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas li...@cmsws.com wrote:
 [snip]
  Also, this is the wrong way to use printf().  Please go read the manual
  page for this function.
 
  Try:
 
  printf(
         'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
         $row['name'],
         $row['name'],
         $row['address']
  );
 
  This is the correct way to use printf()
 
 
 
  I like this, just because I don't need to repeat $row['name'] (but it is 
  the
  same thing):
 
  printf(
         'a href=view.php?name=%1$sb%1$s/bbr /%2$sbr /br 
  //a',
         $row['name'],
         $row['address']
  );
 
  Andrew
 


 I was wondering if that was possible.

 Thanks for the tip.

 Jim Lucas


 That's what I like about this list. I wasn't totally sure it would
 work myself, but I was pretty sure it would, and this was another one
 of those posts that provided just enough prompting for me to actually
 pop the code into Zend Studio where I could test it pretty quickly.
 :-)

 Andrew

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



another option is to wrap the array elements in curly braces

printf('a
href=view.php?name={$row['name']}b%s/bbr%s/brbr/a',$row['name']
,$row['address']);

-- 

Bastien

Cat, the other other white meat

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



Re: [PHP] Syntax Snag need extra eyes

2009-07-16 Thread Jim Lucas
Bastien Koert wrote:
 On Thu, Jul 16, 2009 at 12:43 PM, Andrew Ballardaball...@gmail.com wrote:
 On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas li...@cmsws.com wrote:
 Andrew Ballard wrote:
 On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas li...@cmsws.com wrote:
 [snip]
 Also, this is the wrong way to use printf().  Please go read the manual
 page for this function.

 Try:

 printf(
'a href=view.php?name=%sb%s/bbr /%sbr /br //a',
$row['name'],
$row['name'],
$row['address']
 );

 This is the correct way to use printf()



 I like this, just because I don't need to repeat $row['name'] (but it is 
 the
 same thing):

 printf(
'a href=view.php?name=%1$sb%1$s/bbr /%2$sbr /br 
 //a',
$row['name'],
$row['address']
 );

 Andrew


 I was wondering if that was possible.

 Thanks for the tip.

 Jim Lucas

 That's what I like about this list. I wasn't totally sure it would
 work myself, but I was pretty sure it would, and this was another one
 of those posts that provided just enough prompting for me to actually
 pop the code into Zend Studio where I could test it pretty quickly.
 :-)

 Andrew

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


 
 another option is to wrap the array elements in curly braces
 
 printf('a
 href=view.php?name={$row['name']}b%s/bbr%s/brbr/a',$row['name']
 ,$row['address']);
 

No, that won't work.  The string that it is in, was created using single
quotes.  Therefor the array reference will never be looked at.  It will
simply print the actuall string, not the value associated to the array
reference.

Jim Lucas


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



Re: [PHP] syntax woes

2009-04-03 Thread Michael A. Peters

Jan G.B. wrote:


you don't need the ugly .   . string . merging.


um, I guess most of my code is ugly ;)

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



Re: [PHP] syntax woes

2009-04-03 Thread Jan G.B.
2009/4/3  aurfal...@gmail.com:
 Hi all,

 For any one following this thread, here is how I worked around the
 apache/php/chown limitation.

 script snippet (and if any one has a more elegant style, please share as I
 am an amateur script kiddie).

 $path = /homes.$username;
 $chowncmd = /usr/bin/sudo /bin/chown ;
 mkdir($path);
 chmod($path, 0775);
 exec($chowncmd.$username.  .$path);




OK - you asked for style... ;)
I personally think it's elegant to build such strings with sprintf() like..

$path = sprintf(/homes/%s, $username);
or exec(sprintf(%s %s %s, $chowncmd, $username, $path));

That way you don't need added whitespace on vars like $chowncmd and
you don't need the ugly .   . string . merging.

btw. be sure that you always use
http://php.net/manual/en/function.escapeshellcmd.php as well as
http://php.net/manual/en/function.escapeshellarg.php when dealing with
user inputs and system calls.

byebye




 I modified /etc/sudoers;

 #Defaults requiretty   - I added the comment.
 apache ALL = NOPASSWD: /bin/chown  - added this line.

 - aurf
 On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote:

 Chris wrote:

 Shawn McKenzie wrote:

 Chris wrote:

 Wow, it does chown and chmod as well, thats friggen cool.

 chown will only work if the script is running as root which I doubt
 your
 drupal site will be.


 Or if the script is running as a user/group that has write permissions
 to the dir/file that your trying to chown.

 chmod may allow that, but not chown.

 I believe it depends upon the operating system and version of the
 operating system.

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



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



Re: [PHP] syntax woes

2009-04-03 Thread Shawn McKenzie
Chris wrote:
 Shawn McKenzie wrote:
 Chris wrote:
 Wow, it does chown and chmod as well, thats friggen cool.
 chown will only work if the script is running as root which I doubt your
 drupal site will be.


 Or if the script is running as a user/group that has write permissions
 to the dir/file that your trying to chown.
 
 chmod may allow that, but not chown.
 
 server:~# groupadd test
 server:~# useradd a -g test
 server:~# useradd b -g test
 server:~# mkdir /test
 server:~# chown a.test /test
 server:~# su - a
 No directory, logging in with HOME=/
 a...@server:/$ cd test
 a...@server:/test$ chmod 775 .
 a...@server:/test$ touch a
 a...@server:/test$ chmod 664 a
 a...@server:/test$ chown b.test a
 chown: changing ownership of `a': Operation not permitted
 a...@server:/test$
 
 
Yeah, my bad.  chmod it is...

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] syntax woes

2009-04-02 Thread Chris

aurfal...@gmail.com wrote:

Hi all,

I'm unsure how to describe this but I'll try.

The following code works fine in its own PHP script;

$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);

But when placed in a larger PHP script being part of the 
ldap_provisioning module in Drupal, the Drupal GUI is blank until I do;


$mkdircmd = '/bin/mkdir /homes/'.$uid;

... were I surrounded the variable with , which causes it to not work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/ 
folder (normally the web server would not be able to create such a path 
because of permission issues).


Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for that one.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the  
ldap_provisioning module in Drupal, the Drupal GUI is blank until I  
do;

$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to not  
work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/  
folder (normally the web server would not be able to create such a  
path because of permission issues).


Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for  
that one.


--
Postgresql  php tutorials
http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too  
vague because I don't really understand what I'm doing.


- aurf



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



Re: [PHP] syntax woes

2009-04-02 Thread Ashley Sheridan
On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:
  aurfal...@gmail.com wrote:
  Hi all,
  I'm unsure how to describe this but I'll try.
  The following code works fine in its own PHP script;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  exec($mkdircmd);
  But when placed in a larger PHP script being part of the  
  ldap_provisioning module in Drupal, the Drupal GUI is blank until I  
  do;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  ... were I surrounded the variable with , which causes it to not  
  work.
 
  $mkdircmd = /bin/mkdir /homes/$uid;
  or
  $mkdircmd = /bin/mkdir /homes/${uid};
 
  Should fix the syntax.
 
  I guess you've already solved the permissions problem on the /homes/  
  folder (normally the web server would not be able to create such a  
  path because of permission issues).
 
  Blank GUI - no idea. Anything in the error logs (php or apache) ?
 
  Maybe asking on a drupal specific list would be a better idea for  
  that one.
 
  -- 
  Postgresql  php tutorials
  http://www.designmagick.com/
 
 Thanks Chris.
 
 I appreciate the response.  I was hoping my description wasn't too  
 vague because I don't really understand what I'm doing.
 
 - aurf
 
 
 
This might sound stupid because I've not played with Drupal, but what's
wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the
ldap_provisioning module in Drupal, the Drupal GUI is blank until I
do;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to not
work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the /homes/
folder (normally the web server would not be able to create such a
path because of permission issues).

Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for
that one.

--  
Postgresql  php tutorials

http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too
vague because I don't really understand what I'm doing.

- aurf



This might sound stupid because I've not played with Drupal, but  
what's

wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk



Hi Ash,

I didn't know there was one.

Lemme study it up, thanks for the suggestion.

- aurf

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



Re: [PHP] syntax woes

2009-04-02 Thread Ashley Sheridan
On Thu, 2009-04-02 at 15:58 -0700, aurfal...@gmail.com wrote:
  On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:
  aurfal...@gmail.com wrote:
  Hi all,
  I'm unsure how to describe this but I'll try.
  The following code works fine in its own PHP script;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  exec($mkdircmd);
  But when placed in a larger PHP script being part of the
  ldap_provisioning module in Drupal, the Drupal GUI is blank until I
  do;
  $mkdircmd = '/bin/mkdir /homes/'.$uid;
  ... were I surrounded the variable with , which causes it to not
  work.
 
  $mkdircmd = /bin/mkdir /homes/$uid;
  or
  $mkdircmd = /bin/mkdir /homes/${uid};
 
  Should fix the syntax.
 
  I guess you've already solved the permissions problem on the /homes/
  folder (normally the web server would not be able to create such a
  path because of permission issues).
 
  Blank GUI - no idea. Anything in the error logs (php or apache) ?
 
  Maybe asking on a drupal specific list would be a better idea for
  that one.
 
  --  
  Postgresql  php tutorials
  http://www.designmagick.com/
 
  Thanks Chris.
 
  I appreciate the response.  I was hoping my description wasn't too
  vague because I don't really understand what I'm doing.
 
  - aurf
 
 
 
  This might sound stupid because I've not played with Drupal, but  
  what's
  wrong with using the mkdir command in PHP instead of the exec call?
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 Hi Ash,
 
 I didn't know there was one.
 
 Lemme study it up, thanks for the suggestion.
 
 - aurf
 
PHP can do everything ;)


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

On Thu, 2009-04-02 at 15:58 -0700, aurfal...@gmail.com wrote:

On Thu, 2009-04-02 at 15:47 -0700, aurfal...@gmail.com wrote:

aurfal...@gmail.com wrote:

Hi all,
I'm unsure how to describe this but I'll try.
The following code works fine in its own PHP script;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
exec($mkdircmd);
But when placed in a larger PHP script being part of the
ldap_provisioning module in Drupal, the Drupal GUI is blank  
until I

do;
$mkdircmd = '/bin/mkdir /homes/'.$uid;
... were I surrounded the variable with , which causes it to  
not

work.


$mkdircmd = /bin/mkdir /homes/$uid;
or
$mkdircmd = /bin/mkdir /homes/${uid};

Should fix the syntax.

I guess you've already solved the permissions problem on the / 
homes/

folder (normally the web server would not be able to create such a
path because of permission issues).

Blank GUI - no idea. Anything in the error logs (php or apache) ?

Maybe asking on a drupal specific list would be a better idea for
that one.

--  
Postgresql  php tutorials

http://www.designmagick.com/


Thanks Chris.

I appreciate the response.  I was hoping my description wasn't too
vague because I don't really understand what I'm doing.

- aurf




This might sound stupid because I've not played with Drupal, but
what's
wrong with using the mkdir command in PHP instead of the exec call?


Ash
www.ashleysheridan.co.uk



Hi Ash,

I didn't know there was one.

Lemme study it up, thanks for the suggestion.

- aurf


PHP can do everything ;)


Ash
www.ashleysheridan.co.uk




Wow, it does chown and chmod as well, thats friggen cool.

Ok, then, I'm sold, PHP can do everything...

... but save us from ourselves.  Sorry, I had to kik that in.  Tech  
will be the death of us all, wahahahahaha :)


- aurf




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



Re: [PHP] syntax woes

2009-04-02 Thread Chris



Wow, it does chown and chmod as well, thats friggen cool.


chown will only work if the script is running as root which I doubt your 
drupal site will be.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax woes

2009-04-02 Thread Shawn McKenzie
Chris wrote:
 
 Wow, it does chown and chmod as well, thats friggen cool.
 
 chown will only work if the script is running as root which I doubt your
 drupal site will be.
 

Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] syntax woes

2009-04-02 Thread Chris

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.

chown will only work if the script is running as root which I doubt your
drupal site will be.



Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.


chmod may allow that, but not chown.

server:~# groupadd test
server:~# useradd a -g test
server:~# useradd b -g test
server:~# mkdir /test
server:~# chown a.test /test
server:~# su - a
No directory, logging in with HOME=/
a...@server:/$ cd test
a...@server:/test$ chmod 775 .
a...@server:/test$ touch a
a...@server:/test$ chmod 664 a
a...@server:/test$ chown b.test a
chown: changing ownership of `a': Operation not permitted
a...@server:/test$


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax woes

2009-04-02 Thread Michael A. Peters

Chris wrote:

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.

chown will only work if the script is running as root which I doubt your
drupal site will be.



Or if the script is running as a user/group that has write permissions
to the dir/file that your trying to chown.


chmod may allow that, but not chown.




I believe it depends upon the operating system and version of the 
operating system.


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



Re: [PHP] syntax woes

2009-04-02 Thread aurfalien

Hi all,

For any one following this thread, here is how I worked around the  
apache/php/chown limitation.


script snippet (and if any one has a more elegant style, please share  
as I am an amateur script kiddie).


$path = /homes.$username;
$chowncmd = /usr/bin/sudo /bin/chown ;
mkdir($path);
chmod($path, 0775);
exec($chowncmd.$username.  .$path);


I modified /etc/sudoers;

#Defaults requiretty   - I added the comment.
apache ALL = NOPASSWD: /bin/chown  - added this line.

- aurf
On Apr 2, 2009, at 6:58 PM, Michael A. Peters wrote:


Chris wrote:

Shawn McKenzie wrote:

Chris wrote:

Wow, it does chown and chmod as well, thats friggen cool.
chown will only work if the script is running as root which I  
doubt your

drupal site will be.



Or if the script is running as a user/group that has write  
permissions

to the dir/file that your trying to chown.

chmod may allow that, but not chown.


I believe it depends upon the operating system and version of the  
operating system.


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



Re: [PHP] Syntax checker? Character replacing

2009-03-06 Thread haliphax
On Fri, Mar 6, 2009 at 2:05 PM, Terion Miller webdev.ter...@gmail.com wrote:
 I have this and think maybe something is off, because if there is an amp ()
 in the location then it only displays a comma , and nothing else:

 if (isset($_SERVER['QUERY_STRING'])) {$Page .= ($_SERVER['QUERY_STRING']?
 '?'. str_replace(,amp;,$_SERVER['QUERY_STRING']) : '');}


 is that wrong?

It looks alright to me, but I don't see the need for the in-line
conditional statement since you've already run isset() on
$_SERVER['QUERY_STRING']. Simplify your code:

if(isset($_SERVER['QUERY_STRING']))
$Page .= str_replace('', 'amp;', $_SERVER['QUERY_STRING']);

Does that do the trick?


-- 
// Todd

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



Re: [PHP] Syntax checker? Character replacing

2009-03-06 Thread Adam
just clean up your code and it will work:

?php

$qString = 'http://www.google.ca/search?hl=enq=php+rocks%21%21%21meta=';

if (isset($qString))
{
$buffer = str_replace(,amp;,$qString);
}

echo $buffer.\n;

?

OUTPUT:
C:\php test.php
http://www.google.ca/search?hl=enamp;q=php+rocks%21%21%21amp;meta=

C:\

On Fri, Mar 6, 2009 at 3:05 PM, Terion Miller webdev.ter...@gmail.com wrote:
 I have this and think maybe something is off, because if there is an amp ()
 in the location then it only displays a comma , and nothing else:

 if (isset($_SERVER['QUERY_STRING'])) {$Page .= ($_SERVER['QUERY_STRING']?
 '?'. str_replace(,amp;,$_SERVER['QUERY_STRING']) : '');}


 is that wrong?




-- 
Adi...

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



Re: [PHP] syntax

2009-02-25 Thread Terion Miller


 SELECT something FROM tbl_name
- WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) = date_col;

 Taking that and changing it so it works for you would result in the
 following.

 $query .=  WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) = `stamp`;

 Try that and let us know your results.  */for the archives of course/*

 Jim Lucas


 Well, looking a little closer, you will need to change a little more. Try
 this instead.

 The first should work, but if it doesn't match, try the second.

  WHERE DATE_SUB(NOW(), INTERVAL 7 DAY) = `stamp`;

 or

  WHERE CONVERT(DATE_SUB(NOW(), INTERVAL 7 DAY), DATETIME) = `stamp`;

 also, check these to links out for more information:

 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
 http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html#function_convert


Thanks for the suggestions Jim and everyone
I will be trying them today, I realized yesterday that here I was trying to
write date functions to pull records that were within 7 days which doesn't
really work when the db has JUST been created and only has some fake records
I added in it from the the same day..lol...now I'm wondering if I can put
some in and just put in the mySQL timestamp in the stamp field myself or
basically change it to reflect older records so I can test the stamp
comparisons ...


Re: [PHP] syntax

2009-02-25 Thread Ashley Sheridan
On Wed, 2009-02-25 at 07:17 -0600, Terion Miller wrote:
 
 
  SELECT something FROM tbl_name
 - WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) = date_col;
 
  Taking that and changing it so it works for you would result in the
  following.
 
  $query .=  WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) = `stamp`;
 
  Try that and let us know your results.  */for the archives of course/*
 
  Jim Lucas
 
 
  Well, looking a little closer, you will need to change a little more. Try
  this instead.
 
  The first should work, but if it doesn't match, try the second.
 
   WHERE DATE_SUB(NOW(), INTERVAL 7 DAY) = `stamp`;
 
  or
 
   WHERE CONVERT(DATE_SUB(NOW(), INTERVAL 7 DAY), DATETIME) = `stamp`;
 
  also, check these to links out for more information:
 
  http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
  http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html#function_convert
 
 
 Thanks for the suggestions Jim and everyone
 I will be trying them today, I realized yesterday that here I was trying to
 write date functions to pull records that were within 7 days which doesn't
 really work when the db has JUST been created and only has some fake records
 I added in it from the the same day..lol...now I'm wondering if I can put
 some in and just put in the mySQL timestamp in the stamp field myself or
 basically change it to reflect older records so I can test the stamp
 comparisons ...
Yes you can. I tend to just use phpMyAdmin for stuff like that, as it's
generally quicker to fire that up than write a script and run it!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax

2009-02-25 Thread Rick Duval
 WHERE
  date = DATE_SUB(NOW(), INTERVAL 7 DAY)

Works just fine for me.

R

On Tue, Feb 24, 2009 at 4:15 PM, Terion Miller webdev.ter...@gmail.comwrote:

 Need syntax help when it comes to using a timestamp.
 What I'm trying to say in my query WHERE clause is to select records if the
 timestamp on the record is in the past 7 days from NOW()

 $query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

 the lay language is  WHERE stamp is within the past 7 days how to php
 that? lol
 Thanks
 Terion

 Happy Freecycling
 Free the List !!
 www.freecycle.org
 Over Moderation of Freecycle List Prevents Post Timeliness.
 
 Twitter?
 http://twitter.com/terionmiller
 
 Facebook:
 a href=http://www.facebook.com/people/Terion-Miller/1542024891;
 title=Terion Miller's Facebook profile target=_TOPimg src=
 http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
 alt=Terion Miller's Facebook profile/a
 Vince Lombardi  - Winning is habit. Unfortunately, so is losing.

 --
 This message has been scanned for
 viruses and dangerous content by
 Accurate Anti-Spam Technologies
 and is believed to be clean.
 i...@accurateantispam.com




Re: [PHP] syntax

2009-02-24 Thread Ashley Sheridan
On Tue, 2009-02-24 at 15:15 -0600, Terion Miller wrote:
 Need syntax help when it comes to using a timestamp.
 What I'm trying to say in my query WHERE clause is to select records if the
 timestamp on the record is in the past 7 days from NOW()
 
 $query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 
 
 the lay language is  WHERE stamp is within the past 7 days how to php
 that? lol
 Thanks
 Terion
 
 Happy Freecycling
 Free the List !!
 www.freecycle.org
 Over Moderation of Freecycle List Prevents Post Timeliness.
 
 Twitter?
 http://twitter.com/terionmiller
 
 Facebook:
 a href=http://www.facebook.com/people/Terion-Miller/1542024891;
 title=Terion Miller's Facebook profile target=_TOPimg src=
 http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
 alt=Terion Miller's Facebook profile/a
 Vince Lombardi  - Winning is habit. Unfortunately, so is losing.
I think you should look at the date_add function in mysql

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

they are probably better suited for what you want to do


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] syntax

2009-02-24 Thread Marc Steinert

Terion Miller wrote:


$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 


Try

$query .=  WHERE stamp  SUBDATE(NOW(), INTERVAL -7 DAY);

instead.

Marc


--
http://bithub.net/
Synchronize and share your files over the web for free


My Twitter feed
http://twitter.com/MarcSteinert





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



Re: [PHP] syntax

2009-02-24 Thread Marc Steinert

Marc Steinert wrote:

Terion Miller wrote:


$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 


Try

$query .=  WHERE stamp  SUBDATE(NOW(), INTERVAL -7 DAY);

instead.

Marc



Damn, hit the send-button too fast. Replace -7 with 7. Sry for spamming the 
list.

--
http://bithub.net/
Synchronize and share your files over the web for free


My Twitter feed
http://twitter.com/MarcSteinert





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



Re: [PHP] syntax

2009-02-24 Thread Chris

Terion Miller wrote:

Need syntax help when it comes to using a timestamp.
What I'm trying to say in my query WHERE clause is to select records if the
timestamp on the record is in the past 7 days from NOW()

$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

the lay language is  WHERE stamp is within the past 7 days how to php
that? lol


Has nothing at all to do with php.

http://dev.mysql.com/doc/refman/5.0/en/datetime.html
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax

2009-02-24 Thread Terion Miller
 Has nothing at all to do with php.

 http://dev.mysql.com/doc/refman/5.0/en/datetime.html
 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

 Yeah guess I posted to the wrong list should of been on the php-db list
maybe
but thanks for the suggestions
Marc I'll be trying yours out and also going to try

 *SELECT DATEDIFF('stamp','NOW()')= 7d;   or something somehow like that... *


Re: [PHP] syntax

2009-02-24 Thread Martin Zvarík

Chris napsal(a):

Terion Miller wrote:

Need syntax help when it comes to using a timestamp.
What I'm trying to say in my query WHERE clause is to select records 
if the

timestamp on the record is in the past 7 days from NOW()

$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

the lay language is  WHERE stamp is within the past 7 days how to php
that? lol


Has nothing at all to do with php.

http://dev.mysql.com/doc/refman/5.0/en/datetime.html
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html



$query .=  WHERE stamp  .(time()-7*3600*24);

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



Re: [PHP] syntax

2009-02-24 Thread Jim Lucas
Terion Miller wrote:
 Need syntax help when it comes to using a timestamp.
 What I'm trying to say in my query WHERE clause is to select records if the
 timestamp on the record is in the past 7 days from NOW()
 
 $query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 
 
 the lay language is  WHERE stamp is within the past 7 days how to php
 that? lol
 Thanks
 Terion
 
 Happy Freecycling
 Free the List !!
 www.freecycle.org
 Over Moderation of Freecycle List Prevents Post Timeliness.
 
 Twitter?
 http://twitter.com/terionmiller
 
 Facebook:
 a href=http://www.facebook.com/people/Terion-Miller/1542024891;
 title=Terion Miller's Facebook profile target=_TOPimg src=
 http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
 alt=Terion Miller's Facebook profile/a
 Vince Lombardi  - Winning is habit. Unfortunately, so is losing.
 

Nobody has asked to confirm, but what format is `stamp`?

Unix Timestamp, MySQL Timestamp, MySQL Date stamp???

-- 
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] syntax

2009-02-24 Thread Terion Miller

 Nobody has asked to confirm, but what format is `stamp`?

 Unix Timestamp, MySQL Timestamp, MySQL Date stamp???

 --
 Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

 Twelfth Night, Act II, Scene V
by William Shakespeare

Hi Jim,
stamp is a field in the db and I'm using the NOW() to populate it when a
record is created
and when I echo it to my excel sheet it looks like this:  2/24/2009  2:56:48
PM


Re: [PHP] syntax

2009-02-24 Thread Micah Gersten
Martin Zvarík wrote:
 Chris napsal(a):
 Terion Miller wrote:
 Need syntax help when it comes to using a timestamp.
 What I'm trying to say in my query WHERE clause is to select records
 if the
 timestamp on the record is in the past 7 days from NOW()

 $query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

 the lay language is  WHERE stamp is within the past 7 days how
 to php
 that? lol

 Has nothing at all to do with php.

 http://dev.mysql.com/doc/refman/5.0/en/datetime.html
 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html


 $query .=  WHERE stamp  .(time()-7*3600*24);

Using something like that is disastrous for DST and Leap Seconds...

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com


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



Re: [PHP] syntax

2009-02-24 Thread Martin Zvarík

Micah Gersten napsal(a):

Martin Zvarík wrote:
  

Chris napsal(a):


Terion Miller wrote:
  

Need syntax help when it comes to using a timestamp.
What I'm trying to say in my query WHERE clause is to select records
if the
timestamp on the record is in the past 7 days from NOW()

$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

the lay language is  WHERE stamp is within the past 7 days how
to php
that? lol


Has nothing at all to do with php.

http://dev.mysql.com/doc/refman/5.0/en/datetime.html
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

  

$query .=  WHERE stamp  .(time()-7*3600*24);



Using something like that is disastrous for DST and Leap Seconds...

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
I personally wouldn't even use the timestamp type for this column, but 
'datetime' instead.


Anyway, I don't think he is worried about DST, which I don't think is a 
problem when you have the right settings - nor second precision.




Re: [PHP] syntax

2009-02-24 Thread Chris

Micah Gersten wrote:

Martin Zvarík wrote:

Chris napsal(a):

Terion Miller wrote:

Need syntax help when it comes to using a timestamp.
What I'm trying to say in my query WHERE clause is to select records
if the
timestamp on the record is in the past 7 days from NOW()

$query .=  WHERE stamp  NOW()-7 ;  I have no clue here on this 

the lay language is  WHERE stamp is within the past 7 days how
to php
that? lol

Has nothing at all to do with php.

http://dev.mysql.com/doc/refman/5.0/en/datetime.html
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html


$query .=  WHERE stamp  .(time()-7*3600*24);


Using something like that is disastrous for DST and Leap Seconds...


It was a dig at me for saying it's not php related ;)

(Learning sql still has nothing to do with php).

--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax

2009-02-24 Thread Michael A. Peters

Micah Gersten wrote:




$query .=  WHERE stamp  .(time()-7*3600*24);


Using something like that is disastrous for DST and Leap Seconds...


That's why you use UTC for servers and translate to local time when you 
  need to display it.


Not sure that solves the leap second issue, but it certainly solves the 
DST issue.


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



Re: [PHP] syntax

2009-02-24 Thread Jim Lucas

Terion Miller wrote:

Nobody has asked to confirm, but what format is `stamp`?

Unix Timestamp, MySQL Timestamp, MySQL Date stamp???

--
Jim Lucas

  Some men are born to greatness, some achieve greatness,
  and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
   by William Shakespeare


Hi Jim,
stamp is a field in the db and I'm using the NOW() to populate it when a
record is created
and when I echo it to my excel sheet it looks like this:  2/24/2009  2:56:48
PM



Problem with that example output is, is that a conversion has happened 
somewhere along the way.  I say this because the MySQL timestamp format 
is -MM-DD HH:MM:SS.  And depending on the full settings will 
probably include the GMT offset in there as well.  So, your example is bad.


As for saying that you use NOW() to populate it.  Well, that says to me 
that you at least have something resembling a MySQL timestamp field in 
use.  So, with that said, here is my rendition of what might work for you.


Here is the example that I lifted from the MySQL doc site:

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

SELECT something FROM tbl_name
- WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) = date_col;

Taking that and changing it so it works for you would result in the 
following.


$query .=  WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) = `stamp`;

Try that and let us know your results.  */for the archives of course/*

Jim Lucas

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



Re: [PHP] syntax

2009-02-24 Thread Jim Lucas

Jim Lucas wrote:

Terion Miller wrote:

Nobody has asked to confirm, but what format is `stamp`?

Unix Timestamp, MySQL Timestamp, MySQL Date stamp???

--
Jim Lucas

  Some men are born to greatness, some achieve greatness,
  and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
   by William Shakespeare


Hi Jim,
stamp is a field in the db and I'm using the NOW() to populate it when a
record is created
and when I echo it to my excel sheet it looks like this:  2/24/2009  
2:56:48

PM



Problem with that example output is, is that a conversion has happened 
somewhere along the way.  I say this because the MySQL timestamp format 
is -MM-DD HH:MM:SS.  And depending on the full settings will 
probably include the GMT offset in there as well.  So, your example is bad.


As for saying that you use NOW() to populate it.  Well, that says to me 
that you at least have something resembling a MySQL timestamp field in 
use.  So, with that said, here is my rendition of what might work for you.


Here is the example that I lifted from the MySQL doc site:

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html

SELECT something FROM tbl_name
- WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) = date_col;

Taking that and changing it so it works for you would result in the 
following.


$query .=  WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) = `stamp`;

Try that and let us know your results.  */for the archives of course/*

Jim Lucas



Well, looking a little closer, you will need to change a little more. 
Try this instead.


The first should work, but if it doesn't match, try the second.

 WHERE DATE_SUB(NOW(), INTERVAL 7 DAY) = `stamp`;

or

 WHERE CONVERT(DATE_SUB(NOW(), INTERVAL 7 DAY), DATETIME) = `stamp`;

also, check these to links out for more information:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html#function_convert

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



Re: [PHP] syntax error (stumped)

2008-12-05 Thread Daniel Brown
On Fri, Dec 5, 2008 at 1:31 AM, ddg2sailor [EMAIL PROTECTED] wrote:

 Its begining to look like this code was written for a newer sql
[snip!]

Negative.  It's either a custom function or was written
incorrectly in the first place.  There's never been a native PHP
function `do_mysql_query`, nor was there an `sqlerr` function.
Instead:

?php
mysql_query($sql) or die(mysql_error());
?

 would do the trick.

 Thats all she wrote... instead of do_mysql_query , mysql_query instead.
 Thanks for all your help.. I do however have another issue.. but thats
 another thread.

Good deal.  Glad it's working.

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread Daniel P. Brown
On Thu, Dec 4, 2008 at 8:32 PM, ddg2sailor [EMAIL PROTECTED] wrote:

 This is acctualy a very simple code... But I dont know exactly what to do
 with line 18. It looks to be taking something from dox and redefining it as
 RES. There is some related code but with syntax is pretty much has to be
 this one.
[snip!]

 this is line 18 :  $res = do_mysql_query(SELECT * FROM dox WHERE
 filename=$filename) or sqlerr();

What is the error?

There are a ton of things wrong and bad with that script example,
but for now, is it a customized error output by a user function
`sqlerr` that outputs a MySQL error, or is it saying that
`do_mysql_query` isn't even defined?

-- 
/Daniel P. Brown
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

Sorry , I did mean to mention that... But I forgot.

The original error is :

Fatal error: Call to undefined function do_mysql_query() in
C:\xampp\htdocs\getdox.php on line 18

Something to do with this //  or sqlerr();  //?

Thanks




Daniel P. Brown-2 wrote:
 
 On Thu, Dec 4, 2008 at 8:32 PM, ddg2sailor [EMAIL PROTECTED] wrote:

 This is acctualy a very simple code... But I dont know exactly what to do
 with line 18. It looks to be taking something from dox and redefining it
 as
 RES. There is some related code but with syntax is pretty much has to be
 this one.
 [snip!]

 this is line 18 :  $res = do_mysql_query(SELECT * FROM dox WHERE
 filename=$filename) or sqlerr();
 
 What is the error?
 
 There are a ton of things wrong and bad with that script example,
 but for now, is it a customized error output by a user function
 `sqlerr` that outputs a MySQL error, or is it saying that
 `do_mysql_query` isn't even defined?
 
 -- 
 /Daniel P. Brown
 http://www.parasane.net/
 [EMAIL PROTECTED] || [EMAIL PROTECTED]
 50% Off Hosting! http://www.pilotpig.net/specials.php
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/syntax-error-%28stumped%29-tp20846197p20846336.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread Nathan Nobbe
On Thu, Dec 4, 2008 at 6:44 PM, ddg2sailor [EMAIL PROTECTED] wrote:


 Sorry , I did mean to mention that... But I forgot.

 The original error is :

 Fatal error: Call to undefined function do_mysql_query() in
 C:\xampp\htdocs\getdox.php on line 18


likely something to do w/ do_mysql_query() not being defined ;)
most likely, its in another file that hasnt been included by the time the
invocation is reached.

-nathan


Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

I have been looking at this code all night and at one point I drew the same
conclusion. But I havent been able to find it Il beg the moderators
indulgence here.. But I really do need to add this code which calls the
other code as a user hits a link.

//dox.php//

?
require include/bittorrent.php;

dbconn(false);

loggedinorreturn();

if (get_user_class()  UC_USER)
stderr(Error , Permission denied.);

if ($_SERVER[REQUEST_METHOD] == POST)
{

$file = $_FILES['file'];

if (!$file || $file[size] == 0 || $file[name] == )
stderr(Error, Nothing received! The selected file may have been too
large. );

if (file_exists($DOXPATH/$file[name]))
stderr(Error, A file with the name .htmlspecialchars($file['name']).
already exists! );

$title = trim($_POST[title]);
if ($title == )
{
$title = substr($file[name], 0, strrpos($file[name], .));
if (!$title)
$title = $file[name];
}

$r = mysql_query(SELECT id FROM dox WHERE title= . sqlesc($title)) or
sqlesc();
if (mysql_num_rows($r)  0)
stderr(Error, A file with the title , .htmlspecialchars($title).
already exists!);

$url = $_POST[url];

if ($url != )
if (substr($url, 0, 7) != http://;  substr($url, 0, 6) != ftp://;)
stderr(Error, The URL ,  . htmlspecialchars($url) .  does not seem to
be valid.);

if (!move_uploaded_file($file[tmp_name], $DOXPATH/$file[name]))
stderr(Error, Failed to move uploaded file. You should contact an
administrator about this error.);

setcookie(doxurl, $url, 0x7fff);

$title = sqlesc($title);
$filename = sqlesc($file[name]);

$uppedby = $CURUSER[id];
$size = $file[size];
$url = sqlesc($url);

mysql_query(INSERT INTO dox (title, filename, added, uppedby, size, url)
VALUES($title, $filename, NOW(), $uppedby, $size, $url)) or sqlerr();

header(Location: dox.php);
die;
}

//if (get_user_class() = UC_MODERATOR || $a[uppedby] == 
$CURUSER[id])
//{
$delete = $HTTP_GET_VARS[delete];
if (is_valid_id($delete))
{
$r = mysql_query(SELECT 
filename,uppedby FROM dox WHERE id=$delete)
or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($r) == 1)
{
$a = 
mysql_fetch_assoc($r);
if (get_user_class() = 
UC_MODERATOR || $a[uppedby] ==
$CURUSER[id])
{

mysql_query(DELETE FROM dox WHERE id=$delete) or sqlerr(__FILE__,
__LINE__);
if 
(!unlink($DOXPATH/$a[filename]))

stderr(Warning, Unable to unlink file:, .$a['filename']. 
You should contact an administrator about this error.);
}
}
}
//}

stdhead(Dox);

//print(h1._(Dox)./h1\n);
print(h1Dox/h1\n);

$res = mysql_query(SELECT * FROM dox ORDER BY added DESC) or sqlerr();
if (mysql_num_rows($res) == 0)
print(pSorry, nothing here pal :(/p);
else
{
print(ptable border=1 cellspacing=0 width=750 cellpadding=5\n);
print(trtd class=colhead align=leftTitle/tdtd
class=colheadDate/tdtd class=colheadTime/tdtd
class=colheadSize/tdtd class=colheadHits/tdtd class=colheadUpped
by/td/tr\n);

$mod = get_user_class() = UC_MODERATOR;

while ($arr = mysql_fetch_assoc($res))
{
$r = mysql_query(SELECT username FROM users WHERE id=$arr[uppedby]) or
sqlerr();
$a = mysql_fetch_assoc($r);
$FILELINK = $GLOBALS['DEFAULTBASEURL']./getdox.php/.str_replace( ,%20
, $arr[filename]);
$title = td align=left .$FILELINK.  . $arr[title] .   .
($mod || $arr[uppedby] == $CURUSER[id] ?   ?delete=$arr[id] [Delete] 
: ) ./td\n;
$added = td . substr($arr[added], 0, 10) . /tdtd .
substr($arr[added], 10) . /td\n;
$size = td . mksize($arr['size']) . /td\n;
$hits = td . number_format($arr['hits']) . /td\n;
$uppedby = td .$GLOBALS['DEFAULTBASEURL']. $a[username] /td\n;
print(tr$title$added$size$hits$uppedby/tr\n);
}
print(/table/p\n);
print(pFiles are automatically deleted after 14 days...This is not in
place.../p\n);
}

if (get_user_class() = UC_UPLOADER)
{
$url = $HTTP_COOKIE_VARS[doxurl];
$maxfilesize = ini_get(upload_max_filesize);
begin_main_frame();
begin_frame(Upload, true);
print(form enctype=multipart/form-data method=post action=?\n);
print(table class=main border=1 cellspacing=0 width=700
cellpadding=5\n);
print(trtd class=rowheadFile/tdtd align=leftinput type=file
name=file size=60br(Maximum file size: .$maxfilesize.)/td/tr\n);
print(trtd class=rowheadTitle/tdtd align=leftinput type=text
name=title size=60br(Optional, taken from file name if not
specified.)/td/tr\n);


print(trtd 

Re: [PHP] syntax error (stumped)

2008-12-04 Thread Chris

ddg2sailor wrote:

I have been looking at this code all night and at one point I drew the same
conclusion. But I havent been able to find it Il beg the moderators
indulgence here.. But I really do need to add this code which calls the
other code as a user hits a link.


Find the file where do_mysql_query is defined and include it.

It is not a native php function - someone made it up. Search your code 
for the function.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] syntax error (stumped)

2008-12-04 Thread ddg2sailor

Its begining to look like this code was written for a newer sql

The sysop came up with an older php file that fixxed this issue Samples
enclosed.

//the file I been working on all days - relevant lines only

$filename = sqlesc($filename);
$res = do_mysql_query(SELECT * FROM dox WHERE filename=$filename) or
sqlerr();
$arr = mysql_fetch_assoc($res);

//end

//The swapped out code that works - relevant lines only:

$filename = sqlesc($filename);
$res = mysql_query(SELECT * FROM dox WHERE filename=$filename) or
sqlerr();
$arr = mysql_fetch_assoc($res);

//end

Thats all she wrote... instead of do_mysql_query , mysql_query instead.
Thanks for all your help.. I do however have another issue.. but thats
another thread.

Sailor


chris smith-9 wrote:
 
 ddg2sailor wrote:
 I have been looking at this code all night and at one point I drew the
 same
 conclusion. But I havent been able to find it Il beg the moderators
 indulgence here.. But I really do need to add this code which calls the
 other code as a user hits a link.
 
 Find the file where do_mysql_query is defined and include it.
 
 It is not a native php function - someone made it up. Search your code 
 for the function.
 
 -- 
 Postgresql  php tutorials
 http://www.designmagick.com/
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

-- 
View this message in context: 
http://www.nabble.com/syntax-error-%28stumped%29-tp20846197p20848455.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] syntax error

2008-07-21 Thread Ted Wood


Not a syntax error. It's not successfully connecting to the database.  
Check your settings.


~Ted



On 21-Jul-08, at 4:24 AM, Ronald Wiplinger wrote:


On a system with php4 and mysql 4.x I had these lines:

require(../db-config); // includes $dbhost, $buname, $dbpass
$db = mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname,$db);

   $sql = SELECT * FROM CATEGORY WHERE .;
   $result = mysql_query($sql,$db);
   $num=mysql_num_rows($result);
   while ($myrow = mysql_fetch_array($result)) {


Moving the *.php to a php5 and mysql 5.x site I get these errors:

PHP Warning:  mysql_num_rows(): supplied argument is not a valid MySQL
result resource in ...
PHP Warning:  mysql_fetch_array(): supplied argument is not a valid  
MySQL

result resource in ...


Looking at the manual, I cannot see what I am doing wrong.

bye

R.



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



Re: [PHP] syntax error

2008-07-21 Thread Eric Butera
On Mon, Jul 21, 2008 at 7:24 AM, Ronald Wiplinger [EMAIL PROTECTED] wrote:
 On a system with php4 and mysql 4.x I had these lines:

 require(../db-config); // includes $dbhost, $buname, $dbpass
 $db = mysql_connect($dbhost, $dbuname, $dbpass);
 mysql_select_db($dbname,$db);

$sql = SELECT * FROM CATEGORY WHERE .;
$result = mysql_query($sql,$db);
$num=mysql_num_rows($result);
while ($myrow = mysql_fetch_array($result)) {
 

 Moving the *.php to a php5 and mysql 5.x site I get these errors:

 PHP Warning:  mysql_num_rows(): supplied argument is not a valid MySQL
 result resource in ...
 PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL
 result resource in ...


 Looking at the manual, I cannot see what I am doing wrong.

 bye

 R.


Your mysql_connect is probably failing.  Look at your error log or
look at mysql_error() for a reason why.

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



Re: [PHP] syntax error

2008-07-21 Thread Aschwin Wesselius

Eric Butera wrote:

On Mon, Jul 21, 2008 at 7:24 AM, Ronald Wiplinger [EMAIL PROTECTED] wrote:
  

On a system with php4 and mysql 4.x I had these lines:

require(../db-config); // includes $dbhost, $buname, $dbpass
$db = mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db($dbname,$db);

   $sql = SELECT * FROM CATEGORY WHERE .;
   $result = mysql_query($sql,$db);
   $num=mysql_num_rows($result);
   while ($myrow = mysql_fetch_array($result)) {


Moving the *.php to a php5 and mysql 5.x site I get these errors:

PHP Warning:  mysql_num_rows(): supplied argument is not a valid MySQL
result resource in ...
PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in ...


Looking at the manual, I cannot see what I am doing wrong.

bye

R.




Your mysql_connect is probably failing.  Look at your error log or
look at mysql_error() for a reason why.


Probably the mysql extension is not found or not loaded (due to not 
being compiled with the right path or the default path in PHP is not the 
right one). Happened to me a couple of times.



--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] syntax error

2008-07-21 Thread Eric Butera
On Mon, Jul 21, 2008 at 7:55 AM, Aschwin Wesselius
[EMAIL PROTECTED] wrote:
 Eric Butera wrote:

 On Mon, Jul 21, 2008 at 7:24 AM, Ronald Wiplinger [EMAIL PROTECTED]
 wrote:


 On a system with php4 and mysql 4.x I had these lines:

 require(../db-config); // includes $dbhost, $buname, $dbpass
 $db = mysql_connect($dbhost, $dbuname, $dbpass);
 mysql_select_db($dbname,$db);

$sql = SELECT * FROM CATEGORY WHERE .;
$result = mysql_query($sql,$db);
$num=mysql_num_rows($result);
while ($myrow = mysql_fetch_array($result)) {
 

 Moving the *.php to a php5 and mysql 5.x site I get these errors:

 PHP Warning:  mysql_num_rows(): supplied argument is not a valid MySQL
 result resource in ...
 PHP Warning:  mysql_fetch_array(): supplied argument is not a valid MySQL
 result resource in ...


 Looking at the manual, I cannot see what I am doing wrong.

 bye

 R.



 Your mysql_connect is probably failing.  Look at your error log or
 look at mysql_error() for a reason why.

 Probably the mysql extension is not found or not loaded (due to not being
 compiled with the right path or the default path in PHP is not the right
 one). Happened to me a couple of times.


 --

 Aschwin Wesselius

 'What you would like to be done to you, do that to the other'


Wouldn't that be  call to undefined function then?

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



Re: [PHP] syntax error

2008-07-21 Thread Aschwin Wesselius

Eric Butera wrote:

On Mon, Jul 21, 2008 at 7:55 AM, Aschwin Wesselius
[EMAIL PROTECTED] wrote:
  

Probably the mysql extension is not found or not loaded (due to not being
compiled with the right path or the default path in PHP is not the right
one). Happened to me a couple of times.


--

Aschwin Wesselius

'What you would like to be done to you, do that to the other'




Wouldn't that be  call to undefined function then?


Oh my. I'm so sorry. You're absolutely right. I mixed these two. I'm 
a bit side-tracked today.


Thanks for pointing that out.


--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] syntax error

2008-07-21 Thread Eric Butera
On Mon, Jul 21, 2008 at 8:32 AM, Aschwin Wesselius
[EMAIL PROTECTED] wrote:
 Oh my. I'm so sorry. You're absolutely right. I mixed these two. I'm a
 bit side-tracked today.

 Thanks for pointing that out.


 --

 Aschwin Wesselius


It's no problem, I got scared I was spreading propaganda!  hehe :)

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



Re: [PHP] syntax error

2008-07-21 Thread Daniel Brown
On Mon, Jul 21, 2008 at 7:24 AM, Ronald Wiplinger [EMAIL PROTECTED] wrote:

Try this:

$result = mysql_query($sql,$db) or die(mysql_error());

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] syntax error

2008-07-21 Thread Daniel Brown
Please keep replies on list for all to benefit and be able to assist.

On Mon, Jul 21, 2008 at 5:47 PM, Ronald Wiplinger [EMAIL PROTECTED] wrote:

 On Tue, Jul 22, 2008 at 1:51 AM, Daniel Brown [EMAIL PROTECTED] wrote:

Try this:

 $result = mysql_query($sql,$db) or die(mysql_error());

Did you try my suggestion above?  If so, did you receive any errors?

 echo result=$resultbr;
 $num=mysql_num_rows($result);
 echo num=$num;

 I get:

 result=
 num=

The most you'd get from $result in this case would be a resource
identifier message, because that's all mysql_query() returns.  And
since the resource link doesn't seem to be correctly established, $num
will be empty.

-- 
/Daniel P. Brown
Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] syntax of sprintf

2008-05-20 Thread Chris

 the select query is
 
 $selectqueryusername = sprintf(Select username from individuals where
 username='%s', mysql_real_escape_string($username));

The syntax is fine.

$result = mysql_query($selectqueryusername);
if (!$result) {
  echo Error! ***  . mysql_error();
}


 also for insert query if i have a numeric value i should be writting %d
 correct, i have a numeric value however before inserting that
 numeric value i am appending a character - to combine area code and phone
 number example 09-123 4567 so i am considering this as %s as there is a
 character. is this correct.

Yes.

The placeholders are all documented pretty well:

http://www.php.net/sprintf

-- 
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] syntax of sprintf

2008-05-18 Thread Ólafur Waage
Try this one

$sSQL = sprintf(SELECT username FROM individuals WHERE
username='%s', mysql_real_escape_string($username));
$query = mysql_query($sSQL);
if($query !== false)
{
// do something
}

2008/5/18 Sudhakar [EMAIL PROTECTED]:
 until i started using the techniques for avoiding sql injection, i have been
 using a normal insert and select sql query which worked fine.

 i have a registration page where a user enters their username and if this
 already exists i display a message by executing a select query and if the
 username does not exist then i run an insert query.

 after adopting the technique to avoid sql injection

 if(get_magic_quotes_gpc())
 {
 $username = stripslashes($_POST[username]);
 $email =stripslashes($_POST[email]);
 }
 else
 {
 $username = $_POST[username];
 $email =$_POST[email];
 }

 previously my select and insert query were

 INSERT INTO individuals(username, email) values('$username', '$email')
 Select username from individuals where username = '$username'

 presently the insert query is

 $insertquery = sprintf(INSERT INTO individuals (username, email) VALUES
 ('%s', '%s'),
 mysql_real_escape_string($username), mysql_real_escape_string($email));

 This insert query is working however the select query is not doing its task
 as before of checking if the username already exists or not, even if i
 register with the same username again it does not alert that the username
 exists.

 the select query is

 $selectqueryusername = sprintf(Select username from individuals where
 username='%s', mysql_real_escape_string($username));

 should i change the syntax of the above select query or is there something
 else in need to do to fix the select query.

 please advice.

 thanks.


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



Re: [PHP] syntax question

2007-03-26 Thread cajbecu
Ross wrote:
 Can I put post values directly into insert statements?
 
 $query = INSERT INTO categories (category_name) VALUES 
 ('$_POST['cat_name']); 
 

Yes you can, but it is not secure to do that!

use (insecure):

$query = INSERT INTO categories (category_name) VALUES
('{$_POST['cat_name']}');

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



Re: [PHP] syntax question

2007-03-26 Thread Brad Bonkoski

Ross wrote:

Can I put post values directly into insert statements?

$query = INSERT INTO categories (category_name) VALUES 
('$_POST['cat_name']); 

  

Yes, although this is not recommended.
What is someone puts a single quote in there?  Or some other bad 
characters


otherwise... 2 options:

$query = INSERT INTO categories (category_name) VALUES 
('.$_POST['cat_name'].');

-or-
$query = INSERT INTO categories (category_name) VALUES 
('{$_POST['cat_name']}');


-Brad 



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



Re: [PHP] syntax question

2007-03-26 Thread tedd

At 3:59 PM +0100 3/26/07, Ross wrote:

Can I put post values directly into insert statements?

$query = INSERT INTO categories (category_name) VALUES
('$_POST['cat_name']);



Open to sql injection.

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] syntax question

2007-03-26 Thread Richard Lynch
On Mon, March 26, 2007 9:59 am, Ross wrote:
 Can I put post values directly into insert statements?

 $query = INSERT INTO categories (category_name) VALUES
 ('$_POST['cat_name']);

Sure!

If you want your webserver to get hacked by the Bad Guys, just go
right ahead and do that.

[that was tounge-in-cheek]

Start reading here:
http://phpsec.org

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] syntax question

2007-03-26 Thread itoctopus
Escape it, use either htmlentities (with ENT_QUOTES) or addslashes.

--
itoctopus - http://www.itoctopus.com
Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Mon, March 26, 2007 9:59 am, Ross wrote:
  Can I put post values directly into insert statements?
 
  $query = INSERT INTO categories (category_name) VALUES
  ('$_POST['cat_name']);

 Sure!

 If you want your webserver to get hacked by the Bad Guys, just go
 right ahead and do that.

 [that was tounge-in-cheek]

 Start reading here:
 http://phpsec.org

 --
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?

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



Re: [PHP] Syntax Error

2007-01-07 Thread Chris

JD wrote:
Can someone help me figure out why I can't run this on MySQL.  I get a 
syntax error.


list($qh,$num) = dbQuery(SELECT password AS passwd1, 
$DATABASE_PASSWORD_FUNCTION('$password') AS passwd2 .


FROM $USER_TABLE WHERE username='$username');

$data = dbResult($qh);


You've already posted this on the php-db list and had two responses. No 
need to send it to all php mailing lists you can find.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Syntax Error

2007-01-07 Thread Chris

bruce wrote:

chris...

sure there is.. alot of people don't subscribe to other lists. if you're one
who does, simply ignore his post.


And if the poster looked at either of the responses he received and 
replied to the questions asked, then he'd get a much better response.


http://marc.theaimsgroup.com/?t=11682128183r=1w=2

If the OP didn't get a response at all, then hey go for it but since he 
got two responses within 5 minutes of the original post and then decided 
to post on another list within 10 minutes, then yeh I will criticize.


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] syntax error help

2006-08-21 Thread Richard Lynch


Older version of MySQL does not support subselects.

On Sun, August 20, 2006 5:18 am, Bigmark wrote:
 Can anyone tell me why this works on my localhost but gets an error on
 my
 server:

 ?php
 $sql = SELECT COUNT(*) FROM leaderboard WHERE points =( SELECT
 points FROM
 leaderboard WHERE username= '$username' );
 $result = mysql_query( $sql ) or die ( mysql_error() );
 $rank = mysql_result( $result, 0 );
 echo $rank;
 ?


 this is the error message but i cant figure it out:

 Your Position  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
 'SELECT points FROM leaderboard WHERE username= 'ainslie' )' at

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




-- 
Like Music?
http://l-i-e.com/artists.htm



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



Re: [PHP] syntax error help

2006-08-20 Thread Paul Scott

On Sun, 2006-08-20 at 18:18 +0800, Bigmark wrote:
 Can anyone tell me why this works on my localhost but gets an error on my
 server:
 

Try quote your identifiers.

SELECT COUNT(*) FROM `leaderboard` WHERE `points` =( SELECT `points`
FROM
`leaderboard` WHERE `username` = '$username' );

--Paul

All Email originating from UWC is covered by disclaimer 
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm 

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

Re: [PHP] syntax error help

2006-08-20 Thread chris smith

On 8/20/06, Bigmark [EMAIL PROTECTED] wrote:

Can anyone tell me why this works on my localhost but gets an error on my
server:

?php
$sql = SELECT COUNT(*) FROM leaderboard WHERE points =( SELECT points FROM
leaderboard WHERE username= '$username' );
$result = mysql_query( $sql ) or die ( mysql_error() );
$rank = mysql_result( $result, 0 );
echo $rank;
?


this is the error message but i cant figure it out:

Your Position  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
'SELECT points FROM leaderboard WHERE username= 'ainslie' )' at


They are different mysql versions.

Your localhost version is 4.1+ which supports sub-selects, the other
one is 4.0 or below.

--
Postgresql  php tutorials
http://www.designmagick.com/

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



RE: [PHP] syntax error help

2006-08-20 Thread Peter Lauri
Check the version of MySQL, I think sub queries came in version 4.1 and you
are using that. So you probably have a version=4.1 at localhost, and 4.1
at your server.

/Peter


-Original Message-
From: Bigmark [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 20, 2006 5:19 PM
To: php-general@lists.php.net
Subject: [PHP] syntax error help

Can anyone tell me why this works on my localhost but gets an error on my
server:

?php
$sql = SELECT COUNT(*) FROM leaderboard WHERE points =( SELECT points FROM
leaderboard WHERE username= '$username' );
$result = mysql_query( $sql ) or die ( mysql_error() );
$rank = mysql_result( $result, 0 );
echo $rank;
?


this is the error message but i cant figure it out:

Your Position  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
'SELECT points FROM leaderboard WHERE username= 'ainslie' )' at

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



Re: [PHP] syntax highlighting for Shell scripts and C?

2006-05-25 Thread Chris

Michelle Konzack wrote:

Hello,

since I include source sniplets into some of my webpages I like
this syntax highlighting for php scripts...   because it make
scripts more readable.

My question is:  Does such thing exist for Shell scripts and C?


pastebin.com has it and the code is GPL'ed so you could use that as a 
starting point (go to the blog - http://blog.dixo.net/category/pastebin/ 
and you can download it).


--
Postgresql  php tutorials
http://www.designmagick.com/

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



RE: [PHP] syntax highlighting for Shell scripts and C?

2006-05-25 Thread Daevid Vincent
Check out Geshi
http://qbnz.com/highlighter/ 

 -Original Message-
 From: Chris [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, May 25, 2006 5:54 PM
 To: Michelle Konzack
 Cc: PHP - General
 Subject: Re: [PHP] syntax highlighting for Shell scripts and C?
 
 Michelle Konzack wrote:
  Hello,
  
  since I include source sniplets into some of my webpages I like
  this syntax highlighting for php scripts...   because it make
  scripts more readable.
  
  My question is:  Does such thing exist for Shell scripts and C?
 
 pastebin.com has it and the code is GPL'ed so you could use that as a 
 starting point (go to the blog - 
 http://blog.dixo.net/category/pastebin/ 
 and you can download it).

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



  1   2   3   >