-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Cont. from kickstart here's some example use single quotes <?php if(isset($_SESSION['uid'])) echo '<a href="http://www.bluesapphirestudios.com/search/logout.php">Logout</a>'; //this is line 22 else echo '<a href="http://www.bluesapphirestudios.com/search/main_login.php">Login</a>'; ?> escape the quotes <?php if(isset($_SESSION['uid'])) echo "<a href=\"http://www.bluesapphirestudios.com/search/logout.php\">Logout</a>"; //this is line 22 else echo "<a href=\"http://www.bluesapphirestudios.com/search/main_login.php\">Login</a>"; ?> replace the htmls doubles for singles <?php if(isset($_SESSION['uid'])) echo "<a href='http://www.bluesapphirestudios.com/search/logout.php'>Logout</a>"; //this is line 22 else echo "<a href='http://www.bluesapphirestudios.com/search/main_login.php'>Login</a>"; ?> All the best Keith MadTechie
-
Well if we got it wrong we're going to look like idiots.. but i think we're fine
-
Pawn, I would like to say thank you, for posting back your work, its nice to see people share their work instead of just taking (I have only skimmed it but it looks fine) quick notes: 1. you may want to update if to protected against SQL injection 2. In the foreach($result as $src) loop you could also add the same sort of SQL routine, (but really isn't required)
-
[SOLVED] Find only certain URLs from page ... regex (semi-complete script)
MadTechie replied to doa24uk's topic in Regex Help
While I 100% agree, with nrg_alpha, i had already updated the script.. just removed missed out one part I personally help people who want to learn.. and not those who want the work done for them (don't get me wrong I'm happy to help but if your going to be picky then put some effort in yourself), <?php $dom = new DOMDocument; @$dom->loadHTMLFile('http://rapidshare.com/users/IZF0LP'); $xpath = new DOMXPath($dom); $aTag = $xpath->query('//a[contains(@href, "http://rapidshare.com/files")]'); $list = array(); foreach ($aTag as $val) { //echo $val->getAttribute('href') . ' => ' . $val->nodeValue . "<br />\n"; $list[] = $val->getAttribute('href'); } //remove dups from array here foreach ($list as $val) { echo $val . "<br />\n"; } ?> -
Using different fonts in PHP generated images
MadTechie replied to cactuscake's topic in PHP Coding Help
see imagettftext -
it would seam that imap can't open that server path.. check server/port/path
-
remove the @ and read the error
-
proc_open $process = proc_open("perl.pl", $handles, $pipes);
-
Well considing you said use $binFile= basename($_FILES['userfile']['name']; then changed it to $binFile= basename($_FILES['binFile']['tmp']; which was exactly the same as mine (note that userfile changed to binFile and use of tmp ) at which time i was updating mine to from tmp to tmp_name it seams strange you now have updated again to tmp_name.. « Last Edit: Today at 15:38:47 by Bricktop » this looks like a copy and paste to me
-
@Bricktop why copy my post (shame I missed the _name part) but at least i corrected it
-
~Coughs~ I don't think getting the original name of the file is going to help $_FILES['binFile']['tmp_name'] is for the temporary filename of the file in which the uploaded file was stored on the server.
-
You sure you mean $binFile= $_POST['binFile']; and not $binFile= $_FILES['binFile']['tmp_name'];
-
I guess you could do something like this (replace sessions with a database) <?php session_start(); $URL = 'http://www.apple.com/'; if(!isset($_SESSION[$URL])) { $total = 0; $start = microtime(true); $homepage = file_get_contents($URL); $total += microtime(true)-$start; preg_match_all('/src=(["\']?)([^\1]+?)\1/m', $homepage, $result, PREG_PATTERN_ORDER); $result = $result[2]; foreach($result as $src) { $start = microtime(true); @file_get_contents($src); $total += microtime(true)-$start; } $_SESSION[$URL] = $total; } echo $_SESSION[$URL]; ?> You could even store the scr's with times in a database, add a timestamp and update when the timestamp is older than X
-
[SOLVED] Need help finding siple error in script...
MadTechie replied to DiscoTrio's topic in PHP Coding Help
1. use code tags 2. have you checked the values and the field types in database ? -
[SOLVED] Functions - Something isn't right?
MadTechie replied to Joshua4550's topic in PHP Coding Help
Quick note/tip, Try not to put your functions in the middle of your code.. it makes it a nightmare to read later also you could get problems calling them if you loss them in a block ie <?php test(); if(false){ function test(){ echo "World"; } } ?> -
[SOLVED] preg-match with a string and numbers
MadTechie replied to imperium2335's topic in Regex Help
Great resource is right here its mainly simple ones and practice ie if (preg_match('/id="table-\d+"/', $string)) { echo "valid" } finds id="table- then a \d (digit) + (means 1 or more) and then finds a " Now if it finds the digits but then NOT a " it won't match so 12b" would fail on my second example i put () around the \d+ this means capture (store in $dump) now $dump[0] = the full matched string $dump[1] = the first captured item okay that's a break down of what you have.. hope that helps and doesn't scare you away it takes time when I first saw them i was but they seam simpler now -
[SOLVED] Functions - Something isn't right?
MadTechie replied to Joshua4550's topic in PHP Coding Help
Yep.. that's correct, if solved then please click topic solved (bottom left) oh an welcome -
[SOLVED] preg-match with a string and numbers
MadTechie replied to imperium2335's topic in Regex Help
try this Check only if (preg_match('/id="table-\d+"/', $string)) { echo "valid" } get the number if (preg_match('/id="table-(\d+)"/', $string,$dump)) { echo $dump[1]; } -
[SOLVED] Functions - Something isn't right?
MadTechie replied to Joshua4550's topic in PHP Coding Help
Your function uses the $Menu variable from $Menu = mysql_fetch_array($Menu_Query); But its hasn't been passed to the function, also your function isn't being called or returning anything here is a totally untested example (but may work) <?php // Allow the front page to display 15 recent news entries $NEWS_QUERY = 'SELECT * FROM `Sites_News` WHERE `site`=\'' . $SITENAME . '\' ORDER BY `ID` DESC LIMIT 15'; $Menu_Query = mysql_query("SELECT * FROM `Sites_Menus` WHERE `site`='" . $SITENAME . "'") or die(mysql_error()); $Menu = mysql_fetch_array($Menu_Query); $MENUS= NewCat($Menu, $category, $links, $urls); //call function and set returned value to $MENUS function NewCat($Menu, $category, $links, $urls) { //also passed $Menu $Cat = explode(",", $Menu[$category]); $MENUS = ""; if ($Cat[0] == "true") { if ($Cat[2] == "true") { $fieldset_class = "menu gold"; } else { $fieldset_class = "menu"; } $MENUS .= ' <fieldset class="' . $fieldset_class . '"> <legend>' . $Cat[1] . '</legend> <ul> '; $link = explode("^", $Menu[$links]); $url = explode("^", $Menu[$urls]); for ($i = 0; $i < count($link); $i++) { if ($link[$i] == null || empty($link[$i]) || $link[$i] == " " || $url[$i] == null || empty($url[$i]) || $url[$i]==" ") { continue; } $MENUS .= ' <li><a href="' . $url[$i] . '">' . $link[$i] . '</a></li> '; } $MENUS .= ' </ul> </fieldset> '; } return $MENUS; //return $MENUS } ?> EDIT: added some comments -
[SOLVED] preg-match with a string and numbers
MadTechie replied to imperium2335's topic in Regex Help
Can you give an example of what your expect to pass and fail ie A. table-12 = pass B. table-123 = pass C. table-1a3 = fail or pass ? D. table-abc = fail E. mytable-1 = fail or pass ? With C/E would it pass as its "table-1" ? What does it match up to ? ie name="table-12" would match the text from " to " -
can you post your updated code, the only problem i can see is if(isset($hasError)) header('Location: contacterror.html'); should be if($hasError) header('Location: contacterror.html'); it maybe worth posting the form as well
-
Nice catch mikesta707, that what I get for being lazy and copying and pasting from buggy code
-
it's a quick dirty way to convert the float to a string, of course you could also you ctype or (string), the reason you convert to a string is because of the way floating points work, for example 100 / 3 = 33.333333333....etc now that calculation would never end, so PHP put it as 33.3 but then 33.3*3 = 99.9, now as a string you can have "33.3333333" if you wanted, and when you use it in a calculation it will be converted to the correct type ie echo "33.3333333"*3; // = 99.9999999 (now you only loss 0.0000001 when you multiple it by 3, instead of 0.1) I would recommend looking at BCMath Arbitrary Precision Mathematics EDIT: updated