premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
Use sessions to make page preview for artcile
premiso replied to vividona's topic in PHP Coding Help
Session's are just fine, but if you use MySQL you can store a "draft" of the article for backup purposes and just display the last draft. -
You have to do the joins prior to the where, you have them mixed in. I am not sure if my syntax is right but give this a try: $query2 = "SELECT questions.questionno, questions.question, questions.quizref, questions.questionref, answers.answerno, answers.answer, answers.answervalue, answers.questionno, answers.quizref, answers.answerref, quiz.quizref, quiz.name, quiz.createdby FROM questions JOIN answers ON questions.questionno = answers.questionno JOIN quiz ON quiz.quizref = answers.quizref WHERE questions.questionno = ".$row['questionno']. " AND quiz.quizref = ".$id;
-
The problem is that anything after the / gets filtered as keyword. I would instead make a "keyword" to take in the keywords, such as: yousite.com/k/keywords-to-pass-to-garb or yoursite.com/garb/keywords-to-pass-to-garb This way only that is filtered to it and your index.html stays the same. Hope that helps.
-
Look into cURL and possible Google for advice on how to do it, as I have never used a proxy with cURL.
-
Looks alright to me. I would go as far to say that I would setup an array "white" list instead though: $page = isset($_GET['act'])?strtolower($_GET['act']):'index'; // default to index if no data $validPages = array("index", "view", "user", "contact"); // example white list if (in_array($page, $validPages)) { include('./pages/'.$page.'.php'); } But your way is secure, given that you verify the file_exists. Just another way of doing it
-
Just found this at the preg_replace man. function clickable($url){ $in=array( '`((?:https?|ftp)://\S+[[:alnum:]]/?)`si', '`((?<!//)(www\.\S+[[:alnum:]]/?))`si' ); $out=array( '<a href="$1" rel=nofollow>$1</a> ', '<a href="http://$1" rel=\'nofollow\'>$1</a>' ); return preg_replace($in,$out,$url); } May be what you are looking for.
-
elseif statement failing to execute his assigment.
premiso replied to co.ador's topic in PHP Coding Help
Order of Operations. elseif($tac == 4){ // displaying ok. } elseif (($drop != '') && ($tac == 4)) { $tac == 4 up above that, so there for the second elseif there cannot be ran as the one above it will be entered no matter what. Flip those around and it should work as you expect. -
You can use sessions to persist the data. Basically when the user uploads the image store the post inputs you want saved in session. On the form page in the html input value you would have something like: <input type="text" name="somename" value="<?php echo isset($_SESSION['somename'])?$_SESSION['somename']:'';?>" />
-
SELECT SUM(counts) FROM table
-
Yes, headers cannot be sent if output has already been sent to the browser, it would cause an error. To generally tests scripts like these I would write data to a "log" file instead, that way you can see the data in the log file and it won't break the script.
-
$val == "£3.24" $val = str_replace (chr(ord("£")),"",$val); Using the char with ord maybe that will help this script locate the actual character. Give that a shot see if it works for ya.
-
$slots = array("9-10" => array("User1" => "Work", "User2" => "Work"), "10-11" => array("User1 => "Work2", "User2" => "Work2")); Would be the structure I would use.
-
The only way "easy" I know of would be using this technique: http://www.webaim.org/techniques/powerpoint/convert.php Alternatively you can probably use Citrix to accomplish that, but that would cost quite a bit of money for the license and requires software installation on the server.
-
Perhaps this will help you get your head around the idea of how to do it: http://www.phpfreaks.com/forums/index.php/topic,286115.msg1356963.html#msg1356963
-
Well here is a script I wrote (the tutorial is located at: Fetch View / Profile Data with PHP Using GET <?php /********************** File: view.php Author: Frost Website: http://www.slunked.com ***********************/ // Be sure to change these values to match your databases. mysql_connect("localhost", "username", "password") or trigger_error("MySQL Connection Failed: " . mysql_error()); mysql_select_db("database") or trigger_error("MySQL Select DB Failed: " . mysql_error()); //Check if we have GET data and if so static cast it to an integer. // Casting it to INT will prevent SQL Injection etc. $viewID = isset($_GET['id'])?(int) $_GET['id']:false; if ($viewID) { // Well we have a valid integer let's try to grab it: $sql = "SELECT viewid, title, content FROM view_content WHERE viewid = {$viewID} LIMIT 1"; $result = mysql_query($sql) or trigger_error("Retrieving View Contents Failed: " . mysql_error()); // verify that we have 1 result if (mysql_num_rows($result) == 1) { $row = mysql_fetch_assoc($result) or trigger_error("Fetching Row failed: " . mysql_error()); $output = <<<OUT View ID: {$row['viewid']}<br /> Title: {$row['title']}<br /> Content: {$row['content']}<br /> OUT; }else { $output = "An invalid view id was passed."; } }else { $output = "An invalid view id was passed."; } echo $output; ?> With test data from MySQL being setup as: -- The Table Structure CREATE TABLE view_content ( viewid INT NOT NULL auto_increment, title VARCHAR(50) NOT NULL, content TEXT NOT NULL, PRIMARY KEY (viewid) ); --Now for the test data: INSERT INTO view_content VALUES (1, 'Test 1', 'Testing Content 1.'), (2, 'Test 2', 'Testing Content 2.'), (3, 'Test 3', 'Testing Content 3.'); Hopefully that helps you out!
-
Mis-haps can still happen. Is your server directory structure the exact same? I would just verify the source of the HTML that the images are pointing to the right location and verify that the images are in the correct location. The red x's mean that the image is not at the location it is pointing to. Simple as that.
-
Make sure the images are on the server where the html file points to, as that is the issue. Nothing to do with PHP from what you have stated so far, it has more to do with the images actually being on the server and in the proper location. Moving to HTML section.
-
A do / while would probably work if you never let the script exit until you tell it to. But doing so could eat up your Server Resources and make your site sluggish depending on how many users use it. As multiple processes constantly running like that on the server will eat up the resources. AJAX / Javascript is a much better solution. You could also possibly have that in an iframe and just have the iframe constantly refreshing, but that would still require Javascript.
-
Since you own them, you can use Google Adsense Domain (if you think anyone will goto them) and make a little revenue off of ads, but if no one ever goes there kinda pointless.
-
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/using-php-to-backup-mysql-databases.aspx The email will be trickier, but I trust you can use google to figure out how to email attachments, I will not do that google for you.
-
From the glob site at php.net a user contribution: Contributed by php at hm2k.org <?php // $Id: rglob.php,v 1.0 2008/11/24 17:20:00 hm2k Exp $ /** * Recursive glob() */ /** * @param int $pattern * the pattern passed to glob() * @param int $flags * the flags passed to glob() * @param string $path * the path to scan * @return mixed * an array of files in the given path matching the pattern. */ function rglob($pattern='*', $flags = 0, $path='') { $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); $files=glob($path.$pattern, $flags); foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); } return $files; } /* example usage: */ chdir('../'); var_export(rglob('*.php')); ?>
-
Simple solution: Add a column in your database called, "pageorder" and use that to show what page they are on.
-
Client side php script. That makes no real sense. To send mail using php you can use mail or the phpMailer class which can be found via google.
-
I will not provide the full answer / code as that is cheating imo. But you need to look into file sort fopen foreach fwrite and fclose. All will need to be used to do what you are tasked with.