Jump to content


This topic is now archived and is closed to further replies.


Updateing Infomation In the Database

Recommended Posts


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:
[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<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}

<h1>Who Am I? Game</h1>
$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>";
$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>

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

Share this post

Link to post
Share on other sites
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]

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites


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.