redbullmarky
Staff Alumni-
Posts
2,863 -
Joined
-
Last visited
Never
Everything posted by redbullmarky
-
take a look at ober's [url=http://www.phpfreaks.com/forums/index.php/topic,79168.0.html]Resources sticky[/url] at the top of website critique. Under 'Tools', the top link is all about colour and is pretty good IMO. I've used it a few times. C_V, i'd hate to see how your house has been decorated :o :D
-
no. there is absolutely no reason ever ever ever to turn register_globals on anymore. $_GET/$_POST will work regardless. might be worth having a quick readup: [url=http://uk2.php.net/register_globals]register_globals[/url]
-
if you have a file that you pretty much include on EVERY page in your site, you could always define the docroot with one of: [code] <?php // for MacOSX define('DOCROOT', '/Users/acidity/Sites'); //change to suit // for other define('DOCROOT', $_SERVER['DOCUMENT_ROOT']); ?> [/code] and then use [code] require(DOCROOT . '/csp-include/db.php'); [/code] or similar.
-
^ i posted an edit before. should sort you out.
-
can you post a screenshot or something of your output? [b]edit:[/b] oops sorry. you need to specify that you want it cut: [code] $row[3] = wordwrap($row[3], 40, '<br />', true); [/code]
-
as for your first question, the method still stands, be it get or post. your $_GET/$_POST arrays will be set as normal, just with the addition of the $_FILES array too. as for your second question, i honestly dont have a clue. as far as i know, all files have a mime type when uploading via a form.
-
if line 8 is [code] $query = "SELECT title, news FROM nyheter WHERE id = $_GET['id']"; [/code] then try [code] $query = "SELECT title, news FROM nyheter WHERE id = {$_GET['id']}"; [/code]
-
anywhere you like, as long as it's AFTER you retrieve it from the DB and before you display it. [code]<?php $hostname = ; $username = ; $password = ; $conn = mysql_connect($hostname, $username, $password) or die(mysql_error()); $connection = mysql_select_db(" ", $conn); $query = "SELECT * FROM feedback"; $mysql_result=mysql_query($query,$conn); $row=mysql_fetch_row($mysql_result); $i=1; while(($row!="") && ($i<=4)) { // ***** HERE WILL DO ***** $row[3] = wordwrap($row[3], 40); echo("<table width=80%>"); echo "<tr>"; echo "<td width=40%><b>Feedback Received By:</b></td><td>$row[1]</td></tr>"; echo "<tr><td width=40%><b>Feedback:</b></td><td>$row[3]</td></tr>"; echo "</table><hr>"; $row=mysql_fetch_row($mysql_result); $i++; } ?>[/code]
-
the single dot would imply you're referring to the current directory. personally, i always steer clear of ./ and ../ when dealing with includes. try require($_SERVER['DOCUMENT_ROOT'] . '/csp-includes/db.php') instead, and require($_SERVER['DOCUMENT_ROOT'] . '/index.php') in your db.php
-
you may have 'short tags' support turned off. meaning that <? and <?= wont be supported. change it to <?php echo (in your 'action' part of your form tag) and give it a blast. definitely definitely definitely turn register_globals back off ;)
-
sure - but if your layout is breaking as a result of lines that are too long, then the lines they're are entering are too long, which either means: 1) their spacebar is knackered 2) the code above needs to be used to chop the line up into smaller pieces that wont bust your layout. otherwise, there maybe a problem with quotes being displayed, etc. you might want to use [url=http://www.php.net/htmlspecialchars]htmlspecialchars[/url] which will convert quotes, arrows < and >, etc, into 'special' entities (" , < and > respectively in this example). [code] <?php echo nl2br(htmlspecialchars($text)); ?> [/code]
-
Hi all Probably one for the lazier helpers (like me ;)), but how about a [manual] tag added to the BBCode tags? so... [manual]echo[/manual] would automatically display 'echo' but linked to php.net manual like [url=http://www.php.net/echo]echo[/url] cheers Mark
-
are we talking someone typing lines purposely too long here? there are two other methods. either use CSS overflow:hidden, or PHP's [url=http://www.php.net/wordwrap]wordwrap()[/url] function. [code] <?php $text = "iamaridiculouslylongbitoftextthathasnospacesandisdesignedtobuggerupahtmllayout"; $text = wordwrap($text, 40, "\n"); ?> [/code] the above will split the sentence every 40 characters with a line break.
-
it depends. normally, the only sort of text too wide for a site is a URL. otherwise, you need to widen your site :) non-wrapping is a result of a lack of spaces. so make some. if its a URL, i've occasionally used this: [code] <?php $text = str_replace('?', '?<wbr>', $text); $text = str_replace('&', '&<wbr>', $text); ?> [/code] which inserts a "soft" line break after your &'s and ?'s. meaning - the line will appear continuous, UNLESS it needs to be broken. carefull with this one though, as browser support is a bit rubbish.
-
i either refer to a file in one of these three ways: [code] <?php // when i wanna include something outsite the web root include('/var/www/vhosts/mysite.com/scripts/myfile.php'); // when i wanna include something within my web root include($_SERVER['DOCUMENT_ROOT'] . '/includes/myfile.php'); // when i wanna include something that is ALWAYS in the same directory as the file that i put this line in include(dirname(__FILE__) . '/myfile.php'); ?> [/code] that should help you on your way cheers Mark
-
each time you're intending to append the $message variable, you're actually overwriting it. a good ole full stop will do the trick: [code] <?php $to = "myemailaddress@emailserver.com"; $subject = "Comments"; $message = 'Name: '.$_POST['name']."\n\n"; $message.= 'Address: '.$_POST['address']."\n\n"; $message.= 'Email: '.$_POST['email']."\n\n"; $message.= 'Phone: '.$_POST['phone']."\n\n"; $message.= 'Comments: '.$_POST['comments']."\n\n"; $headers="From: " . $_POST['email'] . "\n"; Mail($to,$subject,$message,$headers); ?> [/code] you have 5 lines starting with $message. notice i've change the $message = to $message.= which basically means it'll append new content to existing content, rather than setting it afresh. cheers Mark
-
yup. more specifically: [url=http://uk2.php.net/manual/en/function.pspell-suggest.php]pspell_suggest[/url] For a list of all the spelling functions, take a look [url=http://uk2.php.net/manual/en/ref.pspell.php]here[/url] the only thing i can think of is that some forms of disability are going to be more medical terms rather than general English, so you may need to delve a bit further into adding custom dictionaries to get it work how you want. cheers Mark
-
how do you mean pushing your layout out of whack? if youre on about lines being too long and not breaking, you'll need to do a few things to chop the lines up a bit. the way i display data from a database depends on what type of data it is. if it is data in a TEXT or BLOB field, then i generally use [url=http://www.php.net/nl2br]nl2br[/url] to maintain the line breaks as i intended. if its a case of lines being too long, then either insert a space every nth character to break the line up, or insert a HTML <wbr /> tag which some browsers support.
-
i'm assuming that when you posted most of your 'addcity' function to start with, youre talking about that one in particular. we'll start there anyway: can you add an extra line for me, just to make sure the data is being populated into the query: where you have: [code] $db->query("INSERT INTO cities VALUES(NULL, '$name', '$desc', '$minlevel')"); [/code] in addcity, can you change it to: [code] $query = "INSERT INTO cities VALUES(NULL, '$name', '$desc', '$minlevel')"; echo $query; $db->query($query); [/code] and tell me what the query is when you add a new city?
-
are you getting any errors? can you post the whole function and your 'switch' statement that goes before your list of 'case's?
-
if this is your whole file: [code]<?php $newlang = $_GET['newlang']; $lang = $_COOKIE['lang']; if (isset($newlang) AND !eregi("\.","$newlang")) { if (file_exists("languages/".$newlang.".php")) { setcookie("lang",$newlang,time()+31536000); include("languages/".$newlang.".php"); $currentlang = $newlang; } else { setcookie("lang",$language,time()+31536000); include("languages/".$language.".php"); $currentlang = $language; } } elseif (isset($lang)) { include("languages/".$lang.".php"); $currentlang = $lang; } else { include("languages/".$language.".php"); $currentlang = $language; } ?>[/code] then line 18 (where your error is) is: [code] include("languages/".$language.".php"); [/code] right? i'm assuming that this, as well as: [code] } else { setcookie("lang",$language,time()+31536000); include("languages/".$language.".php"); $currentlang = $language; } [/code] is some kinda fallback incase no cookies have been sent and no language as been specified in the URL. if that's the case, default to english (or whatever language you wanna default to): [code]<?php $newlang = $_GET['newlang']; $lang = $_COOKIE['lang']; $language = 'en'; // default to 'en' if no lang specified if (isset($newlang) AND !eregi("\.","$newlang")) { if (file_exists("languages/".$newlang.".php")) { setcookie("lang",$newlang,time()+31536000); include("languages/".$newlang.".php"); $currentlang = $newlang; } else { setcookie("lang",$language,time()+31536000); include("languages/".$language.".php"); $currentlang = $language; } } elseif (isset($lang)) { include("languages/".$lang.".php"); $currentlang = $lang; } else { include("languages/".$language.".php"); $currentlang = $language; } ?>[/code] give that a blast
-
you're referring to a variable called $language. where is this coming from?
-
lol no probs. for the future, i'd strongly strongly strongly (STRONGLY) recommend always turning register_globals off in your php.ini file (most default installations/webhosts do this by default these days, hence why your site works differently on localhost where you probably have it turned on) and using $_GET/$_POST/$_COOKIE instead of just the variable name . sure, it means it takes a little longer to type ($_GET/$_POST/$_COOKIE/$_FILES) but it has two advantages. 1) you close many security loopholes and 2) it generally makes your code easier to follow - ie, you can clearly see that $_GET['lang'] / $_COOKIE['lang'] means a URL variable ?lang=en or a cookie, whereas if it's just $lang, you wont have a clue. cheers Mark
-
not sure i'm following you now. basically what you need to aim for is proper retrieval of get/post/cookie values. register_globals is funny like that - if it's off, you need to specify where the data is coming from. so if you're referring to something in the URL, use $_GET. if you're referring to something in a <form> with method set to 'post', use $_POST. if you're referring to a cookie, use $_COOKIE. can you explain your code a little better and try and isolate where the issue is?
-
[code] <?php $newlang = $_GET['newlang']; $lang = $_GET['lang']; if (isset($newlang) AND !eregi("\.","$newlang")) { if (file_exists("languages/".$newlang.".php")) { setcookie("lang",$newlang,time()+31536000); include("languages/".$newlang.".php"); $currentlang = $newlang; } else { setcookie("lang",$language,time()+31536000); include("languages/".$language.".php"); $currentlang = $language; } } elseif (isset($lang)) { include("languages/".$lang.".php"); $currentlang = $lang; } else { include("languages/en.php"); $currentlang = "en"; } ?> [/code] try that. am i right then in thinking that you DO intend to get lang/newlang from the URL? [b]edit:[/b] if not (and it looks like youre trying to get $lang from a cookie) change my line to: [code] $lang = $_COOKIE['lang']; [/code]