FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Yet another error for some unknown reason
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Yet another error for some unknown reason [message #183083] Mon, 07 October 2013 16:10 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
<?php

$playme=array(
1=>array("1960","1","A Summer Place","Percy Faith Orch","6001.mp3"),
2=>array("1960","2","He'll Have To Go","Jim Reeves","6002.mp3"),
3=>array("1960","3","Cathy's Clown","Everly Brothers","6003.mp3"),
4=>array("1960","4","Running Bear","Johnny Preston","6004.mp3"),
5=>array("1960","5","Teen Angel","Mark Dinning","6005.mp3"),
6=>array("1960","6","It's Now Or Never","Elvis Presley","6006.mp3"),
7=>array("1960","7","Handy Man","Jimmy Jones","6007.mp3"),
8=>array("1960","8","I'm Sorry","Brenda Lee","6008.mp3"),
9=>array("1960","9","Stuck On You","Elvis Presley","6009.mp3"),
10=>array("1960","10","The Twist","Chubby Checker","6010.mp3"),
11=>array("1960","11","Everybody Is Somedbody's Fool","Connie
Francis","6011.mp3"),
12=>array("1960","12","Wild One","Bobby Rydell","6012.mp3"),
13=>array("1960","13","Greenifelds","Brothers Four","6013.mp3"),
14=>array("1960","14","What In The World's Come Over You","Jack
Scott","6014.mp3"),
15=>array("1960","15","El Paso","Marty Robbins","6015.mp3"),
16=>array("1960","16","Alley Oop","Hollywood Argyles","6016.mp3"),
17=>array("1960","17","My Heart Has A Mind Of Its Own","Connie
Francis","6017.mp3"),
18=>array("1960","18","Sweet Nothin's","Brenda Lee","6018.mp3"),
19=>array("1960","19","Itsy Bitsy Teenie Weenie Yellow Polka Dot
Bikini","Brian Hyland","6019.mp3"),
20=>array("1960","20","Only The Lonely","Roy Orbison","6020.mp3"),
21=>array("1961","1","Tossin' And Turnin'","Bobby Lewis","6101.mp3"),
22=>array("1961","2","I Fall To Pieces","Patsy Cline","6102.mp3"),
23=>array("1961","3","Michael","Highwaymen","6103.mp3"),
24=>array("1961","4","Crying","Roy Orbison","6104.mp3"),
25=>array("1961","5","Runaway","Del Shannon","6105.mp3"),
26=>array("1961","6","My True Story,","Jive Five","6106.mp3"),
27=>array("1961","7","Pony Time","Chubby Checker","6107.mp3"),
28=>array("1961","8","Wheels","String-A-Longs","6108.mp3"),
29=>array("1961","9","Raindrops","Dee Clark","6109"),
30=>array("1961","10","Wooden Heart","Joe Dowell","6110.mp3"),
31=>array("1961","11","Calcutta","Lawrence Welk","6111.mp3"),
32=>array("1961","12","Take Good Care Of My Baby","Bobby Vee","6112.mp3"),
33=>array("1961","13","Running Scared","Roy Orbison","6113.mp3"),
34=>array("1961","14","Dedicated To The One I Love","The
Shirelles","6114.mp3"),
35=>array("1961","15","Last Night","Mar-Keys","6115.mp3"),
36=>array("1961","16","Will You Love Me Tomorrow","Shirelles","6116..mp3"),
37=>array("1961","17","Exodus","Ferrante and Teicher","6117.mp3"),
38=>array("1961","18","Where The Boys Are","Connie Francis","6118.mp3"),
39=>array("1961","19","Hit The Road Jack","Ray Charles","6119.mp3"),
40=>array("1961","20","Sad Movies (Make Me Cry)","Sue Thompson","6120.mp3")

)



$numbers = range(1, 40); <<<- parse error here?
shuffle($numbers);
foreach ($numbers as $number) {
echo "$number \n";
}
?>


It worked fine with keys 1 through 20.
It failed when I added keys 21 through 40.
Re: Yet another error for some unknown reason [message #183084 is a reply to message #183083] Mon, 07 October 2013 16:20 Go to previous messageGo to next message
Daniel Pitts is currently offline  Daniel Pitts
Messages: 68
Registered: May 2012
Karma: 0
Member
On 10/7/13 9:10 AM, richard wrote:
> <?php
>
> $playme=array(
[snip]
> 38=>array("1961","18","Where The Boys Are","Connie Francis","6118.mp3"),
> 39=>array("1961","19","Hit The Road Jack","Ray Charles","6119.mp3"),
> 40=>array("1961","20","Sad Movies (Make Me Cry)","Sue Thompson","6120.mp3")
>
> )
Missing ; here.
>
>
>
> $numbers = range(1, 40); <<<- parse error here?
> shuffle($numbers);
> foreach ($numbers as $number) {
> echo "$number \n";
> }
> ?>
>
>
> It worked fine with keys 1 through 20.
> It failed when I added keys 21 through 40.
>

BTW, you can clean this up a bit, by not using [number]=>value,

$playme = array(
array("1960","1","A Summer Place","Percy Faith Orch","6001.mp3"),
array("1960","2","He'll Have To Go","Jim Reeves","6002.mp3"),
etc...
);

Also I would suggest considering externalizing this data. Put it in a
file and load that file. A CSV seems like a good choice. If you're
going to have a lot more data, then a database would be a better choice.
Re: Yet another error for some unknown reason [message #183085 is a reply to message #183083] Mon, 07 October 2013 16:23 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
richard the sto0pid wrote:

> 36=>array("1961","16","Will You Love Me
> Tomorrow","Shirelles","6116..mp3"),

> It worked fine with keys 1 through 20.
> It failed when I added keys 21 through 40.

Don't you ever proofread before posting this nonsense?

You have a file named "6116..mp3" ? (That's just one typo I noticed)

Find a new hobby...

--
-bts
-This space for rent, but the price is high
Re: Yet another error for some unknown reason [message #183086 is a reply to message #183083] Mon, 07 October 2013 16:43 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 07 Oct 2013 12:10:52 -0400, richard wrote:

> <?php

This is the problem. You haven't actually written php, you only claim to
have written php, and the interpreter isn't being fooled by the claim.

Why you're pissing about setting sequential associative indexes on the
array elements I have no idea, but I'm sure it makes sense on
planetRichard.

Likewise, I'm sure there is a very good reason indeed for storing
integers as strings.

If you want to generate your playlist in a random order (which is where I
suspect this is going) then I would use the following:

(a) Set the array up as follows:

$playme = array(
array(1960,1,"title","artist","file"),
array(1960,1,"title","artist","file"),
array(1960,1,"title","artist","file")
);

_^_ By the way, this semi-colon is *NOT* *OPTIONAL*

then:

shuffle($playme);

foreach($playme as $a)
echo "{$a[2]} by {$a[3]}, number {$a[1]} in {$a[0]}, {$a[4]}\n";

Here's an amazing fact about PHP:

The elements of an array do not have to all be of the same type!

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: Yet another error for some unknown reason [message #183087 is a reply to message #183083] Mon, 07 October 2013 16:48 Go to previous messageGo to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
On Mon, 7 Oct 2013 12:10:52 -0400, richard wrote:

> <?php
>


As usual, I find the error five minutes later.
Forgot the damn ; again!
Re: Yet another error for some unknown reason [message #183088 is a reply to message #183084] Mon, 07 October 2013 16:56 Go to previous messageGo to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
On Mon, 07 Oct 2013 09:20:47 -0700, Daniel Pitts wrote:

> On 10/7/13 9:10 AM, richard wrote:
>> <?php
>>
>> $playme=array(
> [snip]
>> 38=>array("1961","18","Where The Boys Are","Connie Francis","6118.mp3"),
>> 39=>array("1961","19","Hit The Road Jack","Ray Charles","6119.mp3"),
>> 40=>array("1961","20","Sad Movies (Make Me Cry)","Sue Thompson","6120.mp3")
>>
>> )
> Missing ; here.
>>
>>
>>
>> $numbers = range(1, 40); <<<- parse error here?
>> shuffle($numbers);
>> foreach ($numbers as $number) {
>> echo "$number \n";
>> }
>> ?>
>>
>>
>> It worked fine with keys 1 through 20.
>> It failed when I added keys 21 through 40.
>>
>
> BTW, you can clean this up a bit, by not using [number]=>value,
>
> $playme = array(
> array("1960","1","A Summer Place","Percy Faith Orch","6001.mp3"),
> array("1960","2","He'll Have To Go","Jim Reeves","6002.mp3"),
> etc...
> );
>
> Also I would suggest considering externalizing this data. Put it in a
> file and load that file. A CSV seems like a good choice. If you're
> going to have a lot more data, then a database would be a better choice.

True, I could do it that way.
But I am using the keys mainly as a guide for me.

I have a complete database online.
But for this purpose, it's easier to use an array.
Re: Yet another error for some unknown reason [message #183090 is a reply to message #183085] Mon, 07 October 2013 17:07 Go to previous messageGo to next message
Dennis is currently offline  Dennis
Messages: 17
Registered: February 2004
Karma: 0
Junior Member
On Mon, 7 Oct 2013 16:23:27 +0000 (UTC), "Beauregard T. Shagnasty"
<a(dot)nony(dot)mous(at)example(dot)invalid> opined:

> richard the sto0pid wrote:
>
>> 36=>array("1961","16","Will You Love Me
>> Tomorrow","Shirelles","6116..mp3"),
>
>> It worked fine with keys 1 through 20.
>> It failed when I added keys 21 through 40.
>
> Don't you ever proofread before posting this nonsense?

That's what you're here for. ;-)
>
> You have a file named "6116..mp3" ? (That's just one typo I noticed)
>
> Find a new hobby...

Instead of this hobby, he can probably get a paying job at
healthcare.gov. He'd fit right in!

--

Dennis
Re: Yet another error for some unknown reason [message #183091 is a reply to message #183086] Mon, 07 October 2013 17:37 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Denis McMahon wrote:

> (a) Set the array up as follows:
>
> $playme = array(
> array(1960,1,"title","artist","file"),
> array(1960,1,"title","artist","file"),
> array(1960,1,"title","artist","file")
> );
>
> _^_ By the way, this semi-colon is *NOT* *OPTIONAL*

An optional comma can be inserted after the last array() parameter, though,
which is useful when you have to initialize with more elements.

> […]
> Here's an amazing fact about PHP:

… and several other programming languages:

> The elements of an array do not have to all be of the same type!

ISTM that this naturally follows from using dynamic (run-time) instead of
static (compile-time) type-checking. [Java (which uses static type-
checking) can do this as well, but you have to wrap the value in an object
and have to use a wrapper class that accepts object references.]


PointedEars
--
When all you know is jQuery, every problem looks $(olvable).
Re: Yet another error for some unknown reason [message #183092 is a reply to message #183087] Mon, 07 October 2013 18:06 Go to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 07/10/13 18:48, richard wrote:
> On Mon, 7 Oct 2013 12:10:52 -0400, richard wrote:
>
>> <?php
>>
>
>
> As usual, I find the error five minutes later.
> Forgot the damn ; again!
>

Please us

php -l /path/to/your/file

and read the output, will help you a lot.

--

//Aho
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: A general note on invalid.com and others like it
Next Topic: How to link properly?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 16:09:53 GMT 2024

Total time taken to generate the page: 0.07273 seconds