Coder Profile - Show off your skills, get a coder profile.
 
 
 
code pin board TRUNCATE TABLE Download Source Code
Author Details Code Information
vozzy ( sam )

Pinned 2 Codes
Posted 0 Coding Articles

Send A Message
View Coders Profile
Language PHP (Hypertext Preprocessor)
Expires Never
Length 526 Characters (19 Lines)
Password no password
Description

ok, so here is a simple php program i made that will truncate a table from a mysql database. as you can see i have a "global.php" that stores all the login info. (simple to make, just define $host, $username, $password, and $db_name in it) this page is behind a login. if you want to test it, just remove the session_start() and the if else statement dealing with. enjoy!

p.s. i made it for school use, cause i don't have access to my mysql database when i'm in school.
  1. <?php
  2. session_start();
  3. include(realpath("../global.php"));
  4.    if (isset($_SESSION["loggedIn"]) && $_SESSION["loggedIn"] == "true") {
  5.           mysql_connect ($host,$username,$password);
  6.      @mysql_select_db ($db_name) or die ("Unable to find a database");
  7.        $truncate = mysql_query ("TRUNCATE TABLE Login");
  8.           mysql_close();
  9.            if ($truncate) {
  10.                     print "<span>Done</span>";
  11.           }
  12.            else {
  13.                     print "<span>Failed</span>";
  14.           }
  15.           }
  16.    else {
  17.           print "<span>You must <a href=\"/\">login</a> to view this page.</span>\n";
  18. }
  19. ?>
code pin board Back To Code Pin Board Post New Code
Please login to post comments.
 
vozzy     Posted 194 Days Ago
 
 
also: "Login" is the name of the table i was TRUNCATING. change it as you
will :)
Page 1 of 1
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved