Re: [PHP] PHP Version: 5.2.5.

2011-10-17 Thread Ashley Sheridan
On Mon, 2011-10-17 at 17:43 +0100, Joseph Adenuga wrote:

> 
> Hello Ashley,
> 
> Many thanks for your email. Yes, I'm calling the script from my
> Firefox browser. I've tried all I can to find other ways to open the
> file but, with no luck. Please I'm thanking you in anticipation.
> 
> I look forward to hearing from you.
> 
> Best Wishes,
> 
> Joseph
> 
> --- On Mon, 17/10/11, Ashley Sheridan 
> wrote:
> 
> 
> From: Ashley Sheridan 
> Subject: Re: [PHP] PHP Version: 5.2.5.
> To: "Joseph Adenuga" ,
> php-general@lists.php.net
> Date: Monday, 17 October, 2011, 8:02
> 
> 
> 
> 
> Joseph Adenuga  wrote:
> 
> >
> >
> >Operating System: Window XP
> >
> >PHP Version: 5.2.5. with Apache 2.2.8
> >
> >My Firefox browser returns (Output) the same php script code
> I inserted
> >in Notepad:   >
> >echo "Hello
> >Web!";
> >
> >?>
> >
> > 
> >
> >Please, what am I doing wrong?
> 
> How are you calling the script? If you're just trying to open
> the file in a browser then it won't work, you need to call it
> from a web server (apache or iis). Most usually this is from
> the url localhost/script.php or 127.0.0.1/script.php
> 
> Let us know how you're calling it and we can help further.
> 
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
> --
> Sent from my Android phone with K-9 Mail. Please excuse my
> brevity.
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

Please reply to the list and not back to only me.

You say you're opening it with Firefox, but you haven't said how or
where from? Are you running it from a local web server via something
like localhost or 127.0.0.1, or are you trying to open it up by
selecting the file in your file manager and saying "open with firefox"?

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




[PHP] Convert Hours to Decimal

2011-10-17 Thread Don Wieland

Hey Tim,

I got a select string:

select timediff(cast(out_1 as time), cast(in_1 as time)) tHours FROM  
lm_tc_trans WHERE tc_trans_id = '42'


result = 08:45:00

How do i convert that to a FLOAT (5,2) =  8.75

or

result = 08:15:00

How do i convert that to a FLOAT (5,2) =  8.25

Don Wieland

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



Re: [PHP] Seeking strategy/algorithm for maintaining order of records

2011-10-17 Thread Tommy Pham
On Sun, Oct 16, 2011 at 2:32 PM, Stephen  wrote:

> On 11-10-16 04:10 PM, Jim Giner wrote:
>
>> Stephen:
>>
>> What you describe is a multistep problem. There are many ways to show
>> pictures (images) in any order you want.
>> *
>>
>> So far, the OP has only asked how to keep his "categories" in order.
>> Curious, yes, but he hasn't even asked how to display the images in order
>> -
>> maybe he doesn't care about that..
>>
> Well, I want to deal with one part of the design at a time :)
>
> Thanks to all who replied. This is a collective response.
>
> Displaying in an order is easy when you have a field called "order".
>
> SELECT descriptions FROM categories ORDER by order;
>
> My issue is, say I have three records:
>
> ID CategoryOrder
>
> 1B&W1
> 2Landscapes 2
> 3Nudes  3
>
> I am looking for the best way to be able to change the values to
>
> ID CategoryOrder
>
> 1B&W3
> 2Landscapes 2
> 3Nudes  1
>
> Dynamically building a form, entering the new order value, and then looping
> through the post, with a SQL UPDATE is the best I can come up with.
>
>
> A future issue will be doing the same to the table category-photograph
>
> ID Category_id photo_id order
>
> This table is needed to allow a photograph to be in more than one category.
>
> Cheers
> Stephen
>
>

Depends on the tools you have in your belt.  If you want to keep it strictly
HTML + PHP, you can use the form POST.  Iterate through the form's
categories collection and update to the database, this simplest application
design doesn't require you check what's the previous order is or which
category's order has changed.

/* psuedo code */
- $order = null; $id = null;
- $sql = UPDATE SET `order` = '?' WHERE `ID` = '?';
- make connection to db
- if ( [1] prepare statement === false ) throw new Exception('Error
preparing statement: '.$sql);
- if ( [2] bind param $order and $id === false ) throw new Exception('Error
binding parameters: $order '.$order.' and $id '.$id);
- iterate through the form POST collection of categories
- $id = $category_id; $order = $category_order;
- if ([3] execute prepared statement === false) throw new Exception('Error
executing prepared statement '.$sql;
- end loop / iteration
- close db connection

However, using this method will have a performance issue if the number of
records you're updating is large regardless of which 'category' was changed.

Good luck,
Tommy


[1] php.net/mysqli.prepare
[2] php.net/mysqli-stmt.bind-param
[3] php.net/mysqli-stmt.execute
[4] php.net/language.exceptions


Re: [PHP] FW: parse error

2011-10-17 Thread Stuart Dallas
PLEASE INCLUDE THE LIST WHEN REPLYING!

On 17 Oct 2011, at 18:21, David Savage wrote:

> No... I log into a linux box, and use the vi editor (actually I use 'view', 
> which is vi but without the color highlighting which is somewhat hard to see 
> on some colors, such as blue on a black screen). 

As I said, get one. There are loads of free editors for all operating systems 
that do syntax highlighting for PHP. Get one, load the file up in that and have 
a look.

-Stuart


> From: Stuart Dallas [mailto:stu...@3ft9.com]
> Sent: Thu 10/13/2011 1:43 PM
> To: David Savage
> Cc: PHP General
> Subject: Re: [PHP] FW: parse error
> 
> Please include the list when replying.
> 
> On 13 Oct 2011, at 19:44, David Savage wrote:
> 
>> ok thanks for the quick reply.  Still trying to figure out the line that is 
>> causing the problem above that line 1050I'm a novice at php, and 
>> currently use it just for console programming, though I want to eventually 
>> learn how to place html code in it, and make it simpler to run this program 
>> in a web browser, instead of by the command line.
> 
> Are you using an editor that does syntax highlighting? If not, find one and 
> load up the file. If you have an unterminated string or similar error, the 
> highlighting should tell you where that problem is.
> 
> -Stuart
> 
>> From: Stuart Dallas [mailto:stu...@3ft9.com]
>> Sent: Thu 10/13/2011 12:04 PM
>> To: David Savage
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] FW: parse error
>> 
>> On 13 Oct 2011, at 18:06, David Savage wrote:
>> 
>> > I'm sorryI need help with php v. 4.3.9 (cgi).  I don't know where else 
>> > to turn.  I've looked on the php.net web site for details on this 
>> > particular error, but am unable to find any.
>> >
>> > this is the version I use.
>> > php -v
>> > PHP 4.3.9 (cgi) (built: Jun 26 2006 09:46:03)
>> > Copyright (c) 1997-2004 The PHP Group
>> > Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
>> >
>> > I run the following command, and getting the following compile error on a 
>> > linux environment:
>> > php -l voip_cdrs.php
>> > PHP Parse error:  parse error, unexpected T_STRING in 
>> > /usr/local/cytrex/voip_cdrs.php on line 1050
>> > Errors parsing voip_cdrs.php
>> >
>> > here is a portion of the code that includes the line number mentioned:
>> > if   ($destlen==11) {
>> >$start_from_which_offset=1;
>> > }
>> > if   ($destlen==10) {
>> >$start_from_which_offset=0;
>> > }
>> > $termnum10=substr($dest, $start_from_which_offset,10);
>> > $alias_sql_stmt="SELECT ani FROM ldrates WHERE 
>> > ani='$termnum10'";// <-this is line 1050
>> > print "$alias_sql_stmt\n";
>> > $alias_result = $db->sql_query($alias_sql_stmt);
>> > if  ($alias_result==TRUE) {
>> >if($db->sql_numrows($alias_result) > 0) {
>> >print "Found alias...\n";
>> >continue;
>> >}
>> > } else {
>> >die("problem with sql: $alias_sql_stmt");
>> > }
>> >
>> > Could you please tell me what's wrong with the line 1050 ?   I've been 
>> > pulling my hair out (figuratively speaking) trying to understand why the 
>> > compiler sees this line as a problem.  Thanks for whatever help you can 
>> > give.
>> 
>> There is nothing wrong with the code you've posted...
>> 
>> stuart@willow:~$ php -l test.php
>> No syntax errors detected in test.php
>> 
>> Which means the error is likely above that in the file.
>> 
>> -Stuart
>> 
>> --
>> Stuart Dallas
>> 3ft9 Ltd
>> http://3ft9.com/
>> 

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/



[PHP] Re: PHP Version: 5.2.5.

2011-10-17 Thread Jim Giner
what did you name your file?  If it didn't have a .php extension, it won't 
work.
"Joseph Adenuga"  wrote in message 
news:1318859708.50026.yahoomailclas...@web29517.mail.ird.yahoo.com...


Operating System: Window XP

PHP Version: 5.2.5. with Apache 2.2.8

My Firefox browser returns (Output) the same php script code I inserted in 
Notepad: Hello
Web!";

?>



Please, what am I doing wrong?




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



Re: [PHP] PHP Version: 5.2.5.

2011-10-17 Thread Ashley Sheridan


Joseph Adenuga  wrote:

>
>
>Operating System: Window XP
>
>PHP Version: 5.2.5. with Apache 2.2.8
>
>My Firefox browser returns (Output) the same php script code I inserted
>in Notepad:  
>    echo "Hello
>Web!";
>
>?>
>
> 
>
>Please, what am I doing wrong?

How are you calling the script? If you're just trying to open the file in a 
browser then it won't work, you need to call it from a web server (apache or 
iis). Most usually this is from the url localhost/script.php or 
127.0.0.1/script.php

Let us know how you're calling it and we can help further.

Thanks,
Ash
http://www.ashleysheridan.co.uk
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

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



RE: [PHP] PHP Version: 5.2.5.

2011-10-17 Thread Dajka Tamás
Hi,

PHP parser is not enabled ( module not enabled or not associated with
.php/.html/.htm files! )

Cheers,

Tamas

-Original Message-
From: Joseph Adenuga [mailto:jadenu...@yahoo.com] 
Sent: Monday, October 17, 2011 3:55 PM
To: php-general@lists.php.net
Cc: jadenu...@yahoo.com
Subject: [PHP] PHP Version: 5.2.5. 



Operating System: Window XP

PHP Version: 5.2.5. with Apache 2.2.8

My Firefox browser returns (Output) the same php script code I inserted in
Notepad:  Hello
Web!"; 

?>

 

Please, what am I doing wrong?



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



[PHP] PHP Version: 5.2.5.

2011-10-17 Thread Joseph Adenuga


Operating System: Window XP

PHP Version: 5.2.5. with Apache 2.2.8

My Firefox browser returns (Output) the same php script code I inserted in 
Notepad:  Hello
Web!"; 

?>

 

Please, what am I doing wrong?



RE: [PHP] Seeking strategy/algorithm for maintaining order of records

2011-10-17 Thread Arno Kuhl
From: Stephen [mailto:stephe...@rogers.com] 
Sent: 16 October 2011 11:33 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Seeking strategy/algorithm for maintaining order of
records

Displaying in an order is easy when you have a field called "order".

SELECT descriptions FROM categories ORDER by order;

My issue is, say I have three records:

ID CategoryOrder

1B&W1
2Landscapes 2
3Nudes  3

I am looking for the best way to be able to change the values to

ID CategoryOrder

1B&W3
2Landscapes 2
3Nudes  1

Dynamically building a form, entering the new order value, and then looping
through the post, with a SQL UPDATE is the best I can come up with.

A future issue will be doing the same to the table category-photograph

ID Category_id photo_id order

This table is needed to allow a photograph to be in more than one category.

Cheers
Stephen

-- 

One way would be to use ajax. Each time a photo is moved up or down the
order list you issue an ajax request to update the order. That way your php
script only needs to deal with 2 records at a time and switch their order
values.

Besides that, I can't think of any way of processing a form with multiple
order changes other than looping through the post the way you described.

Cheers
Arno


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