hi,
i am having trouble echoing from posted page, in the url it shows the send id but it gives me error for this query
$_GET['$songs_set["id"]'];
and i get this error
Undefined index: $songs_set[“id”]
hi,
i am having trouble echoing from posted page, in the url it shows the send id but it gives me error for this query
$_GET['$songs_set["id"]'];
and i get this error
Undefined index: $songs_set[“id”]
What does the url look like?
My guess is it should be:
$_GET['id'];
I’m guessing actually you’ve gotten your arrays backwards.
Were you trying to do $songs_set[$_GET[‘id’]] ?
single.php?song =1
yes
single.php?song =1
I hope there is no space between song and =
there is and i was wondering if that is the reason
edit : i fixed the gap
The undefined index error is because you had things mixed up like StarLion said.
Change your code like he told you, and try again.
i still get the error
$_REQUEST['id'];
$song = $_REQUEST["id"];
Notice: Undefined index: id
Notice: Undefined index: $songs_set[“id”]
Because the variable name isn’t ‘id’, but ‘song’. You called it that way in the query string.
single.php?key=value
$_GET[‘key’] contains value
single.php?song=1 (get rid of that space)
$_GET[‘song’] contains 1
i didn’t got any of it.:sick:
Let’s add some color:
single.php?[B][COLOR="Red"]key[/COLOR][/B]=[COLOR="DeepSkyBlue"][B]value[/B][/COLOR]
$_GET['[B][COLOR="Red"]key[/COLOR][/B]'] contains [B][COLOR="deepskyblue"]value[/COLOR][/B]
single.php?[B][COLOR="Red"]song[/COLOR][/B]=[B][COLOR="deepskyblue"]1[/COLOR][/B]
$_GET['[B][COLOR="Red"]song[/COLOR][/B]'] contains [B][COLOR="deepskyblue"]1[/COLOR][/B]
I can’t explain it any clearer than that.
Do a print_r($_GET); in your code to see the contents of $_GET.
i don’t know what is wrong. i am reading a tut too it says the same about passing and getting value, this is page 1
<a href=\\"single.php?song=key{$songs_set["id"]}\\">".$songs_set["title"]."</a>
this is page 2
$song = $_REQUEST['id'];
and i m echoing on page 2
echo $song;
here is my code
<form action="single.php" method="post">
<div class="songslist">
<table class="songs" width="1020" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="281">Artist</th>
<th width="281">Title</th>
<th width="204">Length</th>
<th width="204">Genre</th>
<th width="50">Ratings</th>
</tr>
</table>
<table class="songs" width="1020" border="0" cellpadding="0" cellspacing="0">
<tr>
<?php
$songs = mysql_query("SELECT * FROM songs LIMIT 10");
if($songs){
echo mysql_error();
}
while($songs_set = mysql_fetch_array($songs)){
echo "<tr>
<td width=\\"281\\">".$songs_set["artist"]."</td>"
. "<td width=\\"281\\"><a href=\\"single.php?song={$songs_set["id"]}\\">".$songs_set["title"]."</a></td>"
. "<td width=\\"204\\">".$songs_set["length"]."</td>"
. "<td width=\\"204\\">".$songs_set["genre"]."</td>"
. "<td width=\\"50\\">".$songs_set["rating"]."</td><tr>";
}
?>
</table>
</div>
</form>
and here is the single page
<?php
$song = $_REQUEST['id'];
echo "$song";
?>
now can u guide me where am i going wrong?
single.php?song=1
$_REQUEST[‘id’];
This is where you’re going wrong.
Like I told you, do a print_r($_GET); in your code (or a print_r($_REQUEST); ), and you’ll see what exactly is sent to single.php
its a empty Array. i still don’t understand what i m going wrong
Change
song={$songs_set["id"]}
in
song={$songs_set['id']}
That line should have given you an error though.
u told me to remove double quotes. but it didn’t solve the undefined index error on next page
Did you change id to song?
[QUOTE=guido2004;4881072]Did you change id to song?[/QUOTE} still undefined index error