Jump to content

Archived

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

foreverhex

problem with putting info in MySQL.

Recommended Posts

I have made this code and Im still new at MySQL so I apoligize if it looks buggy. But when you go to submit the info it wont switch any thing and makes the name value 0? Here is the code, any ideas why?

[code]<?php

include 'db.php';

//Grab the reviewed user info

$user = $_POST['user'];
$password = $_POST['password'];
$name = $_POST['name'];
$email = $_POST['email'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$location = $_POST['location'];
$medium = $_POST['medium'];
$interests = $_POST['interests'];
$homepage = $_POST['homepage'];

//New Password check
if ((!$password)) {

$sql = mysql_query("UPDATE users SET name='$name' AND email='$email' AND age='$age' AND sex='$sex' AND location='$location' AND medium='$medium' AND interests='$interests' WHERE user='$user'");

}

else {
$newpassword =md5($password);

$sql = mysql_query("UPDATE users SET password='$newpassword' AND name='$name' AND email='$email' AND age='$age' AND sex='$sex' AND location='$location' AND medium='$medium' AND interests='$interests' WHERE user='$user'");

if(!$sql) {
echo "There has been an error while trying to modify your account. Please report a bug in the forums or try again later.";
}
}

echo 'You information has been updated!';
?>[/code]

Share this post


Link to post
Share on other sites
Replace all the 'AND' in the update with commas. See the UPDATE syntax in the manual:

http://dev.mysql.com/doc/refman/4.1/en/update.html

Share this post


Link to post
Share on other sites
You only to use AND in a query you are comparing somthing to something else, such as within a WHERE clause

Share this post


Link to post
Share on other sites
AHH! I see, so an example would be WHERE user='$user' AND email='$email' . Thats good to know thanks!

Share this post


Link to post
Share on other sites
Yup and you can use it in any other statement

example

if ($user==Bob AND password==bobby){

Share this post


Link to post
Share on other sites
Kick ass! There are some many things I still need to learn but I need to screw up to figure out that I need to know these things.

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.