camdagr81
Members-
Posts
43 -
Joined
-
Last visited
Never
Everything posted by camdagr81
-
$path = pathinfo($_SERVER['PHP_SELF']); echo $path['basename'];
-
<?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']); ?>
-
[SOLVED] need the truth about multiple uploads without browsing
camdagr81 replied to rline101's topic in PHP Coding Help
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. -
[SOLVED] need the truth about multiple uploads without browsing
camdagr81 replied to rline101's topic in PHP Coding Help
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. -
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"); } ?>
-
<?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>"; } ?>
-
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()); }
-
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
-
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 />'; }
-
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')")
-
<?php header("Location: www.yoursitehere.com/yourpage.php"); ?>
-
why does this code fail to set the session expiration properly?
camdagr81 replied to bitt3n's topic in PHP Coding Help
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. -
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]
-
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 }
-
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"; ?>
-
PHP element control array and JavaScript accessing them
camdagr81 replied to mweinberger's topic in PHP Coding Help
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 -
why does this code fail to set the session expiration properly?
camdagr81 replied to bitt3n's topic in PHP Coding Help
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. -
Hmmm not sure why it won't work for you. Maybe something server related then.
-
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.
-
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>
-
[SOLVED] Uploading a file without a file field?
camdagr81 replied to bird_man11's topic in PHP Coding Help
Your best bet is to use an ftp batch file that watches your directory for new files then sends them to your host. -
you want the save as dialog to show up for the local machine or the hosting machine?
-
why does this code fail to set the session expiration properly?
camdagr81 replied to bitt3n's topic in PHP Coding Help
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. -
PHP element control array and JavaScript accessing them
camdagr81 replied to mweinberger's topic in PHP Coding Help
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>