Jump to content

Archived

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

ArcAiN6

PHP SQL update script

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 ]=-

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
hmm... somethign isn't right somewhere... maybe it's on my system, but neither suggestion worked..
I'm stillr ecieving the error...

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

That error happened with the ',' between your two table names 'ibf_members,ibf_member_extra'

that suggests to me that your MySQL can't handle the 2 table update.

You could break the statement up into 2 updates instead, or maybe upgrade your MySQL.

Jeff

Share this post


Link to post
Share on other sites
WEE... IT's ALIVE!!!

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

thank you guys so very much for the help :)
all is peachy keen now :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.