PHP
Please note; These snippets are extremely old. I realize they need massive updating. This will happen when I have everything moved over
SQL Insertion
$ignorethis=do_sql_stuff($query); # Insert Query and we need no data back. function do_sql_stuff($query) { $db_host="<host>"; $db_user="<user>"; $db_pass="<pass>"; $db_name="<dbnname>"; $base_url="http://$ite"; $base_https="https://$ite/"; if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) { $DB_ERR="Error Connecting to Host<br>$function"; DB_DED($DB_ERR); } else { if (!@mysql_select_db($db_name, $link)) { $DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR); } else { if(!$result = @mysql_query($query, $link)) { $DB_ERR="<br>Error with<br>$query"; DB_DED($DB_ERR); } $results = @mysql_fetch_array($result); }} return $results; } function db_ded($DB_ERR) { echo"<FONT COLOR='Red'><B>$DB_ERR</b><br></font></B>\n"; }
SQL Query
Piece of code from my Eve API Tool. I left the variable names intact so connections are clear.
$getValidCorps="SELECT corporationID FROM `eveapimgmt_valid_corporations` where 1"; if (!$link = @mysql_connect($db_host, $db_user, $db_pass)) {$DB_ERR="Error Connecting to Host!!"; DB_DED($DB_ERR);} else { if (!@mysql_select_db($db_name, $link)) {$DB_ERR="Error Connecting to Database at Host!!"; DB_DED($DB_ERR);} else { if(!$CorpIDResult = @mysql_query($getValidCorps, $link)) {$DB_ERR="$CorpIDResult"; DB_DED($DB_ERR);} else { while ($corporationID = mysql_fetch_array($CorpIDResult)) { # Do some work }
Read a file
function Get_my_file($FileNameToGet) { $ContentsOfFile = file_get_contents($FileNameToGet); return $ContentsOfFile; }
Write a File
Call the function with:
Push_Data_To_File($FileNameToOpen, $VariableDataToStore);
Function:
function Push_Data_To_File($FileNameToOpen, $VariableDataToStore) { $fh = fopen($FileNameToOpen, 'w') or die("can't open file for output"); fwrite($fh, $VariableDataToStore); fclose($fh); return 0; }