Jump to content

Centurian

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by Centurian

  1. The Goto is so I can add more if statements without getting two results. A bit superfluous though. I found the problem, and it was even earlier than any of this code. But thanks for the help. *fixed*
  2. Thanks, I Applied Zurevs advice: function getcomment($user,$id) { $con = mysql_connect("localhost","jameswit","Jordan"); if (!$con) { echo "Could not connect."; } $lols = mysql_select_db("jameswit_starship", $con); if (!$lols) { echo "Could not select database."; } $result = mysql_query("SELECT * FROM ".$user."Crew WHERE id = ".$id); if (!$result) { echo "No result <BR>"; echo "SELECT * FROM ".$user."Crew"; } while($row = mysql_fetch_array($result)) { if ((int)$row['loyalty']<20) { if ($row['rank']=="XO") { return $row['Name']." is openly mutinous towards you - s/he is not suitable as an XO."; goto endsub; } else { return $row['Name']." is unhappy with your leadership."; goto endsub; } } } endsub: mysql_close($con); } The Quotes were left because PHP was looking for a variable called '$userCrew' when I removed the dots, and I need to words joined with no space between them. The thing with the equals signs was just my inexperience with this language. Thanks for pointing that out. I'm still getting the same error. 'Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/jameswit/www/www/MYSQL.php on line 106'
  3. Sure, but its a pretty massive file. I'll post a good chunk of it. Its part of a function I use in a game I'm making. Basically, it generates a description of a particular unit. It works by connecting to my MySQL database, grabbing the matching data, then using a bunch of if statements to find problems with it. function getcomment($user,$id) { $con = mysql_connect("localhost","admin","******"); if (!$con) { echo "Could not connect."; } $lols = mysql_select_db("********", $con); if (!$lols) { echo "Could not select database."; } $result = mysql_query("SELECT * FROM ".$user."Crew WHERE id = $id "); if (!$result) { echo "No result <BR>"; } while($row = mysql_fetch_array($result)) { if ((int)$row['loyalty']<20) { if ($row['rank']="XO") { return "$row['Name']." is openly mutinous towards you - s/he is not suitable as an XO."; goto endsub; } else { return "$row['Name']." is unhappy with your leadership."; goto endsub; } endsub: } mysql_close($con); }
  4. echo "No result <BR>"; echo "SELECT * FROM ".$user."Crew"; } while($row = mysql_fetch_array($result)) { if ((int)$row['loyalty']<20)
  5. Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or T_NUM_STRING... I'm getting this error for this line: if ((int)$row['loyalty']<20) Thanks in advanced.
  6. Thanks. I'm starting to get the hang of things.
  7. Okay, I am sort of new to PHP and am confused. Here goes: <html> <body> <?php echo "LOGIN5"; $con = mysql_connect("localhost","USERNAME","PASSWORD"); // Connect to the USERS database. $sel = mysql_select_db("centuria_Players", $con); $result = mysql_query("SELECT * FROM UserData WHERE Username='".$_GET('username')."'"); while($row = mysql_fetch_array($result)) { echo $row['Username'] . " " . $row['Password']; echo "<br />"; if ($row['password'] = $_GET('password')) { echo "Your password is correct"; } mysql_close($con); ?> </body> </html> I hope it wasnt too confusing - Basically, the idea is that I have a MYSQL database containing a table called 'UserData'. When the human inputs their password and username, the website finds their entry in this table, and compares the password listed to the password they have provided. This code - put simply - does not work I cant figure out why. Thanks for helping.
×
×
  • 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.