Advertisement
Guest User

Untitled

a guest
May 7th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <FORM>
  2. <?
  3. #; Fix for when register_globals is off. Also, turns out you dont need quotes unless a string has special characters.
  4.    $OPTS=$HTTP_GET_VARS+array(SERV=>localhost,USER=>root,PASS=>pasword123,DB=>mySQL);
  5.     FOREACH($OPTS as $name => $val) $$name=$val;
  6. PHP?>
  7. <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
  8. <INPUT TYPE=SUBMIT>
  9. </FORM>
  10. <HR>
  11. <?PHP
  12.  
  13.     MYSQL_CONNECT($SERV, $USER, $PASS)
  14.       OR die("Can't connect to DBSERVer. Check $USER:$pass@$SERV");
  15.     MYSQL_SELECT_DB($DB)
  16.       OR die("Can't select DB; check database $DB when logging in to $USER:$pass@$SERV");
  17.  
  18. #; New feature: Allow multiple commands!
  19.    $SQL2=EXPLODE(";",$SQL);
  20.     FOREACH($SQL2 AS $SQL3)
  21.  
  22.     $SQL4[]=MYSQL_QUERY($SQL3);
  23.  
  24. #; New feature 2: Show results for each query!!
  25.    FOR($X=0;$X<SIZEOF($SQL);$X++)
  26.  
  27.     IF($RES[$X]):
  28.         PRINT "<TABLE>";
  29.         WHILE($row=MYSQL_FETCH_ROW($res[$i])) print "<TR>" . implode("<TD>", $row);
  30.         ECHO "</TABLE>";
  31. #; 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.
  32.        ELSE:
  33.             PRINT $SQL[$i]." did not produce a result (NOTE: Connected to DBSERVer as $USER:$pass@$SERV, DB is $DB)";
  34.             ENDIF;
  35. PHP?>
  36. <HR>
  37. <COMMENT This is a useful trick I came up with for makeing HTML comments>
  38. <COMMENT Print the form a second time to save scrolling. Another FORM tag is needed to separate it from the first though>
  39. <FORM>
  40.  
  41. <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
  42. <INPUT TYPE=SUBMIT>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement