Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <FORM>
- <?
- #; Fix for when register_globals is off. Also, turns out you dont need quotes unless a string has special characters.
- $OPTS=$HTTP_GET_VARS+ARRAY(SERV=>localhost,USER=>root,PASS=>pasword123,DB=>mysql);
- FOREACH($OPTS as $OPTS1 => $OPTS2) $$OPTS1=$OPTS2;
- PHP?>
- <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
- <INPUT TYPE=SUBMIT>
- </FORM>
- <HR>
- <?PHP
- MYSQL_CONNECT($SERV, $USER, $PASS)
- OR DIE("Can't connect to DBSERVer. Check $USER:$PASS@$SERV");
- MYSQL_SELECT_DB($DB)
- OR DIE("Can't select DB; check database $DB when logging in to $USER:$PASS@$SERV");
- #; New feature: Allow multiple commands!
- $SQL2=EXPLODE(";",$SQL);
- FOREACH($SQL2 AS $SQL3):
- $SQL4=MYSQL_QUERY($SQL3);
- $ALL[]=$SQL4;
- ENDFOREACH;
- #; New feature 2: Show results for each query!!
- FOR($X=0;$X<SIZEOF($SQL2);++$X):
- $SQL5=$SQL2[$X];
- #; New code ends here
- IF($RES[$X]):
- PRINT "<TABLE>";
- WHILE($SQL3=MYSQL_FETCH_ROW($SQL5)) PRINT "<TR>".IMPLODE("<TD>",$SQL3);
- ECHO "</TABLE>";
- #; 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.
- ELSE:
- PRINT $SQL5." did not produce a result (NOTE: Connected to dbserver as $USER:$PASS@$SERV, DB is $DB)";
- ENDIF;
- #; Whoops, add an ENDFOR here.
- ENDFOR;
- PHP?>
- <HR>
- <COMMENT This is a useful trick I came up with for makeing HTML comments>
- <COMMENT Print the form a second time to save scrolling. Another FORM tag is needed to separate it from the first though>
- <FORM>
- <TEXTAREA NAME=SQL ROWS=8 COLS=70><?=$SQL?></TEXTAREA>
- <INPUT TYPE=SUBMIT>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement