Jump to content

MattC

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MattC's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm trying to write a script that shows movies a user has entered to a site. If they don't have any movies, a message comes up saying they haven't submitted anything yet. Here is the code I am trying to use: $base_dir = "../"; include ($base_dir . "elements/db-connect.php"); //Grab the variables $user_id = $HTTP_GET_VARS["u"]; // simple query to get total no of entries $countq = mysql_query("SELECT count( * ) FROM sc_topics WHERE ( topic_poster = '$user_id' )"); $total = mysql_result($countq, 0, 0); if ($total == 0) { echo "No entries yet."; } elseif ($total > 0) { //Get top 5 Showcase entries $sql3a ="SELECT t.topic_id, t.topic_title, r.Rating FROM sc_topics t, sc_ratings r WHERE topic_poster = '$user_id' AND t.topic_id = r.Item ORDER BY r.Rating DESC LIMIT 5"; $result3a = mysql_query($sql3a); while ($row = mysql_fetch_array($result3a)); { $movie_title = $row['topic_title']; $movie_id = $row['topic_id']; echo " <span class=gensmall> <a href=\"http://showcase.sfdt.com/viewmovie.php?t=$movie_id\">$movie_title</a> </span> <br> "; } } The problem is that it will show the text if they have no entries, but nothing shows up if they have the entries. It runs that part of the loop, but none of the variables come through. I've tried a lot of different ways of coding this, what am I missing?
  2. Okay, the $_Post problem proved to be it. I need to be more thorough next time. Thanks for the help.
  3. Hello, I've been dealing with website for quite a while, but only now am getting into PHP coding. I copied some code from Jason Gilmore's book about inserting data into a mySQL database. Basically, I have two files: [b]insert.php[/b] [code] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <P> Product ID: <input type="text" name="productid" size="8" maxlength="8" value="" /> </p> <p> Name: <input type="text" name="name" size="25" maxlength="25" value="" /> </p> <p> Price: <input type="text" name="price" size="6" maxlength="6" value="" /> </p> <p> Description: <textarea name="description" rows="5" cols="30"></textarea> </p> <p> <input type="submit" name="submit" value="Submit!" /> </p> </form> [/code] [b]test.php[/b] [code] <?php     //If submit button has been pressed     if (isset($POST['submit']))     {         //Connect to the server and select the database         $linkID = @mysql_connect("localhost","username","password")             or die("Could not connect to my SQL server");         @mysql_select_db("sqltesting") or die("Could not connect to database");         //Retrieve the posted product information.         $productid = $_POST['productid'];         $name = $_POST['name'];         $price = $_POST['price'];         $description = $POST['description'];         //Insert the info into the prodict table         $query = "INSERT INTO product SET productid='$productid', name='$name', price='$price', description='$description'";         $result = mysql_query($query);         //Display the appropriate message         if ($result) echo "<p>Product info has been entered.</p>";         else echo "<p>You screwed up.</p>";         mysql_close();         } //Include the insertion form include "insert.php"; ?> [/code] I bring up test.php in the browser, fill it out and hit Submit. This brings me right back to the form with no data entered in it at all. Even if I setup the wrong database information, I get no error messages about connecting. Am I going about this the wrong way? I've checked the code over many times and can't find anything wrong with it. Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.