+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Can someone help me with this?

  1. #1
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Can someone help me with this?

    Ok, long story short I'v having trouble with my output. It output's well.... nothing....


    This is the pet store page. It creates the animal the user wants. When it is done it is to store the bought pet at the owner's home page. But for some reason it doesn't show up.....
    Am I like missing a huge chunk of code? or???
    Here are the scripts I built...
    PHP Code:
    <?php
    include ('connect.php');
    ?>

    <form name="form1" method="post" action="petstore.php">
    Registered Name:
    <br>
    <input name="petname" type="text"
    Rabbit Breed:
    <select breed="petbreed"
    <option value="American Chinchilla">American Chinchilla</option>
    <option value"American Fuzzy Lop">American Fuzzy Lop</option>
    <option value"American Sable">American Sable</option>
    <option value"Belgian Hare">Belgian Hare</option>
    <option value"Brittania Petite">Brittania Petite</option>
    <option value"Californian">Californian</option>
    <option value"Champagne D'Argent"> Champagne D'Argent </option>
    <option value"Checkered Giant">Checkered Giant</option>
    <option value"Cinnamon">Cinnamon</option>
    <option value"Creme D'Argent">Creme D'Argent</option>
    <option value"Dutch">Dutch</option>
    <option value"Dwarf Hotot">Dwarf Hotot</option>
    <option value"English Angora">English Angora</option>
    <option value"English Spot">English Spot</option>
    <option value"Flemish Giant">Flemish Giant</option>
    <option value"Florida White ">Florida White </option>
    <option value"Giant Angora">Giant Angora</option>
    <option value"Giant Chinchilla ">Giant Chinchilla </option>
    <option value"French Angora">French Angora</option>
    <option value"Harlequin">Harlequin</option>
    <option value"Havana">Havana</option>
    <option value"Himalayan">Himalayan</option>
    <option value"Holland Lop">Holland Lop</option>
    <option value"Hotot">Hotot</option>
    <option value"Mini Rex">Mini Rex</option>
    <option value"Rex">Rex</option>
    <option value"Satin Angora">Satin Angora</option>
    <option value"Standard Chinchilla ">Standard Chinchilla </option>
    <br>
    pet gender:
    <select name"petgender">
    <option value"male">Male</option>
    <option value"female">Female</option>
    <br>
    Pet Color:
    <select name"petcolor">
    <option value"white">White</option>
    <option value"black">Black</option>
    <option value"gray">Gray</option>
    <br>
    </select>
    <input type="submit" name="submit" value="But It!">
    </form>

    <?php
    $petname 
    trim($_POST['petname']);
    $petbreed trim($_POST['petbreed']);
    $petgender trim($_POST['petgender']);
    $petcolor trim($_POST['petcolor']);
    ?>

    <?php
    $ownerid 
    =$_SESSION['id']
    ?>

    <?php
    $pet 
    =@mysql_query("INSERT INTO pets (ownerid, petname, petbreed, petgender, petcolor) 
    VALUES ('
    $ownerid', '$petname', '$petbreed', '$petgender', '$petcolor')") or die ("error:".mysql_error())
    ?>
    This is the Home page. I want it to display the animal the user just bought.
    PHP Code:
    <?php
    include('connect.php'); 
    ?>

    <?php
    $query
    ="SELECT petname, petbreed, petgender, petcolor FROM pets WHERE ownerid=".$_SESSION['id']."";
    $result mysql_query ($query)
    or die (
    "couldn't execute query.");
    ?>

    <?php
    while ($petmysql_fetch_object ($result))
    {
    ?>



    <?php
    echo
    "
    Registered Name: 
    $petname
    <br>
    Breed: 
    $petbreed
    <br>
    Gender: 
    $petgender
    <br>
    Color: 
    $petcolor
    <br><br>
    "
    ;
    ?>
    <?php
    }
    ?>

  2. #2
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Can someone help me with this?

    PHP Code:
    <input name="petname" type="text">
    Rabbit Breed:
    <
    select breed="petbreed"

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  3. #3
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Can someone help me with this?

    Thanks... that helped but. it still doesn't show the name, breed, gender, and color of the rabbit you bought...

  4. #4
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Can someone help me with this?

    Echo out your query. Chances are its not inserting properly.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  5. #5
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Can someone help me with this?

    I have the echo in there. Did I do it wrong? Is it in the right place?

  6. #6
    toofani's Avatar
    toofani is offline x10Hosting Member toofani is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    33

    Re: Can someone help me with this?

    Quote Originally Posted by salukigirl View Post
    I have the echo in there. Did I do it wrong? Is it in the right place?
    i guess check this:
    <?php
    include('connect.php');
    ?>

    <?php
    $query="SELECT petname, petbreed, petgender, petcolor FROM pets WHERE ownerid=".$_SESSION['id']."";
    $result = mysql_query ($query)
    or die ("couldn't execute query.");
    ?>

    <?php
    while ($pet= mysql_fetch_object ($result))
    {
    ?>



    <?php
    echo
    <br>
    Registered Name: $petname
    <br>
    Breed: $petbreed
    <br>
    Gender: $petgender
    <br>
    Color: $petcolor
    <br><br>



    is this the output you want?
    Registered Name: $petname
    Breed: $petbreed
    Gender: $petgender
    Color: $petcolor
    toofani;)

  7. #7
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: Can someone help me with this?

    I meant echo
    PHP Code:
    "INSERT INTO pets (ownerid, petname, petbreed, petgender, petcolor) 
    VALUES ('
    $ownerid', '$petname', '$petbreed', '$petgender', '$petcolor')" 
    out

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  8. #8
    conker87 is offline x10Hosting Member conker87 is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    65

    Re: Can someone help me with this?

    You're not suppling the values to the variables.

    PHP Code:
    <?php
    include('connect.php'); 

    $query="SELECT petname, petbreed, petgender, petcolor FROM pets WHERE ownerid=".$_SESSION['id'];
    $result mysql_query ($query) or die ("couldn't execute query.");

    while (
    $petmysql_fetch_object ($result))
    {

    echo 
    "Registered Name: "$pet['petname'] ."
    <br>
    Breed: "
    $pet['petbreed'] ."
    <br>
    Gender: "
    $pet['petgender'] ."
    <br>
    Color: "
    $pet['petcolor'] ."
    <br><br>"
    ;

    }
    ?>
    Cleaned up slightly too.
    Last edited by conker87; 10-31-2007 at 06:24 AM.

  9. #9
    salukigirl is offline x10Hosting Member salukigirl is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    78

    Re: Can someone help me with this?

    Quote Originally Posted by conker87 View Post
    You're not suppling the values to the variables.

    PHP Code:
    <?php
    include('connect.php'); 

    $query="SELECT petname, petbreed, petgender, petcolor FROM pets WHERE ownerid=".$_SESSION['id'];
    $result mysql_query ($query) or die ("couldn't execute query.");

    while (
    $petmysql_fetch_object ($result))
    {

    echo 
    "Registered Name: "$pet['petname'] ."
    <br>
    Breed: "
    $pet['petbreed'] ."
    <br>
    Gender: "
    $pet['petgender'] ."
    <br>
    Color: "
    $pet['petcolor'] ."
    <br><br>"
    ;

    }
    ?>
    Cleaned up slightly too.
    That's what I was thinking! -smacks self and feels stupid. I didn't save that info into the varibles.
    Thanks so much! :drool:
    Edit:
    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/star/public_html/bunnygame/home.php on line 10

    ? =(
    Last edited by salukigirl; 10-31-2007 at 12:38 PM. Reason: Automerged Doublepost

  10. #10
    conker87 is offline x10Hosting Member conker87 is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    UK
    Posts
    65

    Re: Can someone help me with this?

    What is line 10?

    Oh wait, I've never used fetch object. Try this:

    Edit: Try this newer one, here's me trying to make an echo look cleaner -.-

    PHP Code:
    <?php
    include('connect.php'); 

    $query="SELECT petname, petbreed, petgender, petcolor FROM pets WHERE ownerid=".$_SESSION['id'];
    $result mysql_query ($query) or die ("couldn't execute query.");

    while (
    $petmysql_fetch_array($result))
    ?>
    Registered Name: <?=$pet['petname']; ?><br>
    Breed: <?=$pet['petbreed']; ?><br>
    Gender: <?=$pet['petgender']; ?><br>
    Color: <?=$pet['petcolor']; ?><br><br>";
    <? ?>
    Last edited by conker87; 10-31-2007 at 01:40 PM.

+ Reply to Thread
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers