FUDforum - خوراک RDF
http://fudforum.org/forum/index.php
values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181557&th=123057#msg_181557
I am attempting to change the play list given the year selected.
However, regardless of which year is chosen, the code selects only the
originally loaded playlist.
What am I missing?
<?php
$year=$_GET["year"];
if (empty($year)) {$year=1900;}
$year=(int)$year;
echo $year;
if ($year=1900)
{echo '<iframe width="800" height="800" src="test2.php"
frameborder="0"></iframe>';}
if ($year>1900)
{
/* connect to the db */
$con = mysql_connect('localhost','user','pass');
if (!$con){die("can not connect: " . mysql_error());}
mysql_select_db('richbull_top100',$con);
while ($number<=10):
$result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
$number");
if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
$vid = mysql_fetch_row($result);
?>]]>richard2013-05-21T18:17:13-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181558&th=123057#msg_181558
> if ($year=1900)
That is an assignment to $year; instead you'll want to use:
if ($year == 1900)
--
Christoph M. Becker]]>Christoph Becker2013-05-21T18:45:08-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181561&th=123057#msg_181561
> What am I missing?
Pick from:
1) A possible issue with using attribute names instead of attribute name
strings that has already been mentioned to you once.
2) A broken numeric comparison that's been explained elsewhere.
3) Sufficient understanding of php and javascript to safely generate the
latter using the former.
4) All of the above.
My money is on 4.
The data you are assembling looks like json data. For json data, you need
to quote the attribute name string. The json needs double quoted strings,
so as you also need to use php double quoted strings to preserve variable
substitution, you need to use escaped double quoted strings for the json
string values.
--
Denis McMahon, denismfmcmahon@gmail.com]]>Denis McMahon2013-05-21T21:17:15-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181562&th=123057#msg_181562
> On Tue, 21 May 2013 14:17:13 -0400, richard wrote:
>> What am I missing?
>
> Pick from:
>
> 1) A possible issue with using attribute names instead of attribute name
> strings that has already been mentioned to you once.
There still is no such issue here, and there are still no “attribute names”
in ECMAScript implementations. Which has already been explained to you as
well.
PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14]]>Thomas 'PointedEars' 2013-05-21T22:22:42-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181563&th=123057#msg_181563
noreply@example.com> wrote in news:14jsq8i4oxkxn.r427ym6k6zgn$.dlg@
40tude.net:
> www.mroldies.net
>
> I am attempting to change the play list given the year selected.
> However, regardless of which year is chosen, the code selects only the
> originally loaded playlist.
[...]
> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
> $number");
You have a separate table for each year!? Why?]]>Doug Miller2013-05-21T22:23:08-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181564&th=123057#msg_181564
> The data you are assembling looks like json data. For json data, you need
> to quote the attribute name string. The json needs double quoted strings,
> so as you also need to use php double quoted strings to preserve variable
> substitution, you need to use escaped double quoted strings for the json
> string values.
>
> echo "{\"image\":\"\",";
> echo "\"title\":\"{$vid[0]}\",";
> echo "\"file\":\"http://www.youtube.com/watch?v={$vid[2]}\",";
> echo "\"description\":\"{$year} # {$number} - {$vid[1]}\"},";
Assuming JSON, it is much better (if not even the only *correct* way) to
write
Because you cannot simply insert arbitrary strings in a generated string
literal and hope the outcome will be correct JSON; *at least* you would have
to escape slashes in the inserted strings, and you do not have to do that by
yourself if you use json_encode() in the first place. AISB.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee]]>Thomas 'PointedEars' 2013-05-21T22:30:24-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181565&th=123057#msg_181565
> Assuming JSON, it is much better (if not even the only *correct* way) to
> write
>
> echo json_encode(array(
> 'image' => '',
> 'title' => $vid[0],
> 'file' => "http://www.youtube.com/watch?v={$vid[2]}",
> 'description' => "{$year} # {$number} - {$vid[1]}"
> ));
>
> Because you cannot simply insert arbitrary strings in a generated string
> literal and hope the outcome will be correct JSON; *at least* you would
> have to escape slashes in the inserted strings, and you do not have to do
^ with back-
> that by yourself if you use json_encode() in the first place. AISB.
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann]]>Thomas 'PointedEars' 2013-05-21T22:32:02-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181566&th=123057#msg_181566
> www.mroldies.net
>
> I am attempting to change the play list given the year selected.
> However, regardless of which year is chosen, the code selects only the
> originally loaded playlist.
>
> What am I missing?
>
>
>
> <?php
>
> $year=$_GET["year"];
> if (empty($year)) {$year=1900;}
> $year=(int)$year;
>
> echo $year;
>
> if ($year=1900)
> {echo '<iframe width="800" height="800" src="test2.php"
> frameborder="0"></iframe>';}
>
> if ($year>1900)
> {
> /* connect to the db */
> $con = mysql_connect('localhost','user','pass');
>
>
> if (!$con){die("can not connect: " . mysql_error());}
>
> mysql_select_db('richbull_top100',$con);
>
> while ($number<=10):
> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
> $number");
> if (!$result) { echo 'Could not run query: ' . mysql_error(); exit; }
<SNIP> rest of script
In addition to the problems mentioned by others:
you haven't initialised $number for use in the while loop;
the above while loop causes a number of queries to be run, instead you could
use BETWEEN in the query to select matching records for values of id BETWEEN
n and 10;
you have no graceful handling of an error when running a query - the script
just dies
--
Cheers
David Robley
Useless Invention: Soap Dissolver.]]>David Robley2013-05-22T00:32:22-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181570&th=123057#msg_181570
> richard <noreply@example.com> wrote in news:14jsq8i4oxkxn.r427ym6k6zgn$.dlg@
> 40tude.net:
>
>> www.mroldies.net
>>
>> I am attempting to change the play list given the year selected.
>> However, regardless of which year is chosen, the code selects only the
>> originally loaded playlist.
> [...]
>> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
>> $number");
>
> You have a separate table for each year!? Why?
It's richard.
--
The trouble with things that extend your lifespan is that they happen
at wrong end. I'd hate to be wearing Depends at 85 and thinking "I gave
up booze and cigarettes for three more years of this."]]>Peter H. Coffin2013-05-22T02:46:51-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181571&th=123057#msg_181571
> richard <noreply@example.com> wrote in news:14jsq8i4oxkxn.r427ym6k6zgn$.dlg@
> 40tude.net:
>
>> www.mroldies.net
>>
>> I am attempting to change the play list given the year selected.
>> However, regardless of which year is chosen, the code selects only the
>> originally loaded playlist.
> [...]
>> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
>> $number");
>
> You have a separate table for each year!? Why?
To me, it's easier keeping track of the data.
Sure I could easily do it all in one table, adding in yet another column
for the year.
When I finish entering ALL of the data I need, there will be around 7,000
records to deal with.]]>richard2013-05-22T03:40:48-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181575&th=123057#msg_181575
noreply@example.com> wrote in news:1hd4q922lq4b8$.puef8n3pevc9$.dlg@
40tude.net:
> On Tue, 21 May 2013 22:23:08 +0000 (UTC), Doug Miller wrote:
>
>> richard <noreply@example.com> wrote in news:14jsq8i4oxkxn.r427ym6k6zgn$.dlg@
>> 40tude.net:
>>
>>> www.mroldies.net
>>>
>>> I am attempting to change the play list given the year selected.
>>> However, regardless of which year is chosen, the code selects only the
>>> originally loaded playlist.
>> [...]
>>> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
>>> $number");
>>
>> You have a separate table for each year!? Why?
>
> To me, it's easier keeping track of the data.
???
How on earth is fifty separate tables "easier" than ONE table??
> Sure I could easily do it all in one table, adding in yet another column
> for the year.
Well, yes, you could -- after all, that's the way such things are normally done.
>
> When I finish entering ALL of the data I need, there will be around 7,000
> records to deal with.
And -- ?
As databases go, seven thousand rows is tiny.]]>Doug Miller2013-05-22T10:34:48-00:00Re: values not changing
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=181577&th=123057#msg_181577
> On Tue, 21 May 2013 22:23:08 +0000 (UTC), Doug Miller wrote:
>
>> richard <noreply@example.com> wrote in news:14jsq8i4oxkxn.r427ym6k6zgn$.dlg@
>> 40tude.net:
>>
>>> www.mroldies.net
>>>
>>> I am attempting to change the play list given the year selected.
>>> However, regardless of which year is chosen, the code selects only the
>>> originally loaded playlist.
>> [...]
>>> $result = mysql_query("SELECT atitle,artist,avid FROM A$year WHERE id =
>>> $number");
>>
>> You have a separate table for each year!? Why?
>
> To me, it's easier keeping track of the data.
> Sure I could easily do it all in one table, adding in yet another column
> for the year.
Or why not have a 'single' column of Year and then just change the value
of the year for each year record/item
With a separate table per year, among other issues, what if you
want/need to add an extra data column to the table, you now have to do
it for each year table to ensure they are all consistent.
It just seems that you are going to have a maintenance & update
nightmare ahead of you.
>
> When I finish entering ALL of the data I need, there will be around 7,000
> records to deal with.
Another good idea to not separate your tables]]>Scott Johnson2013-05-22T12:41:37-00:00