Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 9th, 2003, 04:50 AM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #2  
Old October 9th, 2003, 11:11 AM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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...

Reply With Quote
  #3  
Old October 9th, 2003, 02:40 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Link not passing variable to next page

Tried that, this is what I'm getting...

Parse error: parse error, expecting `','' or `';''

Reply With Quote
  #4  
Old October 9th, 2003, 03:13 PM
mathewvp mathewvp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 143 mathewvp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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

Reply With Quote
  #5  
Old October 9th, 2003, 03:18 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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:
Original - php Code
  1.  
  2. <?
  3.  
  4. echo "<td width=110 bgcolor=white><font size=1 face=verdana, times><b>ID:</b>
  5. $id<br>$category</td><td width 115 bgcolor=white><font size=1 face=verdana, times>
  6. <b>Artist:</b><br>$artist_name</font></td><td width=125 bgcolor=white><font size=1
  7. face=verdana, times><b>Song:</b><br>$song_title</font></td><td width=50 bgcolor=white>
  8. <font size=1 face=verdana, times><b><a href="listing.php?id=$row->id">See It</a><br />
  9. </b></font></td><P>";
  10. echo "</tr>";
  11.  
  12. ?>


Reply With Quote
  #6  
Old October 9th, 2003, 03:43 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #7  
Old October 9th, 2003, 04:14 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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...

Reply With Quote
  #8  
Old October 9th, 2003, 04:22 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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:
Original - php Code
  1.  
  2. include("dbinfo.inc.php");
  3. "$id=$_GET['id'];
  4. $dbh=mysql_connect ("localhost", "$username", "$password") or die ('I cannot connect to the database because: ' . mysql_error());
  5. mysql_select_db ("$database");
  6. $query=("SELECT * FROM artist WHERE id='$id'");
  7. $result = mysql_query($query);
  8. $num=mysql_num_rows($result);
  9. $i = 0;
  10. echo "<TABLE width=400 border=0 align=center cellpadding=1 cellspacing=0><tr bgcolor=white>";
  11. while ($i < $num):
  12.    $id=mysql_result($result,$i,"id");
  13.    $fname=mysql_result($result,$i,"fname");
  14.    $email=mysql_result($result,$i,"email");
  15.    $category=mysql_result($result,$i,"category");
  16.    $artist_name=mysql_result($result,$i,"artist_name");
  17.    $song_title=mysql_result($result,$i,"song_title");
  18.    $lyrics=mysql_result($result,$i,"lyrics");
  19.     echo "<td width=80><font size=2 face=verdana, times><b>List #:</b> $id</font></td><td width=160><font size=2 face=verdana, times><b>
  20. Submitted by: </b>$fname</font></td><td width=160><font size=2 face=verdana, times><a href=mailto:>$email</a></font></td></tr>
  21. <tr bgcolor=white><td colspan=3 width=400><font size=2 face=verdana, times><b>Category:</b> $category</font></td></tr>
  22.  <tr bgcolor=white><td colspan=3 width=400><font size=2 face=verdana, times><b>Artist:</b> $artist_name</font></td></tr>
  23. <tr bgcolor=white><td colspan=3 width=400><font size=2 face=verdana, times><b>Song Title:</b> $song_title</font></td></tr>
  24. <tr bgcolor=white><td colspan=3 width=400><font size=2 face=verdana, times>$lyrics</font></td>";
  25.    
  26. echo "</tr>";
  27.    
  28.     $i++;
  29.      
  30.     endwhile;
  31.    
  32. ?> 


Maybe you can spot something I'm overlooking.

Reply With Quote
  #9  
Old October 9th, 2003, 04:29 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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...

Reply With Quote
  #10  
Old October 9th, 2003, 04:34 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
  #11  
Old October 9th, 2003, 04:41 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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

Reply With Quote
  #12  
Old October 9th, 2003, 04:50 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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...

Reply With Quote
  #13  
Old October 9th, 2003, 05:27 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Link not passing variable to next page

delete the double quote before $id=$_GET['id']

Reply With Quote
  #14  
Old October 9th, 2003, 05:45 PM
mdhall mdhall is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 158 mdhall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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?

Reply With Quote