Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts

    Error with query string...

    Well, I know mah query strings normally, which is why I cannot for the life of me figure this out...

    PHP Code:
    <form action="http://www.chrysys.net/portfolios.php" method=get>
    <input type="hidden" name="id" value="<? echo $id ?>">
    <a href="http://www.chrysys.net/portfolios.php?id=<? echo $id ?>">
    <?php echo $name ?></a>
    </input>
    </form>
    <td>
    <?php echo $rank ?>
    I don't know why it won't send the data that's included. Each one was properly pulled from the database, so that's not the issue.

    What happens, is when I click the $name in any given field, it takes me to the next page like it should with the url being "Http://www.chrysys.net/porfolios.php?id=1" or whatever I click. But when it does that, for some reason it doesn't pull the data from the database where the id = the one selected.

    Here's my retrieving end:

    PHP Code:
    <?php 
    include("/home/deacon/public_html/critical/includes/profilesconn.php");  

    $id $_GET['id'];

    $sql "SELECT ID,Name,Rank,1,2,3,4,5,About,Interests,Services,Portfolio FROM profile WHERE ID = '".$id."'"
    $result mysql_query$sql ) or die('The error was: ' mysql_error() . '<br />The query was: ' $sql); 
    while(
    $row mysql_fetch_array($result));
    {
            
    $id $row['ID']; 
            
    $name $row['Name']; 
            
    $rank $row['Rank'];
            
    $_1 $row['1']; 
            
    $_2 $row['2']; 
            
    $_3 $row['3'];
            
    $_4 $row['4']; 
            
    $_5 $row['5']; 
            
    $about $row['About']; 
            
    $interests $row['Interests']; 
            
    $services $row['Services'];
            
    $portfolio $row['Portfolio']; 
    }
    ?>
    I've managed to isolate the problem to the link, trying to get the data inside that for the next page, but I just can't seem to work it. I know that since it takes me to id=1, that the information is on the page, but for some reason it won't send to the next page.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Is your HTML validating? Cuz, I'm not going to swear by it, but I don't think it's valid to stick an anchor inside a hidden input tag like what you've done. You should be closing that hidden input tag immediately and then do the anchor.

  • #3
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts
    Yeah should it not be:

    PHP Code:
    <form action="http://www.chrysys.net/portfolios.php" method=get>
    <input type="hidden" name="id" value="<? echo $id ?>">
    <a href="http://www.chrysys.net/portfolios.php?id=<? echo $id ?>"><?php echo $name ?></a>
    </form>
    <td>
    <?php echo $rank ?>
    I never used </input> in HTML, at the moment in XHTML i use <input/> but even so.

  • #4
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Lol, this was my last attempt . Nothing has worked up to this point, and everything I've done (from not using a form and just doing the url, to what you see now) hasn't worked. I've used 5 different techniques to send the data, but for some reason, none of them work. It won't pull data from the database in portfolios.php?id=, and the isolated reason is that the id from the previous page doesn't load properly to send to the next page. So when it tries to select from the database where id=$id since $id is an unassigned value, it can't select anything.

    That's my problem.

  • #5
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts
    Oh I see what your trying to do. Hold on reserved post.

    PHP Code:
    <a href="http://www.chrysys.net/portfolios.php?id=<? echo $id ?>"><?php echo $name ?></a>
    PHP Code:
    $sql "SELECT `ID`,`Name`,`Rank`,`1`,`2`,`3`,`4`,`5`,`About`,`Interests`,`Services`,`Portfolio` FROM `profile` WHERE `ID` = '".$id."'"
    You don't need the url to be in the form, get variables are retrieved from the URL so the form isn't needed just replace the form with that url above. Secondly, as trivial as it is sometimes just adding ` to your sql elements makes a difference. It fixed my strange error before, wouldn't work then but worked after. I'm still not sure EXACTLY what the problem is but try it.
    Last edited by flynch01; 03-14-2008 at 02:35 AM.

  • #6
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Nope...

    here:

    http://www.chrysys.net/portfolio.php

    click "Browse all portfolios" at the top.

    Click "Deacon"

    and you'll see. The image is set in the html, not the database.

    But yeah, it didn't work, i dunno why...

    Here are all three pages:

    PHP Code:
    <?php include("/home/deacon/public_html/critical/includes/header.php"); ?> 

    <body> 

    <div class="left"> 
       
        <ul> 
        <li><a href="index.php">Home</a></li> 
        <li class="active"><a href="portfolio.php">Portfolio</a></li> 
        <li><a href="services.php">Services</a></li> 
        <li><a href="contact.php">Contact</a></li> 
        </ul> 
         
    </div> 

    <div class="right"> 


    <div class="content"> 
    <?php  
    $id 
    $_GET['id'];  

         if(!isset(
    $id)){  
              include(
    "/home/deacon/public_html/portfolios1.php"); 
         }  
         else  
        {  
              include(
    "/home/deacon/public_html/portfolios2.php"); 
         }  
    //repeat for all styles/pages.  
    ?>  

    <? include("/home/deacon/public_html/critical/includes/footer.php"); ?>
    PHP Code:
    <?php 
    include("/home/deacon/public_html/critical/includes/profilesconn.php");  
    $sql "SELECT ID,Name,Rank FROM profile ORDER BY ID LIMIT 30"
    $result mysql_query$sql ) or die('The error was: ' mysql_error() . '<br>The query was: ' $sql); 
    $num mysql_num_rows($result);
    if(
    $num 0)
    {
        while(
    $row mysql_fetch_assoc($result))
        {
            
    $id $row['ID']; 
            
    $name $row['Name']; 
            
    $rank $row['Rank']; 
    ?>

    <center>
    <table width="75%"> 
    <tr> 
    <td>
    <h1>ID</h1>
    <td>
    <h1>Name</h1>
    <td>
    <h1>Rank</h1>
    <tr>
    <td>
    <?php echo $id ?>
    <td>
    <a href="http://www.chrysys.net/portfolios.php?id=<? echo $id ?>"><?php echo $name ?></a> 
    </input>
    </form>
    <td>
    <?php echo $rank ?>
    </td>
    </tr> 
    </table>
    <?php
        
    }
    }
    ?> 
    </center>
    PHP Code:
    <?php 
    include("/home/deacon/public_html/critical/includes/profilesconn.php");  

    $id $_GET['id'];

    $sql "SELECT `ID`,`Name`,`Rank`,`1`,`2`,`3`,`4`,`5`,`About`,`Interests`,`Services`,`Portfolio` FROM `profile` WHERE `ID` = '".$id."'"
    $result mysql_query$sql ) or die('The error was: ' mysql_error() . '<br />The query was: ' $sql); 
    while(
    $row mysql_fetch_array($result));
    {
            
    $id $row['ID']; 
            
    $name $row['Name']; 
            
    $rank $row['Rank'];
            
    $_1 $row['1']; 
            
    $_2 $row['2']; 
            
    $_3 $row['3'];
            
    $_4 $row['4']; 
            
    $_5 $row['5']; 
            
    $about $row['About']; 
            
    $interests $row['Interests']; 
            
    $services $row['Services'];
            
    $portfolio $row['Portfolio']; 
    }
    ?>




    <table width="75%">
    <tr>
    <td>
    <a href="http://www.chrysys.net"><img src="/critical/images/me.jpg" alt="Find All of Deacon's Work" width="150" height="200" align="left" /></a>
    <h1><? echo $name?></h1>
    <h2><? echo $rank?></h2>
    <hr>
    <center><h2>Best Top 5</h2>
    <ol>
    <li><span><? echo $_1?></span></li>
    <li><span><? echo $_2?></span></li>
    <li><span><? echo $_3?></span></li>
    <li><span><? echo $_4?></span></li>
    <li><span><? echo $_5?></span></li>
    </ol>
    </center>
    </td>
    </tr>
    </table>

    <table width="75%">
    <tr>
    <td align>
    <h2>About Me</h2>
    <?php echo $about?>
    </td>
    </tr>
    </table>

    <br /><br />

    <table width="75%">
    <tr>
    <td>
    <h2>My Interests</h2>
    <?php echo $interests?>
    </td>
    </tr>
    </table>


    <br /><br />

    <table width="75%">
    <tr>
    <td>
    <h2>My Services</h2>
    <?php echo $services?>
    </td>
    </tr>
    </table>


    <br /><br />

    <table width="75%">
    <tr>
    <td>
    <h2>My Portfolio</h2>
    <?php echo $portfolio?>
    </td>
    </tr>
    </table>

    They go in that order.

  • #7
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Quote Originally Posted by Deacon Frost View Post
    PHP Code:
    <form action="http://www.chrysys.net/portfolios.php" method=get>
    ... 
    Perhaps you need method="get". Double quotes.

  • #8
    Regular Coder Deacon Frost's Avatar
    Join Date
    Feb 2008
    Location
    Between the Lines
    Posts
    279
    Thanks
    31
    Thanked 4 Times in 4 Posts
    Nah, I was really stupid when I did this. I couldn't use a form (which was my last attempt)..

    So I solved it using the methods taught by learning C++ :P.

    Basically I used the fetch_num_rows to see if the data was getting to the page, then I echoed it to display, and when I saw the '1' I realized that it did in fact pull the information for the prior page.

    my error was here:

    PHP Code:
    while($row mysql_fetch_array($result)); 
    which I changed to

    PHP Code:
    $row mysql_fetch_assoc($result); 

    Which solved it :P.


    Thanks to all who attempted . (Sorry for not trying a lil harder =/)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •