Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another problem with MySQL :P

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
This code doesn't delete, or insert.

Code:
function do_settings($entries_per_page, $date, $time, $allow_html, $allow_smilies, $auto_parse, $email_confirm_msg, $word_censoring) {

global $prefix, $dbi;

$result = sql_query("DELETE FROM guestbook_settings", "INSERT INTO "guestbook_settings VALUES ('$entries_per_page', '$date', '$time', '$allow_html', '$allow_smilies', '$auto_parse', '$email_confirm_msg', '$word_censoring')", $dbi);

}

Can someone help me fix it, please? Thank you.
 
The function is called mysql_query.

And I believe you can only invoke one SQL query at a time using it. Split it into two queries.
______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
Thanks, but when I split it into 2, it doesn't delete the rows, it just inserts a new one. And when that happens I have a screwed up settings page. P-)
 
When you split the query into two statements, what is the value of $result after the first query?

And just to ask the dumb, obvious question, does the user you're using to access the table have delete permission? ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
Oops. Forgot something.

After you run the DELETE query, what does mysql_error () return? ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
Yeah, my web host lets me use that command. I've used it before. There is no error.

I used the print function, and this is what I got:

Code:
$result = mysql_query("DELETE FROM guestbook_settings)", Resource id #1);
$result = mysql_query("INSERT INTO guestbook_settings VALUES ('1111', 'fg', 'fgf', 'yes', 'yes', 'yes', 'f', 'fg')", Resource id #1);

Thanks.
 
I'm sorry, but that output doesn't make sense to me.

When you issue mysql_query() with a DELETE query, afterward $result should be equal to TRUE or FALSE, for success or failure, respectively.

It looks like you're just instruction PHP to print the lines of code. ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
You mean this?:

Code:
$result = sql_query("DELETE FROM guestbook_settings")", $dbi);
$result = sql_query("INSERT INTO "guestbook_settings VALUES ('$entries_per_page', '$date', '$time', '$allow_html', '$allow_smilies', '$auto_parse', '$email_confirm_msg', '$word_censoring')", $dbi);
 
If you replace the function with the following:

function do_settings($entries_per_page, $date, $time, $allow_html, $allow_smilies, $auto_parse, $email_confirm_msg, $word_censoring)
{
global $prefix, $dbi;

$result = sql_query("DELETE FROM guestbook_settings", $dbi);

if ($result == FALSE)
{
print "Delete query did not run. ".mysql_error ($dbi);
}
else
{
print "Delete query ran";
$result = sql_query("INSERT INTO guestbook_settings VALUES ('$entries_per_page', '$date', '$time', '$allow_html', '$allow_smilies', '$auto_parse', '$email_confirm_msg', '$word_censoring')", $dbi);
}
}

What output do you get? ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
And what is in the table? ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
Only what's in the form? You commented earlier that the delete was not working, but the insert was, so there were two sets of data in the table. ______________________________________________________________________
Don't say thanks. Just award stars.
______________________________________________________________________
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top