-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
document.theImage is undefined. That is clear. What web browser are you using? Use Firefox and use the error console to debug! tools >> error console
-
There have been many debates on this forum regarding this issue. Please don't start another. Run a search. Basically a hash cannot be reversed (md5 or sha1). i.e. hashes are used in comparisons against another hashed string. You can never discover the original string from a hash.
-
document.getElementById('text1').innerHTML = Messages[currentIndx];
-
OK, MS Word is the devils work as far as HTML encoding. An alternate solution could be to disable the default character encoding in your apache configuration. Look for: AddDefaultCharset And comment it out #AddDefaultCharset Restart apache
-
A div element does not contain a value attribute as form elements do! [code] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Test</title> <script type="text/javascript"> function setDiv() { var divElement = document.getElementById("text1"); divElement.innerHTML = "Hello World"; } </script> </head> <body> <a href="#" onclick="setDiv();">Display Message</a> <div id="text1"></div> </body> </html> [/code]
-
OK, then just refrain from pasting directly from Word. As I said paste into a text editor and then into your textarea for insert.
-
What does the character look like in your database? Microsoft uses non standard encodings. Do you have some sort of javascript HTML editor that you are using to insert your blog content? If so it will be retaining the MS Word formatting. You should paste the text from Word into a text editor first (i.e. notepad) and then copy into your textarea for insert to your blog. Not directly from MS word! If you are using a javascript editor to insert your blogs such as http://www.fckeditor.net/ there should be a config setting to force pasted content as plain text and not retain formatting (at least this one does). You will never be able to replace characters that have come from MS Word, trust me I have tried.
-
This will result in a sql error. Your braces are invalid after IN clause Fix <?php $createdby_sql = "'".implode("','", explode(" ", $_GET['createdby']))."'"; $sql = "SELECT * FROM test WHERE event IN('performance') and createdby IN ($createdby_sql)"; ?>
-
Custom HTML validation when inserting using PHP
JonnoTheDev replied to matfish's topic in PHP Coding Help
There are many non-paired tags that would need re-formatting however you can do this in one fowl swoop but you will need the 'php html tidy' extension. Read docs to install i.e linux: yum install php-tidy Convert the string to xhtml using <?php $string = "<img src='test.gif'><br><img src='test.gif'>"; $tidyConfig = array('output-xhtml' => true); $string = tidy_parse_string($string, $tidyConfig, 'UTF8'); // display the new output print "<xmp>".$string."</xmp>"; ?> -
Firstly your mail headers are incomplete. <?php $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/plain;\r\n"; $headers .= "X-Priority: 3\n"; $headers .= "X-MSMail-Priority: Normal\n"; $headers .= "X-Mailer: php\n"; $headers .= "From: \"".$_REQUEST['firstname']." ".$_REQUEST['secondname']."\" <".$email.">\n"; $headers .= "Reply-To: \"".$_REQUEST['firstname']." ".$_REQUEST['secondname']."\" <".$email.">\n"; ?> Do you know what mail relaying is? Your SMTP mail server is rejecting the email because: 1. The mail server is not responsible for the sender or sending domain or for the recipient or receiving domain. 2. The details of the sender could not be verified. In other words your mail server does not manage this domain: dpsconsultantsurveyors.co.uk Restrictions may have been put in place on your mail server. If this is not your server then your should contact your hosting company. It is not a script issue.
-
Custom HTML validation when inserting using PHP
JonnoTheDev replied to matfish's topic in PHP Coding Help
In other words you have a HTML text editor built in Javascript such as http://www.fckeditor.net/ You really should not have to do any replacing on elements. With these text editors there are usually configuration files that set the formatting of the document. You should be able to set XHTML as the preferred standard. If not get a better editor like the one posted above. It is fully configurable. -
Where is the $fetch object instantiated? I can't seem to find any ref to it in your script so your condition is always false. <?php if ($fetch->level == "owner"){
-
This doesn't always work. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> I usually force with a header at the top of every script (or common include): header('Content-Type: text/html; charset=UTF-8'); If you have funny characters in your database you could use mbstring extensions to convert the encoding: $string = "abc"; print mb_convert_encoding($string, "UTF-8", "auto"); Prior to inserting records in your database run the following query. Best straight after a connection has been established. mysql_query("SET NAMES UTF8"); Do not attempt to convert characters.
-
session_start(); Must be called prior to any output! HTML, echo, etc. Place at the top of all scripts that require session data. Best used in a common include file on all scripts i.e include('config.inc.php'); You should not be processing form data with your script in the middle of HTML output. It should come prior. There is no reason why this should be an issue. You need to look at re-organising your code structure as your layout sounds poor. Organisation: // common includes include('config.inc.php'); // processing scripts & functions function x() { } function y() { } if(strlen($_POST['submit'])) { $x = x(); $y = y(); } // html / php output <html> <head></head> <body> <form></form> </body> </html>
-
[SOLVED] Pass value from a function into mysql query
JonnoTheDev replied to jarvis's topic in PHP Coding Help
You must return values from functions for them to exist in the global scope. <?php function get_id() { $query1 = "SELECT `article_category_id` FROM `article_categories` WHERE `category` = 'Features'"; $result1 = mysql_query($query1) or die( "Could not execute SQL query" ); $row = mysql_fetch_array ($result1, MYSQL_ASSOC); return $row['article_category_id']; } ?> To improve this function you could use the category name as a parameter. The function can then be used to return the category id of any category. i.e. <?php function get_id($category) { $query1 = "SELECT `article_category_id` FROM `article_categories` WHERE `category` = '".$category."'"; $result1 = mysql_query($query1) or die("Could not execute SQL query"); $row = mysql_fetch_array ($result1, MYSQL_ASSOC); return $row['article_category_id']; } $id = get_id("Features"); ?> -
Implode requires an array as the 2nd parameter. You are attempting to implode a string that you are retrieving from each user object. What you must do is create an array of names from each object, then implode it. <?php $new_users = User::find_by_date(); $users = array(); foreach($new_users as $userObj){ $users[] = $userObj->username; } print implode(",", $users); ?>
-
Store in a session. Your form processing code should always be prior to any screen output! i.e. session_start() // form submitted if(strlen($_POST['submit'])) { $questionNum = $_POST['questionNum']; $answer = $_POST['answer']; // store answer $_SESSION['answers'][$questionNum] = $answer; // move onto next question header("Location:questions.php?q=".($questionNum+1)); exit(); } // form html goes down here This is a pure example. You must always validate the post data.
-
[SOLVED] getting JUST the browser , IE,Firefoxxx,OPERA etc.
JonnoTheDev replied to lynxus's topic in PHP Coding Help
Just find the parts of the user agent that identify what the browser is and then add to an array. Here's a start: <?php function isBrowser($userAgent) { $browsers = array('msie' => 'internet explorer', 'firefox' => 'mozilla firefox', 'avant' => 'avant browser'); foreach($browsers as $ident => $browser) { if(stristr($userAgent, $ident)) { return $browser; } } return false; } // usage if($x = isBrowser($_SERVER['HTTP_USER_AGENT'])) { print "Your browser is: ".$x; } else { print "Unknown web browser"; } ?> -
[SOLVED] getting JUST the browser , IE,Firefoxxx,OPERA etc.
JonnoTheDev replied to lynxus's topic in PHP Coding Help
The browser is contained within the user agent, you are extracting the wrong part of the string. Internet Explorer 7 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; IEMB3; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; .NET LR 2.0.50727; ZangoToolbar 4.8.3) Firefox 3.0.13 Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.13) Gecko/2009080317 Fedora/3.0.13-1.fc10 Firefox/3.0.13 http://www.user-agents.org/ You should check for a value within the user agent rather than extract it as all user agents are formatted differently and map it to a list of browsers i.e. array of browsers -
I Hate Regular Expressions! Can anyone help?
JonnoTheDev replied to LordLanky's topic in PHP Coding Help
You have not closed your H1 tag correctly!!!! Try this helpful function. <?php function parseArray($string, $openTag, $closeTag, $excluding = false) { preg_match_all("($openTag(.*)$closeTag)siU", $string, $matches); if($excluding) { return $matches[1]; } return $matches[0]; } $string = "<h1>The Work of an Idiot</h1> <p>Edited by A Total Moron</p> <h2>Chapter 1</h2> <p>Here is some random text</p> <h2>Chapter 2 - The Wrath of Khan's Mum</h2> <p>Here is some more random text</p> <h2>Chapter 3</h2> <p>Again.. i can ramble for ages</p>"; $array = parseArray($string,"<h1>","</p>"); $array = array_merge($array,parseArray($string,"<h2>","</p>")); print "<xmp>"; print_r($array); print "</xmp>"; ?> -
Your text is still blue. Honestly it is unreadable! Use white. Think about users who may have colour-blindness (accessibility).
-
text unreadable in blue