Re: MYSQL and PHP
| From: | Jordan Arendt | Date: | Mon, 03 Dec 2001 21:50:42 +0000 |
| Subject: | Re: MYSQL and PHP | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-10711@lists.php.net to get a copy of this message | ||
This was fixed. I needed to use the update statement instead of insert.
Jordan
"Jordan Arendt" <jordan@itshop.ca> wrote in message
news:20011203172726.26447.qmail@pb1.pair.com...
> Hi,
>
> I'm struggling with some php code. I'm trying to insert some info into a
> mysql DB. I beleive I'm failing on the SQL statement, specifically the
> WHERE syntax. Can anyone help?
> ------------
> bypass = 0 --confirmed
> $i = 0 works and inserts into the DB.
> $i=1 works, but doesn't insert into DB.
>
> -------------
> if ($bypass==0){
> // Add picks: this is ugly!
> if ($i==0){
> echo " i equals zero";
> $sql = "INSERT INTO picks (u_id, p_1) VALUES
> ('$u_id','$s_id0')";
> $result = mysql_query ($sql);
> }
> elseif ($i==1){
> echo "i equals one";
> printf ("u_id equals %s\n",$u_id);
> $sql = "INSERT INTO picks (p_2) VALUES ('$s_id1')WHERE
picks.u_id=$u_id";
> $result = mysql_query ($sql,$db);
> }
>
> ---------------
>
> The phppool.picks looks like (with more p_*):
>
> mysql> select u_id,p_1,p_2,p_3 from phppool.picks
> -> ;
> +------+-----+-----+-----+
> | u_id | p_1 | p_2 | p_3 |
> +------+-----+-----+-----+
> | 1 | 2 | 0 | 0 |
> | 2 | 1 | 0 | 0 |
> | 3 | 7 | 0 | 0 |
> | 4 | 7 | 0 | 0 |
> | 0 | 0 | 2 | 0 |
> | 5 | 2 | 0 | 0 |
> +------+-----+-----+-----+
> 6 rows in set (0.00 sec)
>
> Any help would be greatly appreciated. I know the code is ugly. I
haven't
> coded in a few years, and this is my first php program.
>
> Jordan
>
>