Jump to content

camdagr81

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Everything posted by camdagr81

  1. $path = pathinfo($_SERVER['PHP_SELF']); echo $path['basename'];
  2. <?php // get_file_name() Function function get_file_name($string) { $str_array = explode("/", $string); $token = count($str_array) - 1; $file = explode("?", $str_array[$token]); return $file[0]; } // Usage: echo get_file_name($_SERVER['PHP_SELF']); ?>
  3. Well if you're folders are on a network and your webserver has access to those folders, you can write a page using the copy() function then you can run the page from where ever you are (provided you have an internet connection) and update the files remotely.
  4. This is correct. The only way to automate file uploads is to set up an ftp server on your webserver and either run a batch file that will automate the process, find an ftp client that will allow you to schedule uploads, or write a php script using the ftp commands.
  5. You could of course use $_SERVER['HTTP_REFERER'] and try to come up with a statement that would determine if the user was coming from a page that is ahead of the current page in the site map. <?php $ref = $_SERVER['HTTP_REFERER']; if (preg_match('/page2.php/i', $ref)) { header("Location: page1.php"); } ?>
  6. <?php $query = "SELECT `mobile` FROM `customer`"; $result = mysql_query($query) or die(mysql_error()); $to = array(); while(list($mobile) = mysql_fetch_row($result)) { $to[] = $mobile; } // Test it foreach($to as $mobile) { echo $mobile . "<br>"; } ?>
  7. I tried to simplify what you're trying to do and maybe this will work. Try leaving the sprintF and the variable typing alone and see if that works: //Set the username as a variable $uname = $_SESSION['MM_Username']; $favsong = "Whatever your $_POST is for the favsong"; if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = "INSERT INTO `information` (`usernm`, `favsong`) VALUES ('$uname', '$favsong')"; mysql_select_db($database_registration, $registration); $Result1 = mysql_query($insertSQL) or die(mysql_error()); }
  8. My best guess is to start with a point of origin. Say New York City and then each zipcode from there out to Los Angelos has a distance from the orgin point associated to it. Then create a calculation that will give you the relation of a specific place based on the city you're trying to find out where some other city is farthest from. For example: if we make New York City our origin point and set it's value at 0 and want to know how far from Columbus, OH is from Atlanta, GA you would do the following equation (Pythagorean Theorem) a = NYC to COL ^ 2 (squared) b = ATL to COL ^ 2 c = NYC to ATL ^ 2 solving for b in the equation... a + b = c b = c - a then take the square root of b * Note this only works when you plot the 3 points as a right triangle
  9. Sure is $query = "SELECT temp_name,temp_char,temp_varchar FROM templates WHERE temp_name IN ('banner','link_txt')"; $sql = mysql_query($query,$conn) or die(mysql_error()); while(list($temp_name, $temp_char, $temp_varchar) = mysql_fetch_row($sql)) { echo $temp_name . '<br />'; echo $temp_char . '<br />'; echo $temp_varchar . '<br />'; }
  10. The problem is that you're not quoting your field and variable names. //Set the username as a variable $uname = $_SESSION['MM_Username']; ("INSERT INTO `information` (`usernm`) VALUES ('$uname')")
  11. <?php header("Location: www.yoursitehere.com/yourpage.php"); ?>
  12. That should do. Maybe add an index.php that sends the header to your main page: //Body of index.php in that directory <?php header("Location: http://www.yoursite.com"); ?> This will prevent anyone trying to get the directory structure of your folder. You should add that in all folders that don't have an index.html/php etc in them.
  13. cookies auto array, all you have to do is specify the name of the item when adding it to the cookie. [code] $time = time() + 360000; setcookie("sbh[id]", "$id", "$time", "/", ".sbhmed.com"); setcookie("sbh[uname]", "$uname", "$time", "/", ".sbhmed.com"); setcookie("sbh[fname]", "$fname", "$time", "/", ".sbhmed.com"); setcookie("sbh[ulevel]", "$ulevel", "$time", "/", ".sbhmed.com"); setcookie("sbh[email]", "$email", "$time", "/", ".sbhmed.com"); setcookie("sbh[date]", "$date", "$time", "/", ".sbhmed.com"); [/code] To retrieve the item you would do something like this: [code]echo $_COOKIE['sbh']['fname'];[/code]
  14. The problem is that you have $i set as 1 where it should be 0 but here's a better way to do it $query2 = "SELECT * FROM `phpnews_news` ORDER BY `id` DESC LIMIT 6"; $result2 = mysql_query($query2); $num = mysql_num_rows($result2); mysql_close(); for($i = 0; $i < $num; $i++) { // Your loop stuff here }
  15. This may not be the MOST efficient example but it should work well <?php $mnm = ''; $cnt = 1; $tot = 0; $names = array(); $sql = "SELECT `name`, `age` FROM `db` ORDER BY `name` ASC"; $dbq = mysql_query($sql); $num = mysql_num_rows($dbq); while (list($name, $age) = mysql_fetch_row($dbq)) { $tot += $age; if ($mnm != $name) { $names[$name] = "$name: $cnt"; $mnm = $name; $cnt = 1; } else { $cnt++; } } $avg = round($tot/$num); foreach($names as $getUsed) { echo $getUsed . '<br>'; } echo "<br>sAverage age: $avg"; ?>
  16. you would create a javascript control that uses the data posted in an array. I was jus showing you how you could write the javascript with php code, thus making your javascript dynamic at the page load. It's up to you to apply said knowledge
  17. LOL that's very dumb, and even dumber is them telling you to mod the dir. You're doing it the right way by saving to a local temp folder, I would see about adding those file types to the htaccess though so that your information isn't phishable.
  18. Hmmm not sure why it won't work for you. Maybe something server related then.
  19. Read the fread() function in the php manual. That will show you how to read the file contents. After understanding that, you would just insert the fread() data into a field in your table, just as if you were inserting regular text or numbers. The fields property has to be a blob so that the data doesn't get encoded. You will also want to specify some data about the file in the same node; such as: file name, file type, creation date, etc.. When you need to access the file you use fwrite(), dumping the contents of the blob field into a file.
  20. This should be around what you're trying to do <?php function new_file() { $cmd = $_POST['cmd']; $text = $_POST['data']; if ($text && $cmd == 'Post') { $dir = './files/'; $filename = time() . '.txt'; $newfile = $dir . $filename; $handle = fopen($newfile, 'a'); fwrite($handle, $text); fclose($handle); return "<a href='$newfile'>$filename</a>"; } } echo "<br>" . new_file(); ?> <form action="" method="post"> <textarea name="data"></textarea> <input type="submit" name="cmd" value="Post"> </form>
  21. Your best bet is to use an ftp batch file that watches your directory for new files then sends them to your host.
  22. you want the save as dialog to show up for the local machine or the hosting machine?
  23. each /tmp directory should be explicit to your hosting account. I've read somewhere (can't remember) that the host pc time could affect the session expiration. But I'm not sure in what way.
  24. you can use a <?php ?> tag in your javascript just like in the html sections. Just be sure to save your page as a .php file for instance: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test.php</title> <script type="text/javascript"> var test = "<?php echo 'HELLO WORLD'; ?>"; document.write(test); </script> </head> <body> </body> </html>
×
×
  • 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.