QuickOldCar
Staff Alumni-
Posts
2,972 -
Joined
-
Last visited
-
Days Won
28
Everything posted by QuickOldCar
-
I agree with you, but person running other site may know even less, or not willing to pay someone to get it done.
-
Calling someone a thief and not being able to code as a response wasn't too nice, I surely wouldn't like it, neither would you. They could have easily had special permission from the owners of http://www.trulos.com I doubt was the case or would have stated that fact, but should think of this the next time someone is asking for help on the same subject.
-
Help me to choose a Hosting Solution
QuickOldCar replied to mostafatalebi's topic in PHP Coding Help
A good reliable and honest host. http://www.limestonenetworks.com/ -
Wordpress uses filtering within the posts by default. Can find it in wp-includes/kses.php If it's just you posting data can edit the filter file directly, Can also add something like below in your functions.php file, refer to wordpress code pages to find out what they are. This one is to stop putting everything into a paragraph automatic. remove_filter( 'the_content', 'wpautop' ); Then you have plugins to get the job done. http://wordpress.org/extend/plugins/raw-html/ http://wordpress.org/plugins/exec-php/ You can also include(),file_get_contents() or iframe the script on a page, store it somewhere on your server or within the themes template file. Speaking of template file, you can also make custom pages. Here would be a simple template Make it a php file and drop it into your current theme folder. <?php /* Template Name: myPage */ ?> <?php get_header(); echo "Hello There"; get_footer(); ?> What you do is go and make a new page, and to the lower right select in this instance... myPage template
-
PHP, quickest method to check another server online status?
QuickOldCar replied to MySQL_Narb's topic in PHP Coding Help
Try using multi-curl or this rolling curl using it http://code.google.com/p/rolling-curl/ Would be best saving the status to a database, and updating it to alive or dead. Show from the database results and not a live script upon view. -
Let user to take picture from webcam/smart phone
QuickOldCar replied to pascal_22's topic in PHP Coding Help
Check this out to take a picture from a webcam. http://tutorialzine.com/2011/04/jquery-webcam-photobooth/ -
Try adding these to the top of your script ini_set('memory_limit', '-1'); set_time_limit(0); Maybe you can handle how many you get different, like fetch the first array and save that into lists or files. Then systematically fetch the title data later,whether by pulling the top one from a text file, or even from a database marking is as fetched when you do. Can try unsetting any arrays you make when are not needed any longer.
-
$link = "Paste full <a href='photo.jpg' rel='prettyPhoto'>click now</a> ....";
-
So others do not have to download it. connect.php <?php define('DB_HOST','localhost'); define('DB_USER','ben'); define('DB_PASS',''); define('DB_NAME','tightcms.com'); $connection = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); ?> functions.php <?php include "connect.php"; $site = new site; $admin = new admin; class site { function name() { $query = mysql_query("SELECT * FROM site_config") or die(mysql_error()); while($sn = mysql_fetch_assoc($query)) { echo "<h1>" . $sn['sitename'] . "</h1>"; } } function login($username, $password) { if(isset($username)) { if(isset($password)) { include "connect.php"; $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($query); if(md5($password) == $user['password']) { $_SESSION['user'] = $user['username']; $_SESSION['userid'] = $user['id']; echo '<script>alert("Successfully Logged In!");</script>'; header("Location: index.php"); } else { echo "<script>alert('Please check your login details!');</script>"; echo '<META HTTP-EQUIV="Refresh" Content="0; URL=login.php">'; exit; } } else { echo "Please check your password!"; include "login.php"; exit; } } else { echo "Please check your username!"; include "login.php"; exit; } } } class admin { function navigation() { echo "<ul>"; echo "<li><a href='index.php'>Home</a></li>"; echo "<li><a href='logout.php'>Logout</a></li>"; echo "</ul>"; } } ?> index.php <?php include "functions.php"; session_start(); if(isset($_SESSION['user'])) { ?> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> </body> </html> <?php } else { header("Location: login.php"); } ?> login.php <!DOCTYPE HTML> <html> <head> <?php include "functions.php"; if (!empty($_POST['login-submit'])) { $site->login($_POST['username'], $_POST['password']); } ?> </head> <body> <?php session_start(); if(isset($_SESSION['user'])) { header("Location: index.php"); } else { ?> <form name="login" method="post"> <table> <tr> <td><label for="username" id="white" align="center">Username: </label></td> <td><input type="text" name="username" /></td> </tr> <tr> <td><label for="password" id="white">Password: </label></td> <td><input type="password" name="password" /></td> </tr> <tr> <td colspan="2"><input type="submit" name="login-submit" value="Login!" /></td> </tr> </table> </form> <?php } ?> </body> </html> logout.php <?php session_start(); session_destroy(); header("Location: login.php"); ?> users.sql -- phpMyAdmin SQL Dump -- version 3.5.6 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Aug 20, 2013 at 08:13 PM -- Server version: 5.5.29-log -- PHP Version: 5.3.21 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; -- -- Database: `tightcms.com` -- -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `full_name` mediumtext NOT NULL, `username` varchar(250) NOT NULL, `password` varchar(150) NOT NULL, `date_of_birth` varchar( NOT NULL, `bio` longtext NOT NULL, `eal` varchar(1) DEFAULT NULL, `pic_path` varchar(100) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`id`, `full_name`, `username`, `password`, `date_of_birth`, `bio`, `eal`, `pic_path`) VALUES (1, 'Administrator', 'admin', '9cdfb439c7876e703e307864c9167a15', '18/05/00', 'lol lol lol', '1', NULL); /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-
If searched for John and Elton John comes up, the search works, it wouldn't work so well otherwise. If you needed more control and wanted to spend the time more advanced and multiple search queries, fulltext search is a better way. http://dev.mysql.com/doc/refman/5.7/en/fulltext-search.html Fulltext Boolean can do things matching against,within,excluding,stemming,weighted and so on. http://dev.mysql.com/doc/refman/5.7/en/fulltext-boolean.html
-
It's a complete out of the box package. The WampServer package is delivered whith the latest releases of Apache, MySQL and PHP
-
place msvcr110.dll into your windows/system32 folder
-
Some example to find within an array <?php $SearchTerms=array('Høstnatt på Fjellskogen', 'Langt Innpå Skoga', 'Den lille fløyten', 'Sølv'); // my array with search terms $string = "Den lille fløyten"; // The string to search //using in_array() if(in_array($string,$SearchTerms)){ echo $string." found <br />"; } else { echo $string." not found <br />"; } //using preg_match $found = array(); foreach ($SearchTerms as $str) { if (preg_match ("/\b($string)\b/i", $str, $matches)){ $found[] = $matches[1]; } } print_r($found); echo "<br />"; //preg_grep() $found2 = array(); $found2 = preg_grep("/\b($string)\b/i", $SearchTerms); print_r($found2); ?> returns: Den lille fløyten found Array ( [0] => Den lille fløyten ) Array ( [2] => Den lille fløyten )
-
would something like this work? $number_value = 0; while($row = mysql_fetch_assoc($rs)) { $answers = array($row['ans1'], $row['ans2'], $row['ans3'], $row['ans4']); shuffle($answers); $questions[] = array( 'que_id' => $row['ques_id'], 'q' => $row['que_desc'], 'answers' => $answers ); shuffle($questions); $output = "<ol>\n"; foreach($questions as $ques) { $output .= "<li>\n"; $output .= "{$ques['q']}<br>\n"; foreach($ques['answers'] as $answ) { $number_value = $number_value + 1; $output .= "<input type='radio' name='".$answ[$number_value]."' value='$number_value'>'".$answ[$number_value]."<br>\n"; } $output .= "</li><br>\n"; }
-
$number_value = 0; while($row = mysql_fetch_assoc($rs)) { $answers = array($row['ans1'], $row['ans2'], $row['ans3'], $row['ans4']); shuffle($answers); $questions[] = array( 'que_id' => $row['ques_id'], 'q' => $row['que_desc'], 'answers' => $answers ); shuffle($questions); $output = "<ol>\n"; foreach($questions as $ques) { $output .= "<li>\n"; $output .= "{$ques['q']}<br>\n"; foreach($ques['answers'] as $ans => $answ) { $number_value = $number_value + 1; $output .= "<input type='radio' name='answ' value='$number_value'> $answ<br>\n"; } $output .= "</li><br>\n"; }
-
I'd be willing to help you out depending how much was involved and what scripts they were.
-
here is a function that may be of use to you, modify it to your needs. <?php function random_row($table, $column) { $max_sql = "SELECT max(" . $column . ") AS max_id FROM " . $table; $max_row = mysql_fetch_array(mysql_query($max_sql)); $random_number = mt_rand(1, $max_row['max_id']); $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " >= " . $random_number . " ORDER BY " . $column . " ASC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); if (!is_array($random_row)) { $random_sql = "SELECT * FROM " . $table . " WHERE " . $column . " < " . $random_number . " ORDER BY " . $column . " DESC LIMIT 1"; $random_row = mysql_fetch_row(mysql_query($random_sql)); } return $random_row; } //USAGE echo '<pre>'; print_r(random_row('YOUR_TABLE', 'YOUR_COLUMN')); echo '</pre>'; ?>
-
Is always difficult to get true random results. You can try shuffle() more than once, or try array_rand() and use the count of results in array I have also used making a numbers range() with a combination of mysql's max(), and then selecting some results from x many results using key values
-
Yes, just doing the names be much simpler, I agree with AbraCadaver's suggestion.
-
Trying to make a simple form to send to PHP. PLEASE HELP!
QuickOldCar replied to Joefuss's topic in PHP Coding Help
Your code worked fine for me, I changed it a tiny bit. <form action="" method="post"> <input type="text" name="user_input" size="20"> <input type="submit" name="press" value="Press da button!"> </form> <?php $user_input = trim($_POST['user_input']); if (isset($_POST['user_input']) && $user_input != '') { echo "You posted ".$user_input."."; } else { echo "Insert Something"; } ?> Leaving the action empty will take it to same page as the script is. Trim removes whitespace, no need for blank values, also added a check for if was blank -
If you can now read this data in a file through php, you can make each a variable and make it an array in a loop, then insert them into mysql using columns and fields you come up with. I'm sure you can glob the directory and do each file like I said above, is hard to determine without seeing an example of the data in each file, and how you can seperate the data. Usually people would have a cvs or text file and use mysql's Load Data Infile There are some import tools out there for popular file types, I doubt will find a .gfr one. So with that said, I believe you will have to either do replaces on each of your files and change yourself to a more popular format, or write a script that does this for you. Either way you will have to find the unique data in each of your files so can be inserted into mysql how you would like it.
-
If you know the filename you want can do something like this, you can add your preg match checking to it. <?php //read a file $my_file = "filename.txt"; if (file_exists($my_file)) { $data = file($my_file); $total = count($data); echo "<br />Total lines: $total<br />"; foreach ($data as $line) { $line = trim($line); echo "$line<br />"; } } else { echo "No file to display"; } ?>
-
Trying to use PHP to bypass the iFrame 'Same Origin Policy' issue
QuickOldCar replied to djs1's topic in PHP Coding Help
Try using file_get_contents() or use curl to get the raw data of the page.- 3 replies
-
- php
- same origin policy
-
(and 2 more)
Tagged with:
-
How to Access Same Website Locally and Non-locally?
QuickOldCar replied to fastpurplemedia's topic in Miscellaneous
using localhost or 127.0.0.1 should let you see it locally -
You have to also include the subcategories GET in the next and previous hyperlinks you generate $paginationDisplay .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '&subcategory=' . $subcategory . '"> Next</a> '; And you should be making any data inserted into mysql be safe...escaped, trim the GET so isn't whitespace Gonna post you the php freaks pagination tutorial, and also 2 pagination scripts I made, maybe something of use will be in them for you or get a better idea. http://www.phpfreaks.com/tutorial/basic-pagination This one has a set 10 per page results and jumping x amount as needed http://dynaindex.com/paginate This one can set the amount to what want, but the navigation is more basic. http://dyna.dyndns.tv/paginate/