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
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
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
Share on other sites

Guest WarpNacelle
[quote author=ArcAiN6 link=topic=107429.msg431106#msg431106 date=1157785761]

I upgraded my MySQL server... evidently it was woefully out of date (v3.32.x)

[/quote]

Wow!  No wonder.  Very good thing to update!  ;D

Glad it's going now.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.