Welcome to Dream.In.Code
Become a PHP Expert!

Join 149,388 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,292 people online right now. Registration is fast and FREE... Join Now!




Problems creating detail page

 
Reply to this topicStart new topic

Problems creating detail page, Trying to pass an id in a php page, but getting an error

NogunShogun
22 Apr, 2007 - 10:12 AM
Post #1

New D.I.C Head
*

Joined: 3 Nov, 2006
Posts: 2


My Contributions
I'm trying create a site that, when you .click using multiple, linked tables. (Comicsmain is the main table, the writer table has information on multiple writers, publisher has publishers, artist has artist names, etc)

For example:
When you click on a page that says publisher, it shows the names of the publisher and the number of database entries that are under that publisher. When you click on the link that says more information, it should bring up information on all of the books by that publisher from the main table (comicsmain) From there, it should let you click on a specific book, and show you all the information on that specific book.

However, I can't get past the step of displaying how many books are published by which publsiher.

When the link is pressed it says to check an error in mySQL syntax near "
Here is the code for my publisher page minus the css, :

CODE
<?php
mysql_select_db($database_firsttry, $firsttry);
$query_Recordset1 = "SELECT comicsmain.publisher, publisher.name, count(publisher.name), comicsmain.price FROM publisher RIGHT OUTER JOIN comicsmain ON publisher.id=comicsmain.publisher GROUP BY name ASC";
$Recordset1 = mysql_query($query_Recordset1, $firsttry) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<?php do { ?>


              <?php echo $row_Recordset1['name']; ?>

                <?php echo $row_Recordset1['count(publisher.name)'];?>

               <a href="detail.php?id=%20<?php echo $row_recordset1['id']; ?>">More  information</a>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<?php mysql_free_result($Recordset1);
?>


and here is the code for the detail page that follows. (also minus the css)

CODE

<?php
$colname_Recordset1 = "1";
if (isset($HTTP_GET_VARS['id'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['id'] : addslashes($HTTP_GET_VARS['id']);
}
mysql_select_db($database_firsttry, $firsttry);
$query_Recordset1 = sprintf("SELECT comicsmain.titles, publisher.name, comicsmain.images FROM comicsmain INNER JOIN publisher ON publisher.id=comicsmain.publisher WHERE publisher.id=%s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $firsttry) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<?php do { ?>
     <a href="info.php?id=<?php echo $row_Recordset1['id']; ?>"><img src="<?php echo $row_Recordset1['images']; ?>" border="0" /></a><br />
      
      
      <?php echo $row_Recordset1['titles']; ?>&nbsp; <?php echo $row_Recordset1['Name']; ?>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>




User is offlineProfile CardPM
+Quote Post

Trogdor
RE: Problems Creating Detail Page
23 Apr, 2007 - 06:22 AM
Post #2

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 549



Thanked: 4 times
Dream Kudos: 125
My Contributions
if you print out the generated query (after that it is generated with sprintf, and before it is executed) you can see why mysql is complaining.
User is offlineProfile CardPM
+Quote Post

menumore
RE: Problems Creating Detail Page
10 Oct, 2007 - 11:25 AM
Post #3

New D.I.C Head
*

Joined: 3 Oct, 2007
Posts: 4


My Contributions
i found this tutorial quite helpful, it solved all of my problems.

http://www.adobe.com/support/dreamweaver/b...tail_php05.html
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Problems Creating Detail Page
11 Oct, 2007 - 03:51 AM
Post #4

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,476



Thanked: 160 times
Dream Kudos: 9025
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
This actually sounds like more of a PHP question than a mySQL Question, moving to the PHP Forum smile.gif
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:59AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month