Re: [PHP] syntax question
Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax question
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 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
[PHP] syntax question
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 error breaking in and out of php into html code
On Aug 26, 2012, at 1:36 PM, Ashley Sheridan 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
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 > 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: > > > > > while(condition) > > { > > ?> > > some html here > > > } > > ?> > > > > 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
On Sun, Aug 26, 2012 at 5:02 AM, Ashley Sheridan 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 > 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 > >> 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: > >> > > >> > >> > while(condition) > >> > { > >> > ?> > >> > some html here > >> > >> > } > >> > ?> > >> > > >> > 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
On Sat, Aug 25, 2012 at 6:54 PM, Ashley Sheridan 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: > > while(condition) > { > ?> > some html here > } > ?> > > 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. -- 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
On Sun, 2012-08-26 at 09:21 -0300, Samuel Lopes Grigolato wrote: > Maybe you have a " allows short open tags? In production that setting could be disabled. > > > On Sun, Aug 26, 2012 at 9:20 AM, Ashley Sheridan > wrote: > > On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote: > > > On 26 Aug 2012, at 03:56, Ashley Sheridan > 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
Maybe you have a "wrote: > On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote: > > > On 26 Aug 2012, at 03:56, Ashley Sheridan > 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
On Sun, 2012-08-26 at 11:02 +0100, Stuart Dallas wrote: > On 26 Aug 2012, at 03:56, Ashley Sheridan 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
On 26 Aug 2012, at 03:56, Ashley Sheridan 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
On Sun, 2012-08-26 at 04:36 -0500, tamouse mailing lists wrote: > On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan > 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 > >> 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: > >> > > >> > >> > while(condition) > >> > { > >> > ?> > >> > some html here > >> > >> > } > >> > ?> > >> > > >> > 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
On Sat, Aug 25, 2012 at 9:56 PM, Ashley Sheridan 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 >> 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: >> > >> > > > while(condition) >> > { >> > ?> >> > some html here >> > > > } >> > ?> >> > >> > 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
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 > 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: > > > > > while(condition) > > { > > ?> > > some html here > > > } > > ?> > > > > 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 error breaking in and out of php into html code
Can you tell us what is the error shown in browser or CLI? On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan 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: > > while(condition) > { > ?> > some html here > } > ?> > > 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
On Sat, Aug 25, 2012 at 6:54 PM, Ashley Sheridan 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: > > while(condition) > { > ?> > some html here > } > ?> > > 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
[PHP] syntax error breaking in and out of php into html code
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: some html here 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
RE: [PHP] syntax question
> -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 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] syntax question
> -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 > > > 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
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 > 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 . > > > > > > > > > >
[PHP] syntax question
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 problem PDO and bindvalue
On Mon, Dec 12, 2011 at 4:22 PM, FeIn 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 problem PDO and bindvalue
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 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'] . ""; < 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 . ""; >} > > > 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
On 12/12/2011 01:49 PM, Stephen 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'] . ""; < 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 . ""; } 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 $x = $x['number']; $stmt->bindValue( ':q', $x['number'], PDO::PARAM_INT ); i didnt dig deep down the problem [might be some C thing, pointer access or ...] but this solves it. Fatih P. http://blog.teknober.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Syntax problem PDO and bindvalue
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'] . ""; < 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 . ""; } 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] PHP syntax - novice question
On 30/10/11 at 01:18, si...@welsh.co.nz (Simon J Welsh) wrote: > It seems as though your editor has changed the normal quotes around > into "pretty" > quotes. Change the ‘s and ’s back to '. Hi, Simon. Thanks for that. Couldn’t see for looking... Cheers, Phil. -- Please consider the environment before reading this email... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP syntax - novice question
On 30/10/2011, at 1:15 PM, Phil Dobbin wrote: > Hi, all. > > I’m new to the list & PHP in general & have a syntax question. > > I have a script that calls both DB & MDB2. This is the part of the script > where the error occurs: > > > > if($type == "DB") > { >$db = DB::connect($dsn); >if (PEAR::isError($db)) { die($db->getMessage()); } >$db->setFetchMode(DB_FETCHMODE_ASSOC); >$res = $db->query( 'SELECT * FROM users'); > >if (PEAR::isError($res)) { > die($res->getMessage()); >} >echo ‘’; >while( $res->fetchInto( $row ) ) { > print_R($row); >} >echo ‘’; > } else if($type == "MDB2") { >$mdb2 =& MDB2::connect($dsn); >if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } > >$res = $mdb2->query( 'SELECT * FROM users'); > >// Always check that result is not an error >if (PEAR::isError($res)) { > die($res->getMessage()); >} > >echo ‘’; >while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { > print_R($row); >} >echo ‘’; > } > > ### > > The syntax checker calls the first instance ofecho ‘’; saying > unexpected > > > I’m at a loss to understand why... > > I’m using PHP 5.3.8 & PEAR 1.9.4 with MySQL 5.1.59 on Mac OS X 10.6.8. > > Any help appreciated. > > Cheers, > >Phil. It seems as though your editor has changed the normal quotes around into "pretty" quotes. Change the ‘s and ’s back to '. --- Simon Welsh Admin of http://simon.geek.nz/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP syntax - novice question
Hi, all. I’m new to the list & PHP in general & have a syntax question. I have a script that calls both DB & MDB2. This is the part of the script where the error occurs: if($type == "DB") { $db = DB::connect($dsn); if (PEAR::isError($db)) { die($db->getMessage()); } $db->setFetchMode(DB_FETCHMODE_ASSOC); $res = $db->query( 'SELECT * FROM users'); if (PEAR::isError($res)) { die($res->getMessage()); } echo ‘’; while( $res->fetchInto( $row ) ) { print_R($row); } echo ‘’; } else if($type == "MDB2") { $mdb2 =& MDB2::connect($dsn); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } $res = $mdb2->query( 'SELECT * FROM users'); // Always check that result is not an error if (PEAR::isError($res)) { die($res->getMessage()); } echo ‘’; while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { print_R($row); } echo ‘’; } ### The syntax checker calls the first instance ofecho ‘’; saying unexpected > I’m at a loss to understand why... I’m using PHP 5.3.8 & PEAR 1.9.4 with MySQL 5.1.59 on Mac OS X 10.6.8. Any help appreciated. Cheers, Phil. -- Please consider the environment before reading this email... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Question
On 8/3/11 10:41 AM, "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: >> >> >> 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: >> >> > href="http://ids.si.edu/ids/dynamic?container.fullpage&id=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.fullpage&id=http://americanart >> .si.e >> du/images/ >> <http://ids.si.edu/ids/dynamic?container.fullpage&id=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.fullpage&id=http://americanart.si.e > du/images/ > <http://ids.si.edu/ids/dynamic?container.fullpage&id=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 = " src=http://ids.si.edu/ids/dynamic?container.fullpage&id=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.fullpage&id=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 Question
> -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: > > > 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: > > href="http://ids.si.edu/ids/dynamic?container.fullpage&id=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.fullpage&id=http://americanart > .si.e > du/images/ > <http://ids.si.edu/ids/dynamic?container.fullpage&id=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.fullpage&id=http://americanart.si.e du/images/ <http://ids.si.edu/ids/dynamic?container.fullpage&id=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 = "http://ids.si.edu/ids/dynamic?container.fullpage&id=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
[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: 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: http://ids.si.edu/ids/dynamic?container.fullpage&id=http://americanart .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.fullpage&id=http://americanart.si.e du/images/ <http://ids.si.edu/ids/dynamic?container.fullpage&id=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
Re: [PHP] Syntax Error
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
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" Date: Mon, Oct 4, 2010 09:04 Subject: [PHP] Syntax Error To: Cc: "chris h" , "Gary" , 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
On Sun, 2010-10-03 at 13:14 -0400, chris h wrote: > On Sun, Oct 3, 2010 at 12:47 PM, Gary 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) > > > > > > > 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; > > } > > } > > ?> > > > // *** 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; > > } > > } > > ?> > > > $editFormAction = $_SERVER['PHP_SELF']; > > if (isset($_SERVER['QUERY_STRING'])) { > > $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); > > } > > > > ?> > > > 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
On Sun, Oct 3, 2010 at 12:47 PM, Gary 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) > > > 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; > } > } > ?> > // *** 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; > } > } > ?> > $editFormAction = $_SERVER['PHP_SELF']; > if (isset($_SERVER['QUERY_STRING'])) { > $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); > } > > ?> > 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.
[PHP] Syntax Error
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) =1) $MM_qsChar = "&"; $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; header ("Location: $MM_dupKeyRedirect"); exit; } } ?> 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
Re: [PHP] PHP Syntax Help - Check?
Hmm. OK with the help below, I am closer. The other fields on the page are getting passed via form fields that look like this: input type="text" value="" name="form[element9]" size="40" maxlength="255" so I added: input type="text" value="" name="form[my_id]" size="40" maxlength="255" and formcheck.php has: "field_label") $form_fields = array( "element0" => 'Your Name:', "element1" => 'Your Email:', "element4" => 'Item Number:', . ); and I added: "my_id" => 'My ID Is:', And this works! So when I am on mypage.php and I enter a value into the form field "my_id" it carries over and repopulates should the form fail validation. But upon initial load of the page from my link of mypage.php?my_id=5 (so I am not getting there via a form submit) how do I get the value into the form field? --Rick On Feb 25, 2010, at 1:02 AM, viraj wrote: if you do the redirection with header('Location: /mypage.php'), setting a variable on formcheck.php is not enough. if you modify the header('Location: /mypage.php') to.. header('Location: /mypage.php?my_id=5') it will take the variable to mypage.php as $_GET['my_id] you can not expect a variable value set in to $_POST array to reflect on a totally different page without making it a form post (aka use of proper headers). i guess, it's time to you to read about session_start() method and the array $_SESSION available in php :) ~viraj On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer wrote: OK... external function... that would explain why I could not locate it. Let me get right to the problem I am having with this code as someone may be able to help directly. I have a link on a page that opens a contact form. The link is mypage.php?my_id=5 So on mypage.php, I capture this value with: $my_id=$_GET['my_id']; I understand this much. But when the end user submits this contact form they do so to formcheck.php and if formcheck.php sees a required field is blank, it throws it back to mypage.php with an alert. BUT, I lose the value of the variable $my_id. SO, I created a hidden field on mypate.php with value="" and on formcheck.php, I added $my_id = $_Post['my_id']; However, when formcheck.php returns me to mypage.php, $my_id is still blank. Very frustrating. Any help determining what I am doing wrong is greatly appreciated. Thanks. --Rick On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote: On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote: Rick Dwyer wrote: Hello all. I'm trying to learn PHP on the fly and I have a line of code that contains syntax I can't find documented anywhere: php echo check('element8'); In the above line, can someone tell me what "check" means? In the above, check is a function. It is being called with parameter 'element8'. This is true. But perhaps more importantly, check() is not a native PHP function. Thus it comes from some other library or group of external functions. Paul -- Paul M. Foster -- 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 -- ~viraj -- 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] PHP Syntax Help - Check?
On Thu, Feb 25, 2010 at 4:22 PM, Rick Dwyer wrote: > OK... external function... that would explain why I could not locate it. > > Let me get right to the problem I am having with this code as someone may be > able to help directly. > > I have a link on a page that opens a contact form. The link is > mypage.php?my_id=5 > > So on mypage.php, I capture this value with: > $my_id=$_GET['my_id']; > > I understand this much. But when the end user submits this contact form > they do so to formcheck.php and if formcheck.php sees a required field is > blank, it throws it back to mypage.php with an alert. BUT, I lose the value > of the variable $my_id. SO, I created a hidden field on mypate.php with > value="" and on formcheck.php, I added $my_id = > $_Post['my_id']; > > However, when formcheck.php returns me to mypage.php, $my_id is still blank. Use the right varialble for the method you're using, so if you're posting, use $_POST, if you're getting use $_GET.. Going by your example, $_GET is what you should probably be using, this is usually the default method if no method is specified on the form tag. Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Syntax Help - Check?
if you do the redirection with header('Location: /mypage.php'), setting a variable on formcheck.php is not enough. if you modify the header('Location: /mypage.php') to.. header('Location: /mypage.php?my_id=5') it will take the variable to mypage.php as $_GET['my_id] you can not expect a variable value set in to $_POST array to reflect on a totally different page without making it a form post (aka use of proper headers). i guess, it's time to you to read about session_start() method and the array $_SESSION available in php :) ~viraj On Thu, Feb 25, 2010 at 11:22 AM, Rick Dwyer wrote: > OK... external function... that would explain why I could not locate it. > > Let me get right to the problem I am having with this code as someone may be > able to help directly. > > I have a link on a page that opens a contact form. The link is > mypage.php?my_id=5 > > So on mypage.php, I capture this value with: > $my_id=$_GET['my_id']; > > I understand this much. But when the end user submits this contact form > they do so to formcheck.php and if formcheck.php sees a required field is > blank, it throws it back to mypage.php with an alert. BUT, I lose the value > of the variable $my_id. SO, I created a hidden field on mypate.php with > value="" and on formcheck.php, I added $my_id = > $_Post['my_id']; > > However, when formcheck.php returns me to mypage.php, $my_id is still blank. > > Very frustrating. > > Any help determining what I am doing wrong is greatly appreciated. > > Thanks. > > > > --Rick > > > On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote: > >> On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote: >> >>> Rick Dwyer wrote: Hello all. I'm trying to learn PHP on the fly and I have a line of code that contains syntax I can't find documented anywhere: php echo check('element8'); In the above line, can someone tell me what "check" means? >>> >>> >>> In the above, check is a function. It is being called with parameter >>> 'element8'. >> >> This is true. But perhaps more importantly, check() is not a native PHP >> function. Thus it comes from some other library or group of external >> functions. >> >> Paul >> >> -- >> Paul M. Foster >> >> -- >> 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 > > -- ~viraj -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Syntax Help - Check?
OK... external function... that would explain why I could not locate it. Let me get right to the problem I am having with this code as someone may be able to help directly. I have a link on a page that opens a contact form. The link is mypage.php?my_id=5 So on mypage.php, I capture this value with: $my_id=$_GET['my_id']; I understand this much. But when the end user submits this contact form they do so to formcheck.php and if formcheck.php sees a required field is blank, it throws it back to mypage.php with an alert. BUT, I lose the value of the variable $my_id. SO, I created a hidden field on mypate.php with value="" and on formcheck.php, I added $my_id = $_Post['my_id']; However, when formcheck.php returns me to mypage.php, $my_id is still blank. Very frustrating. Any help determining what I am doing wrong is greatly appreciated. Thanks. --Rick On Feb 25, 2010, at 12:31 AM, Paul M Foster wrote: On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote: Rick Dwyer wrote: Hello all. I'm trying to learn PHP on the fly and I have a line of code that contains syntax I can't find documented anywhere: php echo check('element8'); In the above line, can someone tell me what "check" means? In the above, check is a function. It is being called with parameter 'element8'. This is true. But perhaps more importantly, check() is not a native PHP function. Thus it comes from some other library or group of external functions. Paul -- Paul M. Foster -- 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] PHP Syntax Help - Check?
On Thu, Feb 25, 2010 at 12:16:08AM -0500, Robert Cummings wrote: > Rick Dwyer wrote: >> Hello all. >> >> I'm trying to learn PHP on the fly and I have a line of code that >> contains syntax I can't find documented anywhere: >> >> php echo check('element8'); >> >> In the above line, can someone tell me what "check" means? > > > In the above, check is a function. It is being called with parameter > 'element8'. This is true. But perhaps more importantly, check() is not a native PHP function. Thus it comes from some other library or group of external functions. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Syntax Help - Check?
Rick Dwyer wrote: Hello all. I'm trying to learn PHP on the fly and I have a line of code that contains syntax I can't find documented anywhere: php echo check('element8'); In the above line, can someone tell me what "check" means? In the above, check is a function. It is being called with parameter 'element8'. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Syntax Help - Check?
Hello all. I'm trying to learn PHP on the fly and I have a line of code that contains syntax I can't find documented anywhere: php echo check('element8'); In the above line, can someone tell me what "check" means? Thank you. --Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error in class
2010/2/11 Jim Lucas > 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 error in class
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
[PHP] syntax error in class
Hello guys, I encountered a syntax error, and cannot figure out the reason, for example: == CODE == 1:'str1'.'str2'); 3:?> === Works fine, but when I try to put it into a class, say: == CODE == 1:'str1'.'str2'); 5:} 6:?> == OUTPUT == Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 PHP Parse error: syntax error, unexpected '.', expecting ')' in C:\Documents and Settings\Administrator\Local Settings\Temp\VI42E5.tmp on line 4 I got the syntax error. Why? My php version: D:\>php -version PHP 5.3.1 (cli) (built: Nov 19 2009 10:17:43) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies I'm currently not on this list, please Cc your comment to me. Thanks in advance. -- Dasn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax Snag need extra eyes
Bastien Koert wrote: > On Thu, Jul 16, 2009 at 12:43 PM, Andrew Ballard wrote: >> On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas wrote: >>> Andrew Ballard wrote: On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas wrote: >> [snip] > Also, this is the wrong way to use printf(). Please go read the manual > page for this function. > > Try: > > printf( >'%s%s', >$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( '%1$s%2$s>>> />', $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(' href="view.php?name={$row['name']}">%s%s',$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 Snag need extra eyes
On Thu, Jul 16, 2009 at 12:43 PM, Andrew Ballard wrote: > On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas wrote: >> >> Andrew Ballard wrote: >> > On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas wrote: > [snip] >> >> Also, this is the wrong way to use printf(). Please go read the manual >> >> page for this function. >> >> >> >> Try: >> >> >> >> printf( >> >> '%s%s', >> >> $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( >> > '%1$s%2$s> > />', >> > $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('%s%s',$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
On Thu, Jul 16, 2009 at 12:35 PM, Jim Lucas wrote: > > Andrew Ballard wrote: > > On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas wrote: [snip] > >> Also, this is the wrong way to use printf(). Please go read the manual > >> page for this function. > >> > >> Try: > >> > >> printf( > >> '%s%s', > >> $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( > > '%1$s%2$s', > > $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
Re: [PHP] Syntax Snag need extra eyes (RESOLVED)
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" wrote: > > printf( > '%s%s', > $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
Andrew Ballard wrote: > On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas 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('>> >> href="view.php?name=$row['name']">%s%s',$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( >>'%s%s', >>$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( >'%1$s%2$s', >$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
On Thu, Jul 16, 2009 at 12:25 PM, Jim Lucas 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(' > > href="view.php?name=$row['name']">%s%s',$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( >'%s%s', >$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( '%1$s%2$s', $row['name'], $row['address'] ); Andrew
Re: [PHP] Syntax Snag need extra eyes (RESOLVED)
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" wrote: printf( '%s%s', $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
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(' href="view.php?name=$row['name']">%s%s',$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( '%s%s', $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
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(' href="view.php?name=$row['name']">%s%s',$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
[PHP] Syntax Snag need extra eyes
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('%s%s',$row['name'] ,$row['address']); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax woes
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
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/4/3 : > 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
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 woes
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
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
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
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
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
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
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
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
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
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
[PHP] syntax woes
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. I'm totally unsure how to approach this and am hoping syntax adjustments will fix it. - aurf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Syntax checker? Character replacing
just clean up your code and it will work: http://www.google.ca/search?hl=en&q=php+rocks%21%21%21&meta='; if (isset($qString)) { $buffer = str_replace("&","&",$qString); } echo $buffer."\n"; ?> OUTPUT: C:\>php test.php http://www.google.ca/search?hl=en&q=php+rocks%21%21%21&meta= C:\> On Fri, Mar 6, 2009 at 3:05 PM, Terion Miller 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("&","&",$_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 checker? Character replacing
On Fri, Mar 6, 2009 at 2:05 PM, Terion Miller 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("&","&",$_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('&', '&', $_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
[PHP] Syntax checker? Character replacing
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("&","&",$_SERVER['QUERY_STRING']) : '');} is that wrong?
Re: [PHP] syntax
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 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: > http://www.facebook.com/people/Terion-Miller/1542024891"; > title="Terion Miller's Facebook profile" target=_TOP>http://badge.facebook.com/badge/1542024891.237.919247960.png"; border=0 > alt="Terion Miller's Facebook profile"> > 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
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
> >> >> 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
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
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
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
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
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
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
> > 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
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: > http://www.facebook.com/people/Terion-Miller/1542024891"; > title="Terion Miller's Facebook profile" target=_TOP>http://badge.facebook.com/badge/1542024891.237.919247960.png"; border=0 > alt="Terion Miller's Facebook profile"> > 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
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
> 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
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
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
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
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: > http://www.facebook.com/people/Terion-Miller/1542024891"; > title="Terion Miller's Facebook profile" target=_TOP>http://badge.facebook.com/badge/1542024891.237.919247960.png"; border=0 > alt="Terion Miller's Facebook profile"> > 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
[PHP] syntax
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: http://www.facebook.com/people/Terion-Miller/1542024891"; title="Terion Miller's Facebook profile" target=_TOP>http://badge.facebook.com/badge/1542024891.237.919247960.png"; border=0 alt="Terion Miller's Facebook profile"> Vince Lombardi - "Winning is habit. Unfortunately, so is losing."
Re: [PHP] syntax error (stumped)
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: 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. -- 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)
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 (stumped)
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)
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// 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(""._("Dox")."\n"); print("Dox\n"); $res = mysql_query("SELECT * FROM dox ORDER BY added DESC") or sqlerr(); if (mysql_num_rows($res) == 0) print("Sorry, nothing here pal :("); else { print("\n"); print("TitleDateTimeSizeHitsUpped by\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 = " .$FILELINK. " . $arr[title] . " " . ($mod || $arr["uppedby"] == $CURUSER["id"] ? " ?delete=$arr[id] [Delete] " : "") ."\n"; $added = "" . substr($arr["added"], 0, 10) . "" . substr($arr["added"], 10) . "\n"; $size = "" . mksize($arr['size']) . "\n"; $hits = "" . number_format($arr['hits']) . "\n"; $uppedby = " .$GLOBALS['DEFAULTBASEURL']. $a[username] \n"; print("$title$added$size$hits$uppedby\n"); } print("\n"); print("Files are automatically deleted after 14 days...This is not in place...\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("\n"); print("\n"); print("File(Maximum file size: ".$maxfilesize.")\n"); print("Title(Optional, taken from file name if not specified.)\n"); print("Download URL(Optional, specifies a primary FTP/HTTP download location. You can substitute ". "the file name part with an asterisk (*), e.g. http://www.URSITE.com/files/*)&...\n"); print("\n"); print("\n"); print("\n"); end_frame(); end_main_frame(); } stdfoot(); ?> //end my.php// Thanks and sorry for the long responce. Are we looking for something that should define sqlerr()? Sailor P.S. Here is the line from the original code: $res = do_mysql_query("SELECT * FROM dox WHERE filename=$filename") or sqlerr(); quickshiftin wrote: > > 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 > > -- View this message in context: http://www.nabble.com/syntax-error-%28stu
Re: [PHP] syntax error (stumped)
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)
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? > > -- > > 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)
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? -- 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