oni-kun
Members-
Posts
1,984 -
Joined
-
Last visited
-
Days Won
1
Everything posted by oni-kun
-
Showing us line 346 would be helpful you know...
-
Do you mean you're both working on a project? There's no reason you can't create a 'test.php' file and put a few of your new functions within there, and statically define user variables etc. You may want to use FOR loops as well, batching 100 uses of your function for example to test the speed of it, if it lags alot then you should optimize your code more. You should be able to test the basic function theory without the need of your partner's code.
-
Alright, got it to work. Thanks!
-
Notice: Undefined offset: 0 in D:\wamp\www\projects\trace.php on line 152 $fullhost = gethostbyaddr($ip); echo $fullhost; preg_match("/^(http:\/\/)?([^\/]+)/i",$fullhost, $matches); if(isset($matches[0])){ $host = $matches[2]; preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); echo "<b>ISP : "; echo strtoupper($matches[0]); //The error line 152 }else{ echo "ISP : [Cannot resolve]"; } It still displays undefined offset, I don't know if isset() is the thing to use to catch this.. help!
-
I have this code to get the IP address and turn it into the host, and extract 'isp.net' for example out of it.. But if there is no host, it throws the error.. "Undefined offset(0) in line xxx".. $fullhost = gethostbyaddr($ip); preg_match("/^(http:\/\/)?([^\/]+)/i",$fullhost, $matches); $host = $matches[2]; preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches); echo "<b>ISP : "; if($matches[0]==null){ echo strtoupper($matches[0]); }else{ echo "ISP : [Cannot resolve]"; } My code works, it simply throws that error when it can't resolve a host, since the preg_match doesn't pass through, how do I catch the 'offset not defined' and make it display the ELSE?
-
Does your XML appear at all? Because Firefox/IE always throws a style error or one-another if you view the XML directly... try viewing the source, and DOUBLE CHECK the <rss> tags are correct, I doubt it's really a PHP problem unless your database/rss feed is not valid, the code seems to be...
-
I'd comment out your echo'ing code for now and vardump everything to make sure it is 100% valid before displaying it as XML.. It seems to be dumping, but is not <tag>'ing or formatting in a valid manner, that's why you get the XML error.. Also you can note: echo "<a href=\"test\" rel=\"self\"></a>"; Can become: echo '<a href="test" rel="self"></a>'; Single quotes are handy when working with HTML.. no need to escape anything.
-
[SOLVED] hiding login/pass boxes once logged in HELP
oni-kun replied to shane85's topic in PHP Coding Help
No problem Be sure to mark this topic as solved, in the bottom left of the thread.. -
[SOLVED] hiding login/pass boxes once logged in HELP
oni-kun replied to shane85's topic in PHP Coding Help
That works great, you did a simple error there though.. This: if ($SESSION['$_SESSION['SESS_LOCATION_ID']' == false) { Needs to be changed into: if (!isset($_SESSION['SESS_LOCATION_ID'])) { ? You seemed to have accidentally nested invalid sessions, but 'a'b'c'd' would show as an error, quote wise. isset() should be as well instead of '==false'.. !isset() would mean if not set, aka not in the session.. -
[SOLVED] hiding login/pass boxes once logged in HELP
oni-kun replied to shane85's topic in PHP Coding Help
I'm sure what every website does (atleast mine), uses PHP to echo the box in the first place.. roughly like.. if ($SESSION['loggedin'] == false) { echo '<input type="textarea">blaa</input>';// Whatever HTML your login form has } else { echo "You are logged in as <b>".$SESSION['login_name']." <a href=\"logout.php\">log out</a></b>" } .. So it'd only appear when they're not logged in. -
I believe this is an SQL problem as your code seems alright. If it says 'RSS feed error'.. that is not in your code or SQL, is it? That means there's a problem in.. A) Either the database's output, B) The RSS is invalid.
-
I believe you can just use the 'each()' command, such as this: reset($array); while (list($key, $val) = each($array)) { echo "$key => $val\n"; //Write search code here } And it should list everything in the array even if unknown, then you can write a search function inside..
-
character encoding issue with a rating system help
oni-kun replied to co.ador's topic in PHP Coding Help
If this is a problem in your script I'm truly not sure. What I would recommend is using the PHP command utf8_encode() to make sure it's put in your database as UTF-8 and not ISO so it will display properly.. Do those not display at ALL, or come out as weird text? If they're not displaying at all, even if it's all UTF-8; then it's a problem with your script placing it in your database, because those characters should send. Double check the code that send to and from it to make sure it doesn't strip out UTF .... -
Serverside scripting to send and receive images?
oni-kun replied to RON_ron's topic in PHP Coding Help
I don't get what you mean. Do you mean send them to an e-mail? You cannot include an image with the mail() command. But you can include HTML to place an image in the mail.. such as... $message = '<img src="./images/1.gif"/> - I'm image one'; Such as that. But sending FROM abc@e-mail.com.. I haven't a clue what you're meaning... -
You should not use it in that fasion, you should use 'empty'. If (empty($ticker)){ die("Ticker is empty or not set"); //Display an error and kill page. } else { echo "Page is valid."; // Write code here if $ticker is valid } If $ticker is filled with a value then it'll execute the code in the ELSE, the DIE function is handy when writing a database error when you set text into it like I have..
-
character encoding issue with a rating system help
oni-kun replied to co.ador's topic in PHP Coding Help
Why can you not set it to this? <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> All your characters will display properly, you have no need to re-encode them, and the rating system will successfuly work. You may want to use header('Content-Type: text/html; charset=utf-8'); alongside to make sure it's all one encoding. The browser uses the meta tag, not your code, so one's browser will convert the UTF to mojimbake... the é, ', ñ, ú, ó é you're seeing. Only switching all to UTF will fix this! -
[SOLVED] language change and seo url problem...
oni-kun replied to pfkdesign's topic in PHP Coding Help
I'm not sure the variables, can't be arsed to look them up but you can do this.. if $lang = "de" header(Location: $_SERVER['SERVER_NAME'].'/de/'.$PATH.'/') else if $lang = "en" header(Location: $_SERVER['SERVER_NAME'].'/en/'.$PATH.'/') like that, you'll have to find out the $path $_SERVER var.. if there is one.. You can also simply use str_replace/regex to replace '/en/' in the href.. not too hard. -
Oh, simply you download the DOM parser and open it up. All you need is the one php file 'simple_html_dom.php' but you can browse the examples if you wish. For example... lets say you wanted to grab google's logo. <?php include('simple_html_dom.php'); $html = file_get_html('http://www.google.com/'); $logo = $html->find('#logo'); echo $logo; That'll return the div #logo with the image. You can easily traverse to someone's stats like you wanted, and parse the content after.. There are plenty of examples here.. http://simplehtmldom.sourceforge.net/manual.htm
-
Thankfully I've had the same problem before. There's a very simple single PHP file that can parse HTML/DOM for you, you just need to include it.. http://simplehtmldom.sourceforge.net/ You can made the coding as simple as this! // Create DOM from URL or file $html = file_get_html('http://www.google.com/'); foreach($html->find('div.scores') as $html) { $item['title'] = $html->find('div.title', 0)->plaintext; $item['rank'] = $html->find('div.rank', 0)->plaintext; $html[] = $item; } Like that sorta, can find div's and output their innerhtml and everything. echo $element->src . '<br>';
-
Here's a simple example on an url that would be found in a post.. //First find and add "http://" to an url without.. $URL = "www.example.com"; //Add http://www.. $http = strpos($URL, "http://"); $www = strpos($URL, "http://www."); if ($http === false){$URL = "http://.". $URL . "";} elseif ($www === false) {$URL = "http://www.". $URL . "";} //Replace URL with hyperlink. $hyperlink = preg_replace('/\\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i', '<a href="\\0">\\0</a>', $URL); www.google.com and google.com will become.. <a href="http://www.google.com">http://www.google.com</a> Hope that helps!
-
<?php //Cleaner $Profile['Dan'] = array ( "Age"=>"23", "Weight"=>"220", "foo"=>"bar" ); //Shorter $Profile['Fred'] = array ("Age"=>"33","Weight"=>"150","foo"=>"bar"); //Echo his 'Age' and 'Weight' key echo $Profile['Dan']['Age'].'<br/>'; echo $Profile['Dan']['Weight'].'<br/>'; //Example check if ($Profile['Dan']['Age'] > 18) { echo "Dan is older than 18!"; }; ?> To get an array within an array.. $Profile['Fred'] = array ("Age"=>"33","Weight"=>"150","foo"=>array("1"=>"one","2"=>"two")); $Profile['Fred']['foo']['1']; Sorry for all the edits, tiring night.
-
function checkUname() { global $uname; if(empty($this->username)) { echo "Username field is blank"; $this->myErrors++; } elseif($uname != $_POST['username'] && $_POST['Log-In'] == "Log-In"){ echo "Username does not exist"; $this->myErrors++; } elseif(strlen($this->username) < 5 || strlen($this->username) > 10) { echo "Username is to short"; $this->myErrors++; } elseif(!preg_match('/[^0-9a-zA-Z]/s', $this->username)) { echo "Username is not Alphanumeric"; $this->myErrors++; } elseif($uname == true && $_SESSION['create'] == "Create Account"){ echo "Username Taken"; $this->myErrors++; That should be better. Eregi is deprecated so it should be preg_match.
-
elseif(strlen($this->username) < 5 || strlen($this->username) > 15) Should be 5, "5" is a string. You should add a max amount of characters..
-
Can you do something as simple as this? $pn=$row_ot['product_name']; $pn = str_replace(" ", " ,", $pn); Being SPACE SPACE / SPACE COMMA. That should work fine as long as it's consecutive, unless you mean every second occurance, in that case regex I'm not sure about.
-
[SOLVED] Reload GD without reloading the whole page
oni-kun replied to guyfromfl's topic in PHP Coding Help
No problem! Remember you can always go to http://www.phpfreaks.com/forums/index.php/board,51.0.html The AJAX section to get more help on this.