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 $name => $val) $$name=$val;
- 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);
- #; New feature 2: Show results for each query!!
- FOR($X=0;$X<SIZEOF($SQL);$X++)
- IF($RES[$X]):
- PRINT "<TABLE>";
- WHILE($row=MYSQL_FETCH_ROW($res[$i])) print "<TR>" . implode("<TD>", $row);
- 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 $SQL[$i]." did not produce a result (NOTE: Connected to DBSERVer as $USER:$pass@$SERV, DB is $DB)";
- ENDIF;
- 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