Social Networking Site for Davao City

September 28, 2009

Feel free to join the community.

Just log in at:

http://artgallery.site50.net

Connection Strings

October 6, 2008

MySQL Connector/ODBC 2.50 (MyODBC 2.50)
Local database
Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;

Remote database
Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword;
Specifying TCP/IP port
Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword;
MySQL Connector/ODBC 3.51 (MyODBC 3.51)
Local database
Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
Remote database
Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
Specifying TCP/IP port
Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
Specifying character set
Driver={MySQL ODBC 3.51 Driver};Server=data.domain.com;charset=UTF8;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
OLE DB, OleDbConnection (.NET)
Standard
Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

 

mySQL based counter script for multiple pages

September 21, 2008

//MYSQL database is needed

$db = "DATABASE NAME";
$admin = "MYSQL USER NAME";
$adpass = "MYSQL PASSWORD";
$mysqllink = mysqlconnect("localhost", $admin, $adpass);
mysqlselectdb($db, $mysqllink);

$result = mysqlquery("SELECT impressions from tdscounter where COUNTID=’$cid’", $mysqllink);
if(
mysql
numrows($result)) {
   mysql
query("UPDATE tdscounter set impressions=impressions+1 where COUNTID=’$cid’", $mysqllink);
   $row = mysql
fetch_row($result);
   if($inv != 1) {
       print("$row[0]");
   }
}
?>

creating a mySQL table using a PHP script

$mysqldb = "DATABASE NAME";
$mysql
user = "YOUR MYSQL USERNAME";
$mysqlpass = "YOUR MYSQL PASSWORD";
$mysql
link = mysqlconnect("localhost", $mysqluser, $mysqlpass);
mysql
selectdb($mysqldb, $mysqllink);
$create
query = "CREATE TABLE tdscounter (
    COUNT
ID INT NOT NULL AUTOINCREMENT,
    pagepath VARCHAR,
    impressions INT,
    reset
counter DATETIME,
    PRIMARY KEY (COUNTID)
    )"
;

mysqlquery($createquery, $mysqllink);
print(
"Table Creation for tdscounter successful!

");

$insert = "INSERT into tdscounter VALUES (
    0, ‘/phpdiary/021901.php3’, 0, SYSDATE
   )"
;

mysqlquery($insert, $mysqllink);
print(
"Inserted new counter successfully for this page: http://www.php-scripts.com/php
diary/021901.php3

");

?>

admin interface for adding and deleting users using mySQL

//needs a database MYSQL, thanks
$db = "DATABASE NAME";
$admin = "MYSQL USER NAME";
$adpass = "MYSQL PASSWORD";
$mysqllink = mysqlconnect("localhost", $admin, $adpass);
mysqlselectdb($db, $mysqllink);

?>




Delete Users
user">


ADD A New User

User:

Pass:




shuffling and "cutting" a deck of playing cards

$cards = array("ah", "ac", "ad", "as",
               
"2h", "2c", "2d", "2s",
               
"3h", "3c", "3d", "3s",
               
"4h", "4c", "4d", "4s",
               
"5h", "5c", "5d", "5s",
               
"6h", "6c", "6d", "6s",
               
"7h", "7c", "7d", "7s",
               
"8h", "8c", "8d", "8s",
               
"9h", "9c", "9d", "9s",
               
"th", "tc", "td", "ts",
               
"jh", "jc", "jd", "js",
               
"qh", "qc", "qd", "qs",
               
"kh", "kc", "kd", "ks");
srand(time());
  for(
$i = 0; $i < 52; $i++)
{
   
$count = count($cards);
   
$random = (rand()%$count);
      if(
$cards[$random] </font><font color=”#cc0000″>&quot;&quot;</font><font color=”#006600″>)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color=”#0000cc”>$i</font><font color=”#006600″>–;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color=”#0000cc”>$deck</font><font color=”#006600″>[] = </font><font color=”#0000cc”>$cards</font><font color=”#006600″>[</font><font color=”#0000cc”>$random</font><font color=”#006600″>];<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font color=”#0000cc”>$cards</font><font color=”#006600″>[</font><font color=”#0000cc”>$random</font><font color=”#006600″>] = </font><font color=”#cc0000″>&quot;&quot;</font><font color=”#006600″>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /> }<br /><br /></font><font color=”#0000cc”>srand</font><font color=”#006600″>(</font><font color=”#0000cc”>time</font><font color=”#006600″>());<br /></font><font color=”#0000cc”>$starting<em>point </font><font color=”#006600″>= (</font><font color=”#0000cc”>rand</font><font color=”#006600″>()%</font><font color=”#0000cc”>51</font><font color=”#006600″>);<br />print(</font><font color=”#cc0000″>&quot;Starting point for cut cards is: $starting</em>point<p>&quot;</font><font color=”#006600″>);<br /><br /></font><font color=”#ff9900″>// display shuffled cards (EXAMPLE ONLY)<br />&nbsp;&nbsp;</font><font color=”#006600″>for (</font><font color=”#0000cc”>$index </font><font color=”#006600″>= </font><font color=”#0000cc”>0</font><font color=”#006600″>; </font><font color=”#0000cc”>$index </font><font color=”#006600″>< </font><font color=”#0000cc”>52</font><font color=”#006600″>; </font><font color=”#0000cc”>$index</font><font color=”#006600″>++)<br /> {<br />&nbsp;&nbsp;&nbsp;if (</font><font color=”#0000cc”>$starting<em>point </font><font color=”#006600″> 52) { $starting
point = 0; }
   print(
"Uncut Point: $deck[$index] ");
   print(
"Starting Point: $deck[$startingpoint]
"
);
   
$starting
point++;
  }
?>

searching through a directory and picking out files using a regular expression

$diarydirectory = opendir(".");
  while(
$filename = readdir($diary
directory))
{
    
$filesplit = explode(".", $filename);
    
$checkfilename = $filesplit[0];
       if(
ereg("[0-9]{6}", $check
filename))
      {
         
$checkfilename .= ".$filesplit[1]";
         
$valid
filename[] = $checkfilename;
      }
  }
closedir($diary
directory);
for(
$index = 0; $index < count($validfilename); $index++)
{
  print(
"$valid
filename[$index]
"
);
}
?>

forcing the text in a string to be all upper or lowercase

// force all uppercase
print(strtoupper("i bet this will show up as all letters capitalized
"
));
// force all lowercase
print(strtolower("I BET THIS WILL SHOW UP AS ALL LETTERS IN LOWERCASE
"
));
// force the first letter of a string to be capitalized
print(ucfirst("i bet this will show the first letter of the string capitalized
"
));
// force the first letter of each WORD in a string to be capitalized
print(ucwords("i bet this will show the first letter of every word capitalized
"
));
?>

random text link advertising using predefined arrays

$randomurl = array("http://www.tdscripts.com/linkorg.html",
                    
"http://www.tdscripts.com/keno.html",
                    
"http://www.tdscripts.com/ezibill.shtml",
                    
"http://www.tdscripts.com/tdforum.shtml",
                    
"http://www.tdscripts.com/picofday.html",
                    
"http://www.tdscripts.com/gutsorglory.html");

$urltitle = array("Link Organizer",
                   
"TD Keno",
                   
"eziBill *Free Promotion!",
                   
"TD Forum",
                   
"TD Pic of Day PHP",
                   
"Guts or Glory Poker PHP");
$urldesc = array("- A comprehensive link list organizer",
"- Offer your site visitors an engaging Keno game without the monetary risk",
"- Sell access to and protect your membership area using iBill and our eziBill script",
"- An unthreaded messageboard script to exchange ideas with your site visitors",
"- Run your own picture of the day script from any site anywhere with this handy script",
"- A casino-style card game written entirely in PHP");
srand(time());
$sizeof = count($random
url);
$random = (rand()%$sizeof);
print(
"

url[$random]">$urltitle[$random] $url_desc[$random]
");
?>

php simple slot machine - multiple rand number generation

function slotnumber()
{
srand(time());
for (
$i=0; $i < 3; $i++)
{
$random = (rand()%3);
$slot[] = $random;
}
print(
"

$slot[0] ");
print(
"
$slot[1] ");
print(
"
$slot[2] ");
if(
$slot[0] </font><font color=”#0000cc”>$slot</font><font color=”#006600″>[</font><font color=”#0000cc”>1</font><font color=”#006600″>] && </font><font color=”#0000cc”>$slot</font><font color=”#006600″>[</font><font color=”#0000cc”>0</font><font color=”#006600″>] $slot[2])
{
print(
" Winner!—Hit refresh on your browser to play again");
exit;
}
}
?>

  
slotnumber();
?>

  
  
    

  
    action="example13.php3">


      

    

    

Get free blog up and running in minutes with Blogsome | Theme designs available here