# SQL Query UPDATE/WHERE statement

**URL:** https://forum.kirupa.com/t/sql-query-update-where-statement/29366
**Category:** flash
**Created:** [August 26, 2003, 1:01am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366 "2003-08-26T01:01:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zammzamm](https://avatars.discourse-cdn.com/v4/letter/z/278dde/32.png) [@zammzamm](https://forum.kirupa.com/u/zammzamm)
#### Post date: [August 26, 2003, 1:01am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/1 "2003-08-26T01:01:53Z")

</div>

Question regarding this query

This script allows a user to update his profile.  
The user has logged in and now he edit his preference

My UPDATE/WHERE statements are not working.  
It is not selecting the appropriate row that is  
recongnized by the first\_name = $first\_name and password = $password

What wrong with this???

```php

$link = @mysql_connect($dbHost, $dbUser, $dbPass);

if (!$link) {
    
    print "&list=" . urlencode("<b>Error:</b> Could not conenct to database") . "&";
    exit;
}

if (!@mysql_select_db($dbName)) {

    print "&list=" . urlencode("<b>Error:</b> Could not find $dbName database") . "&";
    exit;
}

$currentTime = time();

$query = "UPDATE $table SET ScreenName, Telephone, Age, entryDate WHERE first_name = $first_name && password= $password ";
$query .= "VALUES('$disp_ScreenName1', '$disp_Telephone1', '$disp_Age1', $currentTime)";

$result = mysql_query($query);

if (!$result) {

    print "&list=" . urlencode("Error: Could not insert record into download log") . "&";
    exit;
}

$query = "SELECT * FROM $table WHERE first_name = '$first_name && password= $password' ORDER BY entryDate DESC";

$result = mysql_query($query);

if (!$result || @mysql_num_rows($result) < 1) {

    print "&list=" . urlencode("No entries in table $table") . "&";
    exit;
}

$list = "";
    
while($row = mysql_fetch_array($result)) {
        

    $entryDate = strftime("%A %d/%m/%y", $row['entryDate']);
        
    $list .= "<b>Date:</b> " . $entryDate . "<br>";
    $list .= "<b>ScreenName:</b> " . $row['ScreenName'] . "<br>";
    $list .= "<b>Telephone:</b> " . $row['Telephone'] . "<br>";
	$list .= "<b>Password:</b> " . $row['Password'] . "<br>";
    $list .= "<b>Age:</b> " . $row['Age'] . "<br><br>";
}

print "&list=" . urlencode($list) . "&";

mysql_close($link);

```

?\>

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2003, 1:35am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/2 "2003-08-26T01:35:37Z")

</div>

try this:

```php
$query = "UPDATE '$table' SET ScreenName = '$disp_ScreenName1', Telephone = '$disp_Telephone1', Age = '$disp_Age1', entryDate = '$currentTime' WHERE first_name = '$first_name' AND password= '$password'";

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2003, 2:29am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/3 "2003-08-26T02:29:22Z")

</div>

:esmirk:

I think there is a conflict with a \_root.checklog = 0; command I have in the .Fla and it is not accessing the first\_name or password

Maybe I’m wrong???

well anyway,

here is the .fla with the two php scripts

Let me know if you can pinpoint this issue

:cool:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2003, 2:31am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/4 "2003-08-26T02:31:18Z")

</div>

try running the php script through the browser, not flash, see if that works…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 26, 2003, 6:46am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/5 "2003-08-26T06:46:21Z")

</div>

I am getting this

&list=Error%3A+Could+not+insert+record+into+download+log&

It’s comming from this line in the php

/\* If there was an error executing query… \*/  
if (!$result) {

```
/* Return error information to Flash and quit! */
print "&list=" . urlencode("Error: Could not insert record into download log") . "&";
exit;

```

}

:bu:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 28, 2003, 7:59am UTC](https://forum.kirupa.com/t/sql-query-update-where-statement/29366/6 "2003-08-28T07:59:20Z")

</div>

howdi,

ahmed

I’ve tried several things here and it is not letting me update the  
rows

It will let me insert fine

but the error keeps comming up

and suggestions?

:tie:
