Jump to content

Seaholme

Members
  • Posts

    81
  • Joined

  • Last visited

Profile Information

  • Gender
    Female
  • Location
    United Kingdom

Seaholme's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, I'm struggling to solve what seems to be potentially quite a simple problem with my form! It's for a really basic web-based racing game, and basically the issue is that in the form, the option I've named "teamid" isn't sending any information forwards so $newteamid in the next section is always =0, which is the default in the MySQL database. I just don't know how to set it! I want the team id from the first part to send through into the second part. Is it possible to have the value of a form option set to being a variable like this?? //Find their teams and let them pick which team to use $findteams = mysql_query("SELECT * FROM team WHERE owner='$id'") or die(mysql_error()); echo "Select which team to race with:<br><form action='regional.php' method=post> <select name=teamid value=teamid> Team:"; while($row = mysql_fetch_array( $findteams )) { $teamid = $row['id']; echo "<option name=teamid value={$row['id']}>{$row['teamname']}</option>"; } echo '</select>'; echo "<bR><br>Is your team ready to go?<br><br><input type=submit name='stage1' value='Begin Race!'></form><br><br>"; if(isset($_POST['stage1'])) { $_POST['teamid'] = $newteamid; echo $newteamid; $startrace = @mysql_query("INSERT INTO regionals (teamid, stage, ownerid) VALUE ('$newteamid', '1', '$id')") or die("Error: ".mysql_error()); Please let me know if I need to explain or elaborate at all, I'd appreciate any help. Thanks guys!
  2. I apologise in advance if this is a simple question, but essentially I have a forum with the following code: if($a_answer == '') die("You must enter in a reply!"); And my problem is that when nobody enters a reply and it does default to the die option, that nothing subsequent to the die command shows up on the page below it, including the footer of the website, which leaves the whole thing looking very unprofessional. Is there a way to add the website footer into the 'die' command? (I've tried and failed). Or should I be using a different command from die that's more suited to what I'm trying to achieve? The footer is attached to the page via an include command. Any suggestions gratefully received!
  3. Yep, it does. It's a number to say which item it is. I've been thinking about it and I was wondering, is it possible that because one of those lines deletes the item from the database that that is giving the error?
  4. Ah elsewhere in the script, it comes from the URL as a $_GET['id'] type thing. I've checked all of the variables by echoing them out and they do -- also the script itself functions perfectly, which it wouldn't do if any of the variables were wrong. That's kinda why I'm very confused!
  5. Hey all, I keep getting this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2 When I use the script below. I'm finding it a bit confusing because everything about it continues to work, it's just it gives me an error. When the script runs, the outcome is "Success! Your dog now looks far more energetic! Looks like this food is all used up." Followed by the error, which cuts the remainder of the page off. Does anybody know why it's doing this? $dogyay = $_POST['dogid']; $checkenergy = "SELECT energy FROM dogs WHERE id=$dogyay"; $energylevel = mysql_query($checkenergy) or die(mysql_error()); $row = mysql_fetch_array($energylevel) or die(mysql_error()); if($row['energy'] >= 100) { echo "<b>Oops!</b> Looks like your dog is full right now...";} else{ echo "<b>Success! Your dog now looks far more energetic!</b><br><br>"; $sql11="UPDATE dogs SET energy=energy + 50 WHERE id=$dogyay"; $result11=mysql_query($sql11); $sql12="UPDATE items SET uses = uses - 1 WHERE itemid=$id"; $result12=mysql_query($sql12); $checkuses = "SELECT uses FROM items WHERE itemid=$id"; $useslevel = mysql_query($checkuses) or die(mysql_error()); $row = mysql_fetch_array($useslevel) or die(mysql_error()); if($row['uses'] == 0) { echo "Looks like this food is all used up.<bR><br>"; mysql_query("DELETE FROM items WHERE itemid='$id'") or die(mysql_error());} Thanks !
×
×
  • 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.