Jump to content


Photo

PHP SQL update script


  • Please log in to reply
7 replies to this topic

#1 ArcAiN6

ArcAiN6
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 09 September 2006 - 02:15 AM

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

<?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>");
}

?>



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:

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


any help would be most appreciated :)

-=[ ArcAiN6 ]=-

#2 Guest_WarpNacelle_*

Guest_WarpNacelle_*
  • Guests

Posted 09 September 2006 - 02:38 AM

Hi,

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

I believe the error is with this line:



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



Try either:

<?php 

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

?>

or



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



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

I think that will work.

#3 ArcAiN6

ArcAiN6
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 09 September 2006 - 03:20 AM

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

#4 Guest_WarpNacelle_*

Guest_WarpNacelle_*
  • Guests

Posted 09 September 2006 - 04:55 AM

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?

#5 jefkin

jefkin
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 09 September 2006 - 05:25 AM


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

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 September 2006 - 06:43 AM

do 2 updates ok then fine ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 ArcAiN6

ArcAiN6
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 09 September 2006 - 07:09 AM

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 :)

#8 Guest_WarpNacelle_*

Guest_WarpNacelle_*
  • Guests

Posted 09 September 2006 - 03:25 PM


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


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

Glad it's going now.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users