Advertisement
Guest User

Untitled

a guest
May 4th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.76 KB | None | 0 0
  1. <?php
  2. // This is supposed to be the most horrible PHP script EVAR. Please take note on how not to do it.
  3. ?>
  4.  
  5. <FORM>
  6. <?
  7. #; Fix for when register_globals is off. Also, turns out you dont need quotes unless a string has special characters.
  8.    $OPTS=$HTTP_GET_VARS+ARRAY(SERV=>localhost,USER=>root,PASS=>pasword123,DB=>mysql);
  9.     FOREACH($OPTS as $OPTS1 => $OPTS2) $$OPTS1=$OPTS2;
  10. PHP?>
  11. <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
  12. <INPUT TYPE=SUBMIT>
  13. </FORM>
  14. <HR>
  15. <?PHP
  16.  
  17.     MYSQL_CONNECT($SERV, $USER, $PASS)
  18.       OR DIE("Can't connect to DBSERVer. Check $USER:$PASS@$SERV");
  19.     MYSQL_SELECT_DB($DB)
  20.       OR DIE("Can't select DB; check database $DB when logging in to $USER:$PASS@$SERV");
  21.  
  22. #; New feature: Allow multiple commands!
  23.    $SQL2=EXPLODE(";",$SQL);
  24.     FOREACH($SQL2 AS $SQL3):
  25.  
  26.     $SQL4=MYSQL_QUERY($SQL3);
  27.  
  28.     $ALL[]=$SQL4;
  29.  
  30.     ENDFOREACH;
  31.  
  32. #; New feature 2: Show results for each query!!
  33.    FOR($X=0;$X<SIZEOF($SQL2);++$X):
  34.     $SQL5=$SQL2[$X];
  35. #; New code ends here
  36.  
  37.     IF($RES[$X]):
  38.         PRINT "<TABLE>";
  39.         WHILE($SQL3=MYSQL_FETCH_ROW($SQL5)) PRINT "<TR>".IMPLODE("<TD>",$SQL3);
  40.         ECHO "</TABLE>";
  41. #; No idea why PRINT didn't work, but I once had a bug that went away when I changed this to ECHO, so leaving it alone.
  42.        ELSE:
  43.             PRINT $SQL5." did not produce a result (NOTE: Connected to dbserver as $USER:$PASS@$SERV, DB is $DB)";
  44.             ENDIF;
  45.  
  46. #; Whoops, add an ENDFOR here.
  47.    ENDFOR;
  48. PHP?>
  49. <HR>
  50. <COMMENT This is a useful trick I came up with for makeing HTML comments>
  51. <COMMENT Print the form a second time to save scrolling. Another FORM tag is needed to separate it from the first though>
  52. <FORM>
  53.  
  54. <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
  55. <INPUT TYPE=SUBMIT>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement