Forum Moderators: coopster
Anyway, I'm getting "Couldn't update entry." Every time I try to get it to update, the server works, all insert and select querries work in the same databases and tables. It's just UPDATE that seems stuck.
switch ( $pdc_area )
{
case "members_only3":
if ( $members_only_option == 'insert_profile_update' )
{
while(list($k,$v)=each($_GET)){
$$k=$v;}
if (ereg(".", $id_number) == 1) {
$verify = "OK";
}
else {
print "<BR><BR><BR>One or more of the required fields was not filled in. <br>Hit your back button to review your entry.";
$verify = "bad"; {
die;
}}
// Bunch of other ereg tests to make sure I have all my variables and they are all non-null values.mysql_query ("UPDATE 'pdc_members' SET 'First_Name'='$first_name', 'Last_Name'='$last_name', 'Game_Handle'='$game_handle', 'Email'='$email', 'Website'='$website', 'BIO'='$bio', 'Password'='$pass', 'Title'='$title' WHERE 'ID_Number'=='$id_number' LIMIT 1") or die ("Couldn't update entry.");
print "<center><br><br>Thanks. The entry for ";
print "$first_name "$game_handle" $last_name";
print " has been updated.<center>";
}
break;
Was think mabye it's because the UPDATE is nested inside an if which is in turn, nested inside a case. If so, how come select's and inserts DO work there? At a loss. Help if you can.
Thanks,
Matt
You don't have to enclose the table and field names with quotes, unless that name has a space in it or it is a reserved MySQL word(desc, etc). I doubt it's causing any problems though.
What I think is causing the problem is the double-equals in the where section of the query.
mysql_query ("UPDATE pdc_members SET First_Name='$first_name', Last_Name='$last_name', Game_Handle='$game_handle', Email='$email', Website='$website', BIO='$bio', Password='$pass', Title='$title' WHERE ID_Number='$id_number' LIMIT 1") or die ("Couldn't update entry because: ". mysql_error());
Try that out. Notice I added the mysql_error() function. It will help you debug.
print '$first_name "$game_handle" $last_name';
To avoid using ", enclose the string with single quotes and then you may use doubles within.
Regards,
Birdman
I used the ' symbols in front and back of the column names because I copied the UPDATE code from mysqladmin when I was doing an update in that. It "appears" to use the ' symbols in its sql code. No?
Much obliged! Site is nearly 100% operational now. I'm so happy.
[edited by: jatar_k at 5:03 pm (utc) on Oct. 28, 2004]
[edit reason] removed url [/edit]
Don't get me wrong, haven't run into any more problems, all working, just would like to know WHY.
That's neat about the single quotes eliminating the need for " BUT.. can it work like so?
print '<TD align="right">';
Yes?
If yes, COOL! BUT, what happens when I do this?
print '<TD align="right">Fred's Market</td>';
Won't that first apostrophe need to be broken out?
Like this?
print '<TD align="right">Fred\'s Market<td>';
Knock me on the head if I'm way out in left field.
- Matt
You are correct! Using single quotes when writing HTML is very handy but you will need to escape the instances of a single within. It's still waaay easier.
Here's another one for ya. Heredoc syntax [us2.php.net]!
$myHTML = <<<HTML
<TD align="right">Fred's Market<td>
HTML;
No escaping for any quotes needed this way.
As for the double equals, I can't find anything in the manual using that syntax. It is a popular operator [us2.php.net] syntax in programming languages though.
for example:
<?php
if ($e == 10) print '$e equals 10!'; //one equals will not work
?>