|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Link not passing variable to next page
My project is a song lyric database. Each row will contain id, category, artist_name, song_title, and lyrics. I have the initial search results show just the category, artist and title. I want to display along with these 3 a link which will go to another page, which will list all of the fields in that row that the 3 came from. The following is the major bits and pieces of code I've found, which I've been told is supposed to do this, but I havent been able to get it to work. (The html I added, might need some tweaking)
$query=("SELECT id,category,artist_name,song_title FROM artist WHERE artist_name LIKE '$searchartist' OR song_title LIKE '$searchtitle' OR category LIKE '$searchcategory'"); $result = mysql_query($query); $num=mysql_num_rows($result); $i = 0; echo "<TABLE width=400 border=0 align=center cellpadding=4 cellspacing=0> <tr>"; while ($i < $num): $id=mysql_result($result,$i,"id"); $category=mysql_result($result,$i,"category"); $artist_name=mysql_result($result,$i,"artist_name"); $song_title=mysql_result($result,$i,"song_title"); echo "<td width=110 bgcolor=white> <font size=1 face=verdana, times> <b>ID:</b>$id<br>$category</td> <td width 115 bgcolor=white> <font size=1 face=verdana, times><b>Artist:</b><br>$artist_name</font></td> <td width=125 bgcolor=white><font size=1 face=verdana, times><b>Song:</b><br>$song_title</font></td> <td width=50 bgcolor=white><font size=1 face=verdana, times> <b>echo '<a href="listing.php?id='.$row->id.'">'.$row->See It'</a><br />'; </b></font></td><P>"; echo "</tr>"; $i++; endwhile; Like I said, not sure what the problem is, but I'm getting parse errors for the line which has echo '<a href="listing.php?id='.$row->id.'">'.$row->See It'</a><br />'; Any help is appreciated |
|
#2
|
|||
|
|||
|
RE: Link not passing variable to next page
you have not closed your first echo statement before starting the next one. delete the echo statemnet before the link and remove the single quotes around the href tag. Minor syntax errors is all that is wrong...
|
|
#3
|
|||
|
|||
|
RE: Link not passing variable to next page
Tried that, this is what I'm getting...
Parse error: parse error, expecting `','' or `';'' |
|
#4
|
|||
|
|||
|
RE: Link not passing variable to next page
Your second echo is statement is also missing the ending double quotes and semicolon.Its syntax error,check on the line specified or the line before that
|
|
#5
|
|||||
|
|||||
|
RE: Link not passing variable to next page
you had bad combinations of single and double quotes in the echo statement that was causing the errors. Here is the corrected code, study both yours and mine to see the differences.
php Code:
|
|
#6
|
|||
|
|||
|
RE: Link not passing variable to next page
OK, I spotted the differences in the syntax, thnx. No ore parse errors, but the page that it goes to isnt showing the row. I have the
$id = $_GET['id']; statement in it, but no results. |
|
#7
|
|||
|
|||
|
RE: Link not passing variable to next page
try echoing the $id variable before your query is run to see if it is even making it to the new page. if it is, there might be a problem wth the code on the new page...
|
|
#8
|
|||||
|
|||||
|
RE: Link not passing variable to next page
I earlier used a form pointing to listing.php where I added the row id and the row came up fine. Heres the current page the link goes to.
php Code:
Maybe you can spot something I'm overlooking. |
|
#9
|
|||
|
|||
|
RE: Link not passing variable to next page
did you try echoing the $id variable? if it shows up, try echoing the query to see if it is being formed properly...
|
|
#10
|
|||
|
|||
|
RE: Link not passing variable to next page
To be honest, I'm not sure how to go about doing that. Sorry for the ignorance on my part.
|
|
#11
|
|||
|
|||
|
RE: Link not passing variable to next page
after you assigning the value to $id, type the following...
echo "id=".$id; then right after you build the query type the following... echo "query=".$query; run the script and see what is output |
|
#12
|
|||
|
|||
|
RE: Link not passing variable to next page
Hope this is what you meant to do...
"$id=$_GET['id']; echo "id=".$id; $query=("SELECT * FROM artist WHERE id='$id'"); echo "query=".$query; This is what I get... Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' Sorry I'm totally lost here... |
|
#13
|
|||
|
|||
|
RE: Link not passing variable to next page
delete the double quote before $id=$_GET['id']
|
|
#14
|
|||
|
|||
|
RE: Link not passing variable to next page
That eliminated the parse errors, but the second page still doesnt display anything. I noticed that when I hover the cursor over the link, the status bar shows
listing.php?id= Should this be showing more? |