Jump to content


Photo

building a patch system.


  • Please log in to reply
4 replies to this topic

#1 ArcAiN6

ArcAiN6
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 10 September 2006 - 02:30 AM

I recently started a project with a group, and after lengthy discussion, i've decided that the best way to patch / update thier mysql driven forums.

I was planning on using some sort of form to let the administrator select witch patch to apply, but i've run into a snag, whenever i select teh data on the form, and click submit, the screen is then blank..

here is what i have so far in it's entirity. I look forward to your suggestions and ideas :)

[DIR]= /home/http/vhosts/xxxxxxxxxx.com/subdomains/cf/htdocs

Form.php located in [DIR]/patches/:
<?php
echo ("<html>");
echo ("<body>");
echo ("");
echo ("<form action='complete.php' method='post'>");
echo ("<select name='Patch'>");
echo ("<option value='patch.php'>Mass Inactive Users ban</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("<option value=''>n/a</option>");
echo ("</select>");
echo ("<input type='submit' name='submit' value='Patch'>");
echo ("</form>");
echo ("");
echo ("</body>");
echo ("</html>");
?>

Complete.php located in [DIR]/patches/:
<?php
include = 'includes/config.php';
include = 'includes/opendb.php';
mysql_select_db($dbname, $dbcnx);
include = 'includes/$patch';
if ( @mysql_query($sql) ) {
  echo("<p>Update affected " . mysql_affected_rows() . "
rows.</p>");
} else {
  echo("<p>Error performing update: " . mysql_error() .
"</p>");
}
?>

config.php Located in [DIR]/includes/patches/:
<?php
// This is an example of config.php
$dbhost = 'localhost';
$dbuser = 'xxxxx';
$dbpass = 'xxxxxx';
$dbname = 'xxxxxxxxxxx';
// DO NOT EDIT BELOW THIS LINE

$patch = $_POST["Patch"];
$date = date('l dS \of F Y h:I:s A');
?>


opendb.php Located in [DIR]/includes/patches/:
<?php
    // Connect to the database server
  $dbcnx = @mysql_connect("localhost", $dbuser, $dbpass);
  if (!$dbcnx) {
    echo( "<p>Unable to connect to the " .
          "database server at this time.</p>"
);
    exit();
}
?>


patch.php located in [DIR]/patches/
<?php
$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;";
?>


as you can see, i've attempted to make it so the admin can choose wich patch to apply by using a dropdown menu. But i've also parted everything out so it may be used again in other parts or or other standalone patches at a later date. The reason i'm attempting to do it this iway is to ease the burden on myself and the sql coder so we only need to write out as little as possible.

Any help with this would be much appreciated. Sorry for including all of the files, but i thought it would be more clear to everyone that way.

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 10 September 2006 - 02:50 AM

Try making
echo ("<option value='patch.php'>Mass Inactive Users ban</option>");
echo ("<option value='patch'>Mass Inactive Users ban</option>");
and make
$patch = $_POST["Patch"];
$patch = $_POST["Patch"] . ".php";

and see if anything different happens, also on patch.php at the end add
mysql_query($sql);

Why doesn't anyone ever say hi, hey, or whad up world?

#3 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 10 September 2006 - 10:15 AM

Corbin,

mysql_query($sql);

Is already included after the statement itself, but it's just included in complete.php

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#4 redarrow

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

Posted 10 September 2006 - 10:41 AM

First use the firom in a function and add that function to a page called functions.php

Then include("functions.php");

Then call the function example function form(); any were you need it.

redesign your form had a hartattack here.
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

#5 ArcAiN6

ArcAiN6
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 11 September 2006 - 04:32 AM

ok... i rewrote everything.. but now i'm not getting any type of responce.. i.e. it supposed to tell me if everything went OK, or if something went wrong... just getting a blank page...


the form is not included as it's very large.. don't wanna over post.. if you guys need to see it let me know..

patch1.php
<?php
$dbhost = "localhost";
$user = "xxxxxx";
$pw = "xxxxxxx";
$dbname = "xxxxxxxxxx";
$join = $_POST["join"]
$memb = $_POST["memb"]
$count = $_POST["count"]
$date = date('l dS \of F Y h:I:s A');

$dbcnx = @mysql_connect($dbhost, $user, $pw);
  if (!$dbcnx) {
    echo( "<p>Unable to connect to the " .
          "database server at this time.</p>"
);
    exit();
}
mysql_select_db($dbname, $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=$memb
 AND ibf_members.posts<$count
 AND ibf_members.joined< UNIX_TIMESTAMP()-$join;";
if ( @mysql_query($sql) ) {
  echo("<p>Update affected " . mysql_affected_rows() . "
rows.</p>");
} else {
  echo("<p>Error performing update: " . mysql_error() .
"</p>");
}
 
?>






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users