Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11306 > unrolled thread
| Started by | richard <noreply@example.com> |
|---|---|
| First post | 2013-10-07 12:10 -0400 |
| Last post | 2013-10-07 20:06 +0200 |
| Articles | 9 — 7 participants |
Back to article view | Back to comp.lang.php
Yet another error for some unknown reason richard <noreply@example.com> - 2013-10-07 12:10 -0400
Re: Yet another error for some unknown reason Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2013-10-07 09:20 -0700
Re: Yet another error for some unknown reason richard <noreply@example.com> - 2013-10-07 12:56 -0400
Re: Yet another error for some unknown reason "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> - 2013-10-07 16:23 +0000
Re: Yet another error for some unknown reason Dennis <nobody@nowhere.invalid> - 2013-10-07 13:07 -0400
Re: Yet another error for some unknown reason Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-07 16:43 +0000
Re: Yet another error for some unknown reason Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-07 19:37 +0200
Re: Yet another error for some unknown reason richard <noreply@example.com> - 2013-10-07 12:48 -0400
Re: Yet another error for some unknown reason "J.O. Aho" <user@example.net> - 2013-10-07 20:06 +0200
| From | richard <noreply@example.com> |
|---|---|
| Date | 2013-10-07 12:10 -0400 |
| Subject | Yet another error for some unknown reason |
| Message-ID | <ar44fcpqvv23.4dvziqbqzlxp.dlg@40tude.net> |
<?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.
[toc] | [next] | [standalone]
| From | Daniel Pitts <newsgroup.nospam@virtualinfinity.net> |
|---|---|
| Date | 2013-10-07 09:20 -0700 |
| Message-ID | <rbB4u.25340$Y95.14798@fx31.iad> |
| In reply to | #11306 |
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.
[toc] | [prev] | [next] | [standalone]
| From | richard <noreply@example.com> |
|---|---|
| Date | 2013-10-07 12:56 -0400 |
| Message-ID | <rlamixdusuha$.1jhz87j1vldug.dlg@40tude.net> |
| In reply to | #11307 |
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.
[toc] | [prev] | [next] | [standalone]
| From | "Beauregard T. Shagnasty" <a.nony.mous@example.invalid> |
|---|---|
| Date | 2013-10-07 16:23 +0000 |
| Message-ID | <l2un5v$l5o$1@dont-email.me> |
| In reply to | #11306 |
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
[toc] | [prev] | [next] | [standalone]
| From | Dennis <nobody@nowhere.invalid> |
|---|---|
| Date | 2013-10-07 13:07 -0400 |
| Message-ID | <d8q5591c4h7j04k2t4ftl6r24gs54tu3pp@4ax.com> |
| In reply to | #11308 |
On Mon, 7 Oct 2013 16:23:27 +0000 (UTC), "Beauregard T. Shagnasty"
<a.nony.mous@example.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
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-10-07 16:43 +0000 |
| Message-ID | <l2uobs$bp8$3@dont-email.me> |
| In reply to | #11306 |
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@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-10-07 19:37 +0200 |
| Message-ID | <7660010.il6QMlxOBB@PointedEars.de> |
| In reply to | #11309 |
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).
[toc] | [prev] | [next] | [standalone]
| From | richard <noreply@example.com> |
|---|---|
| Date | 2013-10-07 12:48 -0400 |
| Message-ID | <1thsnq41sc8m7$.1xp2sfbh03ddn$.dlg@40tude.net> |
| In reply to | #11306 |
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!
[toc] | [prev] | [next] | [standalone]
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Date | 2013-10-07 20:06 +0200 |
| Message-ID | <bbgbgbFk2h4U1@mid.individual.net> |
| In reply to | #11310 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web