Jump to content

Klance

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Klance's Achievements

Member

Member (2/5)

0

Reputation

  1. I'm getting this error: Error in query: SELECT MAX(score) FROM GH80 WHERE console = 'PS2' AND diff = 'Expert' AND song = 'Ain't Nothin But A Good Time'. You have an error in your SQL syntax near 't Nothin But A Good Time'' at line 1 Here is the code i'm using: <tr> <td><center><?php (include "PreSong.inc"); ?>&song=Ain't Nothin But A Good Time">Ain't Nothin But A Good Time</a></td></center> <td> <?php $query = "SELECT MAX(score) FROM $game WHERE console = '$console' AND diff = '$diff' AND song = 'Ain't Nothin But A Good Time'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo mysql_result($result, 0); ?> </td> </tr>
  2. Ok, I tried that and it came out with "Resource id #2" Heres the code I used: <?php $host = "localhost"; $user = "root"; $pass = "****"; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); $query = "SELECT MAX(score) FROM GH80"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo $result ?>
  3. I want to display the highest score of a song from the db GHScores the table GH80 and the field Score. The field Score holds all the scores, how do I just pull out just the highest score?
  4. I know you use ORDER BY but i'm not sure about to use it. I want the records to come out on a table ordered by the field Score. Here is what I have: <?php $host = "localhost"; $user = "root"; $pass = "*****"; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); $game = $_GET['game']; $console = $_GET['console']; $diff = $_GET['diff']; $song = $_GET['song']; $query = "SELECT * FROM $game WHERE console = '$console' AND diff = '$diff' AND song = '$song' ORDER BY 'Score'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo "<br><center><table border = '1' bordercolor='gray' cellpadding='3' cellspacing='0'> <tr> <th>Song</th> <th>User</th> <th>Score</th> <th>% of Notes Hit</th> <th>Note Streak</th> <th>Timestamp</th> <th>Comment</th> <th>Picture</th> <th>Video</th> </tr></center>"; if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td><center>".$row['Song']."</td></center>"; echo "<td><center>".$row['User']."</td></center>"; echo "<td><center>".$row['Score']."</td></center>"; echo "<td><center>".$row['NotesHit']."</td></center>"; echo "<td><center>".$row['Streak']."</td></center>"; echo "<td><center>".$row['Timestamp']."</td></center>"; echo "<td><center>".$row['Comment']."</td></center>"; echo "<td><center>".$row['Picture']."</td></center>"; echo "<td><center>".$row['Video']."</td></center>"; echo "</tr>"; } echo "</table>"; } else { echo "None found!"; } ?> I'm not sure why this doesn't work...
  5. Ok, so I have a form where you can enter the type of console and the difficulty of the game and it's put into one table. So say I want to view PS2 difficulty HARD how would I select only records that have console PS2 AND difficulty HARD using a MySQL query?
  6. For some reason $_GET only works at the top of my script. This is the URL: http://24.177.36.183/test/Submit/index.php?game=GH2&console=PS2&diff=Expert and I want to get out the console and difficulty so I used $diff = $_GET['diff']; $console = $_GET['console']; And those work, but for some reason by the time it's ready to enter them into mysql they turn blank. I've tried using the $_GET right before they were entered into mysql and that doesn't make a difference, their still blank. Well heres the script, I hope somone can help. Thanks in advance <?php $diff = $_GET['diff']; $console = $_GET['console']; echo $diff . '<br />'; echo $console; //check to see if form is submitted, if not, show form if (!isset($_POST['submit'])) { ?> <form action="scores.php" method="post"> Song*: <select name="song" size="1"> <option value="">Click Here to Choose a Song</option> <option value="">-----Opening Licks-----</option> <option value="Shout at the Devil">Shout at the Devil</option> <option value="Mother">Mother</option> <option value="Surrender">Surrender</option> <option value="Woman">Woman</option> <option value="Tonight I'm Gonna Rock You Tonight">Tonight I'm Gonna Rock You Tonight</option> <option value=""></option> <option value="">-----Amp-Warmers-----</option> <option value="Strutter">Strutter</option> <option value="Heart-Shaped Box">Heart-Shaped Box</option> <option value="Message in a Bottle">Message in a Bottle</option> <option value="You Really Got Me">You Really Got Me</option> <option value="Carry on Wayward Son">Carry on Wayward Son</option> <option value=""></option> <option value="">-----String-Snappers-----</option> <option value="Monkey Wrench">Monkey Wrench</option> <option value="Them Bones">Them Bones</option> <option value="Search and Destroy">Search and Destroy</option> <option value="Tattooed Love Boys">Tattooed Love Boys</option> <option value="War Pigs">War Pigs</option> <option value=""></option> <option value="">-----Thrash and Burn-----</option> <option value="Cherry Pie">Cherry Pie</option> <option value="Who Was in My Room Last Night">Who Was in My Room Last Night</option> <option value="Girlfriend">Girlfriend</option> <option value="Can't You Hear Me Knockin'">Can't You Hear Me Knockin'</option> <option value="Sweet Child O' Mine">Sweet Child O' Mine</option> <option value=""></option> <option value="">-----Return of the Shred-----</option> <option value="Killing in the Name">Killing in the Name</option> <option value="John the Fisherman">John the Fisherman</option> <option value="Freya">Freya</option> <option value="Bad Reputation">Bad Reputation</option> <option value="Last Child">Last Child</option> <option value=""></option> <option value="">-----Relentless Riffs-----</option> <option value="Crazy on You">Crazy on You</option> <option value="Trippin' On a Hole in a Paper Heart">Trippin' On a Hole in a Paper Heart</option> <option value="Rock This Town">Rock This Town</option> <option value="Jessica">Jessica</option> <option value="Stop">Stop</option> <option value=""></option> <option value="">-----Furious Fretwork-----</option> <option value="Madhouse">Madhouse</option> <option value="Carry Me Home">Carry Me Home</option> <option value="Laid to Rest">Laid to Rest</option> <option value="Psychobilly Freakout">Psychobilly Freakout</option> <option value="YYZ">YYZ</option> <option value=""></option> <option value="">-----Face-Melters-----</option> <option value="Beast and the Harlot">Beast and the Harlot</option> <option value="Institutionalized">Institutionalized</option> <option value="Misirlou">Misirlou</option> <option value="Hangar 18">Hangar 18</option> <option value="Free Bird">Free Bird</option> <option value=""></option> <option value="">-----Bonus Tracks-----</option> <option value="Raw Dog">Raw Dog</option> <option value="Arterial Black">Arterial Black</option> <option value="Collide">Collide</option> <option value="Elephant Bones">Elephant Bones</option> <option value="Fall of Pangea">Fall of Pangea</option> <option value="FTK">FTK</option> <option value="Gemini">Gemini</option> <option value="Push Push (Lady Lightning)"> Push Push (Lady Lightning) </option> <option value="Laughtrack">Laughtrack</option> <option value="Less Talk More Rokk">Less Talk More Rokk</option> <option value="Jordan">Jordan</option> <option value="Mr. Fix It">Mr. Fix It</option> <option value="The New Black">The New Black</option> <option value="One for the Road">One for the Road</option> <option value="Parasite">Parasite</option> <option value="Radium Eyes">Radium Eyes</option> <option value="Red Lottery">Red Lottery</option> <option value="Six">Six</option> <option value="Soy Bomb">Soy Bomb</option> <option value="The Light That Blinds">The Light That Blinds</option> <option value="Thunderhorse">Thunderhorse</option> <option value="Trogdor">Trogdor</option> <option value="X-Stream">X-Stream</option> <option value="Yes We Can">Yes We Can</option> </select> <br /> Score*: <input type="text" name="score" /> <br /> Streak: <input type="text" name="streak" /> <br /> Notes Hit: <input type="text" name="noteshit" /> <br /> Picture: <input type="text" name="picture" /> <br /> Video: <input type="text" name="video" /> <br /> Comment: <input type="text" name="comment" /> <br /> <input type="Submit" value="Submit" name="submit" /> <br /> <?php } else { //process form $host = "localhost"; $user = "root"; $pass = ""; $db = "GHScores"; $conn = mysql_connect($host, $user, $pass) or die("Unable to connect!") ; mysql_select_db($db) or die("Unable to select database!"); echo $diff; echo $console; $user = "klance"; $song = $_POST['song']; $streak = $_POST['streak']; $score = $_POST['score']; $noteshit = $_POST['noteshit']; $picture = $_POST['picture']; $video = $_POST['video']; $comment = $_POST['comment']; $timestamp = date("d/m/y : H:i:s", time()); $query = "INSERT INTO gh2 (Song, User, Score, NotesHit, Streak, Timestamp, Console, Diff, Comment, Picture, Video) VALUES ('$song', '$user', '$score', '$noteshit', '$streak', '$timestamp', '$console', '$diff', '$comment', '$picture', '$video')"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); echo "Score Submitted"; mysql_close($conn); } ?>
  7. Oh I figured it out.. I needed to use: $diff = $HTTP_GET_VARS["diff"];
  8. Klance

    Logout

    session_start() starts a session and session_destroy() destroys a session.
  9. diff does not get set in that form, it gets set on PS2.php here it is: Difficulty: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php echo $_GET['game']; ?>&console=<?php echo $_GET['console']; ?>&diff=Easy">Easy</a> | <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php echo $_GET['game']; ?>&console=<?php echo $_GET['console']; ?>&diff=Medium">Medium</a> | <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php echo $_GET['game']; ?>&console=<?php echo $_GET['console']; ?>&diff=Hard">Hard</a> | <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php echo $_GET['game']; ?>&console=<?php echo $_GET['console']; ?>&diff=Expert">Expert</a> | <br /> <?php if (!empty($_GET['diff'])) { include("scores.php"); } ?>
×
×
  • 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.