Jump to content

dbillings

Members
  • Posts

    190
  • Joined

  • Last visited

    Never

Everything posted by dbillings

  1. line 73 is missing another semi-colon <?php echo $username ?>
  2. you were also missing a semi-colon. if ($username = "administrator") {header("Location: admin.php"); }
  3. Your while loop doesn't terminate. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Radio Ilam | Radio of the Suburbs</title><meta name="keywords" content="music note, free template, website template, CSS, XHTML" /><meta name="description" content="Music Note - free CSS template provided by templatemo.com" /><link href="templatemo_style.css" rel="stylesheet" type="text/css" /><style type="text/css"> .style1 { text-align: center; } .style2 { font-weight: bold; color: #C32929; } .style3 {color: #FF0000} </style></head> <body> <?php // Connects to your Database mysql_connect("mysql3.000webhost.com", "a1408362_georgeb", "dryduck18") or die(mysql_error()); mysql_select_db("a1408362_data") or die(mysql_error()); //checks cookies to make sure they are logged in if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']) { header("Location: login.php"); } //if user is administrator then go to admin view if ($username = "administrator") {header("Location: admin.php") } //if the cookie does not exist, they are taken to the login screen else{ header("Location: login.php"); } } ?> <div id="templatemo_container_wrapper"> <div id="templatemo_container"> <div id="templatemo_header"> <div id="templatemo_site_title">Radio<span class="style2">Ilam</span></div> <div id="templatemo_site_slogan">Radio of the Suburbs</div> </div> <div id="templatemo_menuleft"></div> <div id="templatemo_menu"> <ul> <li><a href="index.html">Home</a></li> <li><a href="competitions.php">Competitions</a></li> <li><a href="#">Lates Music</a></li> <li><a href="#" class="current">Members</a></li> <li><a href="#">Listen Live</a></li> <li><a href="#">Contact Us</a></li> </ul> </div> <div id="templatemo_content"> <div id="templatemo_left_column"> <div class="templatemo_section2"> <h1>Members</h1> <p>Welcome <?php echo $username ?> <p><a href="logout.php">Logout</a></p> </div> <br /> </div> <div id="templatemo_right_column"> <h1>Members</h1> <h3>Song of the Week:</h3> <table width="540" height="126" border="0"> <tr> <td width="139" rowspan="2"><div align="center"><img src="muse-the-resistance.jpg" width="138" height="133" /></div></td> <td width="391" height="71">Muse - Uprising</td> </tr> <tr> <td> <object type="application/x-shockwave-flash" data="player_mp3.swf" width="200" height="20"> <param name="movie" value="player_mp3.swf" /> <param name="FlashVars" value="mp3=uprising.mp3" /> </object> </td> </tr> </table> <p> </p> </div> </div> <div id="templatemo_footer">Copyright © 2009 RadioIlam<a href="#"></a></div> </div> </div> </body> </html>
  4. woops <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("clients", $con); $extract = mysql_query ("SELECT * FROM members"); $numrows = mysql_num_rows ($extract); echo"Select USER: <select name='site'>"; while ($row = mysql_fetch_assoc($extract)) { echo"<option name='$row['firstname']'>$row['firstname']</option> "; } ?>
  5. <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("clients", $con); $extract = mysql_query ("SELECT * FROM members"); $numrows = mysql_num_rows ($extract); echo"Select USER: <select name='site'>"; while ($row = mysql_fetch_assoc($extract)) { echo"<option name='$row['firstname']>$row['firstname']</option> "; } ?>
  6. Here's a debugged version, but it won't display unless you have the proper format in your text file. item@@@@cost****item2@@@@cost2**** <?php $filename = 'filename.txt'; // adjust for correct makeshift db file $gtValue = 20; // adjust for gt value if (filesize($filename) > 0) { $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); } $seperate = explode("****", $contents); $item = array(); $cost = array(); foreach ($seperate as $value) { list($item[], $cost[]) = split('@@@@', $value); } for($x=0; $x < count($cost); $x++) { if($cost[$x] > $gtvalue) { echo "Item: ".$item[$x]."\n"; echo "Cost: ".$cost[$x]."\n<br />"; } } ?>
  7. I agree you're just adding complexity
  8. when things don't work out "or die mysql_error()" sheds a little light on why your not getting what you expect from your mysql database
  9. <?php require_once( dirname(__FILE__) . '/class.dbComponent.php'); class dbConnector extends dbComponent { var $query; var $thelink; function __construct() { $dbComponent = new dbComponent(); $this->thelink = $dbComponent->connectDB('localhost', 'root', NULL, 'jv_cms') or die('Details provided to connect to the database are invalid.' . mysql_error()); mysql_select_db($dbComponent->get_name(), $this->thelink) or die('Could not select the database. ' . mysql_error()); } function query($q) { $this->query = $q; return mysql_query($this->query)or die mysql_error(); } function fetch_array($result) { return mysql_fetch_array($result) or die mysql_error(); } function close() { mysql_close($this->thelink); } } ?>
  10. user "or die mysql_error()" with all your throughput from your database.
  11. $state[1]="Alabama"; $state[2]="Alaska"; $state[3]="Arizona"; $state[4]="Arkansas"; $state[5]="California"; $state[6]="Colorado"; $state[7]="Connecticut"; $state[8]="Delaware"; $state[9]="Florida"; $state[10]="Georgia"; $state[11]="Hawaii"; $state[12]="Idaho"; function findState($state[], $number) echo $state[$number]; }
  12. might want to change this too. mysql_select_db($this->dbname); to mysql_select_db($this->dbname) or die mysql_error();
  13. Try using this for DB component class. <?php class dbComponent { var $dbhost; var $dbusername; var $dbpassword; var $dbname; /** * Creates the database on construct */ function connectDB($host, $username, $password, $name) { $this->dbhost = $host; $this->dbusername = $username; $this->dbpassword = $password; $this->dbname = $name; mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword) or die mysql_error(); mysql_select_db($this->dbname); } function get_host() { return $this->dbhost; } function get_username() { return $this->dbusername; } function get_password() { return $this->dbpassword; } function get_name() { return $this->dbname; } } ?>
  14. you'd be able to read the values by doing the following for($i=0; $i < count($cost); $i++) { echo "Item: ".$item." Cost: ".$cost; }
  15. You'll need to modify your textfile to this format and it isn't built to catch problems like a misformated textfile. sun glasses@@@@20.00****beans@@@@5.00****
  16. $filename = 'filename.txt'; $gtValue = 20; if (filesize($filename) > 0) { $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); } $seperate = explode("****", $contents); $item = array(); $cost = array(); foreach ($seperate as $value) { // Split the array by IP and last page refresh. list($item[], $cost[]) = split('@@@@', $value); } for ($i=0; $i < count($cost); $i++) { if($cost[$i] < $gtValue) { unset($cost[$i]; unset($item[$i]; } }
  17. yeah, give me a sec.
  18. if($_COOKIE['skinid'] == 5) { echo bla bla bla; }
  19. try echoing $rcount before you perform the math. echo $rcount; // for testing purposes $num = 250; $count = ($num - $rcount); echo $rcount; echo "<br>"; echo $count;
  20. ooo lookie here <?php function smartCopy($source, $dest, $folderPermission=0755,$filePermission=0644){ # source=file & dest=dir => copy file from source-dir to dest-dir # source=file & dest=file / not there yet => copy file from source-dir to dest and overwrite a file there, if present # source=dir & dest=dir => copy all content from source to dir # source=dir & dest not there yet => copy all content from source to a, yet to be created, dest-dir $result=false; if (is_file($source)) { # $source is file if(is_dir($dest)) { # $dest is folder if ($dest[strlen($dest)-1]!='/') # add '/' if necessary $__dest=$dest."/"; $__dest .= basename($source); } else { # $dest is (new) filename $__dest=$dest; } $result=copy($source, $__dest); chmod($__dest,$filePermission); } elseif(is_dir($source)) { # $source is dir if(!is_dir($dest)) { # dest-dir not there yet, create it @mkdir($dest,$folderPermission); chmod($dest,$folderPermission); } if ($source[strlen($source)-1]!='/') # add '/' if necessary $source=$source."/"; if ($dest[strlen($dest)-1]!='/') # add '/' if necessary $dest=$dest."/"; # find all elements in $source $result = true; # in case this dir is empty it would otherwise return false $dirHandle=opendir($source); while($file=readdir($dirHandle)) { # note that $file can also be a folder if($file!="." && $file!="..") { # filter starting elements and pass the rest to this function again # echo "$source$file ||| $dest$file<br />\n"; $result=smartCopy($source.$file, $dest.$file, $folderPermission, $filePermission); } } closedir($dirHandle); } else { $result=false; } return $result; } ?>
  21. Something like this would probably work. This is not tested and may have errors also I don't know what you're using to grab the files from one directory multiple directories? <?php // master directory with common files desired to populate user directories $masterDir = '/somedirectory'; $masterFiles = scandir($masterDir); //assuming all user directories are subdirectories of a higher level user directory $userDir = '/userdirectory'; $userFiles = scandir($userDir); for($i=0; $i<count($userFiles); $i++) { for($x=0; $x<count($masterFiles); $x++) { copy($masterFiles[x], $userFiles[i]."/$masterFiles[x]"); } } ?>
  22. This looks promising as well. http://us2.php.net/copy
  23. You really wouldn't need to do that you can use the directory functions to read what files are in the directory. http://us3.php.net/manual/en/function.opendir.php
  24. Try adding the mysql_error() function like I've written below. It will print a database error in your web browser when you try to run the code. $db_username="nottelling"; $db_password="reallynottelling"; $database="realmof2_profiles"; $cfirst_name=$_POST['ud_first_name']; $cmiddle_init=$_POST['ud_middle_init']; $clast_name=$_POST['ud_last_name']; $ce_mail=$_POST['ud_e_mail']; $cphone=$_POST['ud_phone']; $cstreet_ad=$_POST['ud_street_ad']; $ccity=$_POST['ud_city']; $cstate=$_POST['ud_state']; $czipcode=$_POST['ud_zipcode']; $link = mysql_connect(localhost,$db_username,$db_password); $query = sprintf("UPDATE contactinfo SET first_name='$cfirst_name', middle_init='$cmiddle_init', last_name='$clast_name', e_mail='$ce_mail',phone='$cphone', street_ad='$cstreet_ad', city='$ccity', state='$cstate', zipcode='$czipcode' WHERE user_id='$userid'"); echo $query; mysql_query($query) or die mysql_error($link); mysql_close(); echo ' </div>';
  25. I'm not sure php is the best answer for something like this, but maybe someone else has an idea.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.