Re: [PHP] PHP & MySQL problems, updating database..

2002-01-17 Thread Miles Thompson

Hawk,

If you have a working login, can we safely assume that there is information 
in the database for each user? If so, then we won't bother discussing 
insert statements, but concentrate on updates. We'll also assume that $user 
has update privileges on the database.

The normal form of an update query is as you describe, I'm just going to 
flesh it out a bit ...

$query = "UPDATE users SET email='$email', phone = '$phone'  WHERE user_id 
= '$user_id' ";
echo $query;
$result = mysql_query( $query) or die( mysql_errno() ." : ".mysql_error() );

The WHERE clause makes certain that everyone's email isn't updated with the 
contents of $email.

The echo is useful for debugging - you may be assuming that the update 
statement is correct, but it turns out that a key variable is missing, 
contains no data, or there are single quotes around numerical fields, etc.

The revised die() will print out MySQL's error code and error message, 
which may or may not be helpful.

This may still not work, but we've more information to work on. Please let 
us know what happens.

Cheers - Miles Thompson


At 07:18 PM 1/17/2002 +0100, Hawk wrote:
>Having a problem with this, I have a working login that supports multiple
>users, and I'm trying to make it possible for the users to change their own
>settings etc, but I get killed when trying to send the data to the MySQL
>database.
>To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)
>
>the retrieving data from the form works since I belive, since it showed up
>when I added a print "$the vars " but I don't know how to save it to the
>database..
>
>I might be missing some line or maybe it's just because I'm a newbie or
>something.. ;D
>anyway.. I use something similiar to this
>$query = "UPDATE users SET email='$email'"; // and so on..
>$result = mysql_query($query) or die ("blabla");
>
>I don't get any error lines or anything, the only thing that shows is the
>"blabla" thing.
>
>I also tried INSERT INTO in the query but that didn't make any difference :p
>
>if anyone could tell me what I'm doing wrong I would be happy.. :p
>"the best way to learn is to ask people that know" :p
>
>Hawk
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP & MySQL problems, updating database..

2002-01-17 Thread Dennis Moore

Try using mysql_error() to display the mysql error message before issuing
your die().   this will give more information to troubleshoot.  You may not
have the right privileges set up in your database where you can update or
insert into the database or table.

/dkm


- Original Message -
From: "Hawk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 17, 2002 1:18 PM
Subject: [PHP] PHP & MySQL problems, updating database..


> Having a problem with this, I have a working login that supports multiple
> users, and I'm trying to make it possible for the users to change their
own
> settings etc, but I get killed when trying to send the data to the MySQL
> database.
> To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)
>
> the retrieving data from the form works since I belive, since it showed up
> when I added a print "$the vars " but I don't know how to save it to the
> database..
>
> I might be missing some line or maybe it's just because I'm a newbie or
> something.. ;D
> anyway.. I use something similiar to this
> $query = "UPDATE users SET email='$email'"; // and so on..
> $result = mysql_query($query) or die ("blabla");
>
> I don't get any error lines or anything, the only thing that shows is the
> "blabla" thing.
>
> I also tried INSERT INTO in the query but that didn't make any difference
:p
>
> if anyone could tell me what I'm doing wrong I would be happy.. :p
> "the best way to learn is to ask people that know" :p
>
> Hawk
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP & MySQL problems, updating database..

2002-01-17 Thread Erik Price

The reason you aren't seeing any errors is because you used "or 
die()" -- to the best of my knowledge, this replaces any standard errors 
that PHP would normally generate.

It appears that you have omitted the second argument to mysql_query().  
A common mistake that I've made many times myself.  You need to specify 
the connection parameters in the second argument.

$result = mysql_query($sql, $db); // $db is mysql_connect(host, user, 
pass) or whatever you use

You would have gotten an error message telling you this if you weren't 
using "or die"... "or die" can be helpful but it can also occlude 
valuable information.

Good luck I hope this works,


Erik



On Thursday, January 17, 2002, at 01:18  PM, Hawk wrote:

> Having a problem with this, I have a working login that supports 
> multiple
> users, and I'm trying to make it possible for the users to change their 
> own
> settings etc, but I get killed when trying to send the data to the MySQL
> database.
> To connect I use mysql_connect($host,$user,$pswd) and 
> mysql_select_db($db)
>
> the retrieving data from the form works since I belive, since it showed 
> up
> when I added a print "$the vars " but I don't know how to save it to the
> database..
>
> I might be missing some line or maybe it's just because I'm a newbie or
> something.. ;D
> anyway.. I use something similiar to this
> $query = "UPDATE users SET email='$email'"; // and so on..
> $result = mysql_query($query) or die ("blabla");
>
> I don't get any error lines or anything, the only thing that shows is 
> the
> "blabla" thing.
>
> I also tried INSERT INTO in the query but that didn't make any 
> difference :p
>
> if anyone could tell me what I'm doing wrong I would be happy.. :p
> "the best way to learn is to ask people that know" :p
>
> Hawk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] PHP & MySQL problems, updating database..

2002-01-17 Thread Hawk

Having a problem with this, I have a working login that supports multiple
users, and I'm trying to make it possible for the users to change their own
settings etc, but I get killed when trying to send the data to the MySQL
database.
To connect I use mysql_connect($host,$user,$pswd) and mysql_select_db($db)

the retrieving data from the form works since I belive, since it showed up
when I added a print "$the vars " but I don't know how to save it to the
database..

I might be missing some line or maybe it's just because I'm a newbie or
something.. ;D
anyway.. I use something similiar to this
$query = "UPDATE users SET email='$email'"; // and so on..
$result = mysql_query($query) or die ("blabla");

I don't get any error lines or anything, the only thing that shows is the
"blabla" thing.

I also tried INSERT INTO in the query but that didn't make any difference :p

if anyone could tell me what I'm doing wrong I would be happy.. :p
"the best way to learn is to ask people that know" :p

Hawk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]