Jump to content

PHP SQL update script


ArcAiN6

Recommended Posts

I've been tweaking this for a while now, and i still can't seem to get it to work,... If anyone has any suggestions, or ideas, please let me know what could possibly be wrong with this script.. I recieve an error, but as i'm not very good with MySQL i haven't the faintest idea how to fix it..

[code]
<?php


//Edit before execution

// change below is your assigned mySQL username
$user = "xxxxxxxxxx";

// change to the pw below is your assigned mySQL password
$pw = "xxxxxxxxx";

// change to the database you have permission to connect to
$db = "xxxx";

    //Set current Date-time we need two I to display two minute digits
$date = date('l dS \of F Y h:II:s A');

    // Connect to the database server
  $dbcnx = @mysql_connect("localhost", $user, $pw);
  if (!$dbcnx) {
    echo( "<p>Unable to connect to the " .
          "database server at this time.</p>"
);
    exit();
}
mysql_select_db($db, $dbcnx);
$sql = "UPDATE ibf_members,ibf_member_extra
SET ibf_members.mgroup=5,
ibf_member_extra.signature= \"Banned on:" .$date ." by nExfUn script\"
WHERE ibf_members.id=ibf_member_extra.id
AND ibf_members.mgroup=151
AND ibf_members.posts<20
AND ibf_members.joined< UNIX_TIMESTAMP()-2592000;";
if ( @mysql_query($sql) ) {
  echo("<p>Update affected " . mysql_affected_rows() . "
rows.</p>");
} else {
  echo("<p>Error performing update: " . mysql_error() .
"</p>");
}

?>


[/code]

an online buddy did the SQL portion for me, but he's not been online for almost a week now, and i get the following error when i try to run the script:

[quote]
Error performing update: You have an error in your SQL syntax near 'ibf_member_extra SET ibf_members.mgroup=5, ibf_member_extra.signature= "Banned' at line 1
[/quote]

any help would be most appreciated :)

-=[ ArcAiN6 ]=-
Link to comment
https://forums.phpfreaks.com/topic/20193-php-sql-update-script/
Share on other sites

Guest WarpNacelle
Hi,

The error your getting is indicating a problem with UPDATE query.

I believe the error is with this line:

[code]


ibf_member_extra.signature=  \"Banned on:" .$date ." by nExfUn script\"


[/code]

Try either:

[code]
<?php

ibf_member_extra.signature= 'Banned on: $date by nExfUn script'

?>
[/code]

or

[code]


ibf_member_extra.signature=  \"Banned on:\" .$date .\" by nExfUn script\"


[/code]

I think he didn't use the quotes quite right.

I think that will work.
Link to comment
https://forums.phpfreaks.com/topic/20193-php-sql-update-script/#findComment-88823
Share on other sites

Guest WarpNacelle
Darn.

It's got to be that line...

If I take it out of the query and send it through phpMyAdmin it checks out.

Shoot man - I don't know what to suggest.  Enclosing the value in single quotes should have taken care of it.

Is it the exact same error or did it change slightly?
Link to comment
https://forums.phpfreaks.com/topic/20193-php-sql-update-script/#findComment-88847
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.