Jump to content


Photo

Updateing Infomation In the Database


  • Please log in to reply
2 replies to this topic

#1 alexville

alexville
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 26 March 2006 - 02:30 PM

Hello,

I am making a PHP game and I need help with updating the "user"'s account infomation the database.

I have 2 pages at the moment. One of them contains the form. The other contains the PHP code. Heres the PHP code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Who Am I? Game - Assikinack Edition</title>
<style type="text/css">
<!--
body {
    background-color: #CCCCCC;
}
body,td,th {
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
}
.style1 {font-family: "Courier New", Courier, mono}
-->
</style></head>

<body>
<h1>Who Am I? Game</h1>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$clueone = $_POST['clueone'];
$cluetwo = $_POST['cluetwo'];
$cluethree = $_POST['cluethree'];
// *End* ~Get the 'username' varible from flash~
// Disply my famous welcome message
echo "Updating Your Account Info...";
// *End* ~Disply my famous welcome message
// End PHP code for now and create HTML divider
// Start database connection
$dbcnx = @mysql_connect("localhost","username","password");
if (!$dbcnx) {
echo "<p>Unable to connect to the database server at this time.</p>";
exit();
}
mysql_select_db("alexg_web",$dbcnx);
$result = @mysql_query("UPDATE whoamipeople SET Clue='$clueone' AND Cluetwo='$cluetwo' AND Cluethree='cluethree' WHERE Username = '$username' AND Password = '$password'");
if (!$result) {
exit("<p>Sorry, There must be a problem with your Username or Password. Please press back on your browser and retype the infomation. Here is the mysql error: " . mysql_error() . "</p>");
} else {
echo "<p> Your Infomation Has Been Updated! </p>"
// swich back to html mode to create divider
?>
<p>S<a href="http://www.whoami.alexville.com/game.htm">ign-Out</a></p>
<hr>
</html>

I think I have a problem with the UPDATE function. Please help me.

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 26 March 2006 - 02:51 PM

Replace the 'AND' with commas. See update syntax in manual:

[a href=\"http://dev.mysql.com/doc/refman/4.1/en/update.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/4.1/en/update.html[/a]


#3 alexville

alexville
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 26 March 2006 - 09:29 PM

UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]

I just want to use data collected from a form. Does anyone have an example i could use?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users