Jump to content


Photo

DO..LOOP Query not working


  • Please log in to reply
6 replies to this topic

#1 Lokolo

Lokolo
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 15 October 2006 - 08:25 PM

Pastebin being a pain.

<?php
session_start();
include("function.php");
db_sign_in();
$name = $_POST['name'];
$password = MD5($_POST['password']);
$civ = $_POST['civ'];
$email = $_POST['email'];
do {
srand((double)microtime()*1000000);
$mapcoord = rand(0,100);
$isitfree = mysql_query("SELECT free FROM map WHERE ($mapcoord = ID)")
} while ($isitfree <>1);

$check_query = mysql_query("INSERT INTO accounts VALUES ('$name','$password','$email')");
$add_player_query = mysql_query("INSERT INTO players (name, civ, r1, r2, r3, mapID) VALUES ('$name', '$civ', 100, 100, 100, '$mapcoord')");
if ( $civ = "arthurian" ) {
$add_civart_query = mysql_query("INSERT INTO arthurian VALUES ('$name', 100, 100, 100, 5)");
} else {
$add_civazt_query = mysql_query("INSERT INTO aztec VALUES ('$name', 150, 150, 60, 5)");
}
$_SESSION[registered] = "1";
redirect("0","register.php");

?>

Hm, can't see whats wrong. Basically I need to get a random number 1-100, then check whether this item in the list has free of = 1 or not. Bit complicated, ask if you don't understand parts.

Thanks in advance.

Lokolo

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 15 October 2006 - 09:31 PM

Not sure why you wouldn't just do this in MySQL, which also has a rand function.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 Lokolo

Lokolo
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 16 October 2006 - 08:24 PM

because i didn't know one existed - time for google :P

[edit] still doesn't work though
Parse error: parse error in c:\phpdev\www\register2.php on line 13

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 16 October 2006 - 10:03 PM

$isitfree = mysql_query("SELECT free FROM map WHERE ID = '$mapcoord'")

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Lokolo

Lokolo
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 17 October 2006 - 04:38 PM

same error heh, makes no sense to me :-/

#6 LazyJones

LazyJones
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 17 October 2006 - 06:32 PM

would ; in end of the line do the trick?

#7 Lokolo

Lokolo
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 18 October 2006 - 02:46 PM

lol thats hated. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users