-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
Which is easier than using a substr also sasa code should be $x = explode('/', $url); not $x = ekplode('/', $url);
-
basically you use strrpos and substr ie <?php $path = "../../images/aprilfoolcards/lovefoolsday.gif"; $cat = substr($path, 13, strrpos($path,"/", 13)-13); echo $cat; ?> untested EDIT updated: made a pigs ear of that!
-
[SOLVED] Pagination on flat database? please help
MadTechie replied to superkingkong's topic in PHP Coding Help
no, I just used the same code on post#2 as you posted. where do i need to update this code? $Page = (int)(!empty($_GET['page']))?$_GET['page']:1; ? Replace the first $Page with the code above No worries your doing great, is it correct? Yep very correct.. i missed that (was untested), -
Okay, the script is creating the png file (in its raw format) and what your doing is the same as opening the png file in a text editor and dumping it contents in a HTML page, this fails (as your seeing) To solved this you need to make the php appear as a png file.. to do this you use header() which you seam to be doing.. BUT what you need to do is call that php script as it is was a image So if my php script is called "createPNG.php" you put this in your HTML output like this <img src="createPNG.php"> So simply put create a file that is only used outputting the PNG raw data with the header set and then call that VIA the html file.. if thats confused you then please post what you have
-
No.. it will not "cause" it, clicking the submit button does! 1. display form 2. submit form (file get uploaded here) 3. the form tiggers the (php) script in actions. So by the time the php has started the file is already in temp!
-
No its not the same problem he has "Connection refused" this means the script found the server but was denied access (port blocked or something along those lines) you problem is your php took too long to connect this is why i got you to increase timeout to 15.. Lets create a smaller script and try to get it to connect.. at let try to find out why theirs a problem! First turn off any firewall you may have a test, (remember to turn the firewall on after the tests) if you old script still fails then try this. (this script is only for getting exta info) <?php error_reporting(E_ALL); // Use cURL to get the RSS feed into a PHP string variable. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://www.dpreview.com/feeds/news.xml'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $xml = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); echo "<br>------------------------------<br>"; echo "<pre>";var_dump($info);echo "</pre>"; echo "<br>------------------------------<br>"; die($xml); try that script in a new file and pass back the output!
-
when you upload a file, if it fits in the limts set in php.ini (ie max_filesize etc) then the file goes to tmp,, this happens before your script starts ie 1. Form is submitted 2. files are uploaded 3. action script is tiggered 4. action script does the move from $_FILES['var']['tmp_name'] to path you choose So before you make the move you check to see if the uploaded file has a tmp name ($_FILES['var']['tmp_name']), if not then the file wasn't uploaded, of couse you can also check the error ie if($_FILES['var']['error'] == 0) { # upload is fine } i hope that helps!
-
[SOLVED] Pagination on flat database? please help
MadTechie replied to superkingkong's topic in PHP Coding Help
did you update the code for the page ? ie $Page = (int)(!empty($_GET['page']))?$_GET['page']:1; -
I was asking if you had them on.. try turning them off..
-
[SOLVED] Pagination on flat database? please help
MadTechie replied to superkingkong's topic in PHP Coding Help
if your using $_GET then just do a help like for "?Page=".($Page-1) and "?Page=".($Page+1) for previous and next if you want a full page number list then just create loop from 1 to $totalPages with a simple echo "<a href='?page=".$n."' >$n</a>"; -
Could be a firewall, do you have safe mode enabled , or open_basedir applied ? to be truth this isn't really a coding question anymore!
-
[SOLVED] Pagination on flat database? please help
MadTechie replied to superkingkong's topic in PHP Coding Help
your do it something like this <?php $Page = 1; $Entries = 30; // Open log file $logfile = "log.db"; if (file_exists($logfile)) { #$handle = fopen($logfile, "r"); #$log = fread($handle, filesize($logfile)); #fclose($handle); $fulllog = file($logfile); } else { die ("The log file doesn't exist!"); } // Seperate each logline #$log = explode("\n", trim($log)); // After that it may be useful to get each part of each logline in a separate variable. // This can be done by looping through each logline, and using explode again: $totalPages = ceil(count($log)/$Entries); $end = $Entries*$Page; $start = $end-$Entries; // Seperate each part in each logline $log = array(); for ($i = $start; $i < ($end); $i++) { $log[$i] = trim($fulllog[$i]); $log[$i] = explode('|', $fulllog[$i]); } echo "<p>Total Entries : " . count($fulllog) . "</p>"; // Show a table of the logfile //rest of your code -
use the function file_exists() <?php $file = '../images/image_1.jpg'; if(file_exists($file)) { echo "<img src='$file'>"; }else{ echo "<img src='no_image.jpg'>"; } ?>
-
echo "from PHP $Monkeh said"; so your code should look something like this <?php $query = "SELECT * FROM `cards`"; $result = mysql_query($query) or die (mysql_error()); if (mysql_num_rows($result)>0) { echo'<select name = "cards">'; while ($row = mysql_fetch_array($result)) { $cid=$row[0]; $hid=$row[1]; $cards=$row[2]; echo "<option value=\"$cid\">$cards</option>\n"; } echo'</select>'; } ?>
-
Code is fine the problem is with your Server and/or Configuration i tested it on my local PC, I assume you rebooted..and i assume the code your testing is the same as you posted! (except moving the last preg_replace into the make_safe function)
-
why? uploads what?
-
Okay well $xml is empty.. try these inorder (test after each one) #1 reboot apache and retest #2 increase the timeout Add curl_setopt($ch, CURLOPT_TIMEOUT, 15); after curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); #3 Add error reporting Add error_reporting(E_ALL); , to the start of the page (after the <?php)
-
Please read this thread again! i have no idea why you added "file_get_contents" back in!
-
by the sounds of thing you just want to check its valid!.. but also you want to extract details! telling me its changes and need to be a wildcard (i know what wildcard is thus if it changes i know its going to be a wildcard) With all that in-mind i'll have to assume you want parent:' to ' sprintf(LANG.lvnote_createafilter, ' to ') data: to ; i'll also assume the order is the seam each time! in that case try <?php preg_match('/parent:\s*\'([^\']*)\'.*?sprintf\(LANG.lvnote_createafilter, \'([^\']*)\'\).*?data: ([^;]*);/si', $Contents, $Matches) $parent= $Matches[1]; $createafilter= $Matches[2]; $data= $Matches[3]; } ?>
-
Nope infact as 'element_set' isn't a php function i googled 'xml_regex.php' and found the site http://www.bobulous.org.uk/coding/php-xml-feeds.html this stats this means use one or the other! the reason for that use due to this line // Create an array of item elements from the XML feed. $news_items = element_set('item', $xml); its not creating an array try changing $xml = curl_exec($ch); curl_close($ch); to $xml = curl_exec($ch); curl_close($ch); die($xml);//added for debugging and see if your getting the sites RSS details!
-
Your need to give an example as i'm not sure what you mean!
-
[SOLVED] I need help creating a thumbnail with GD
MadTechie replied to devdavad's topic in PHP Coding Help
that suggests that imagecreatefromXXX isn't working.. thus checking to see if the file exists would be my first step.. do you have error_reporting on ? -
Sorry i'm a little confused.. what are you trying to check for ? maybe a few examples and bolding the thing you need to check for.. are you trying to get the data between "data: " and the ";" ? if so try this preg_match_all('/data: ([^;]*);/s', $Contents, $Matches, PREG_PATTERN_ORDER); $Matches= $Matches[1]; echo "<pre>"; var_dump($Matches);
-
[SOLVED] I need help creating a thumbnail with GD
MadTechie replied to devdavad's topic in PHP Coding Help
As a guess.. (as it looks okay try this) <?php //add at the start. $uploadedPictExt = strtolower($uploadedPictExt); if(!file_exists("../photos/" . $_POST["photo_name"] . $uploadedPictExt)) { die("Error: file not found"); } ?> -
Well that RegEx isn't even valid! "http/i" should atleast be "/http/i" it doesn nothing to protect against bcc's it check to see if http exists in the $variable, as which stripos would be quicker!.. heres a quick version that will probably work. basically it check for newlines content-type:, to:, cc:, bcc in the body and just newlines in the email and to fields <?php //check valid email if(!validemail($email)) { die("invalid email"); } //check name + email if(!(has_no_newlines($name) && has_no_newlines($email) && (has_no_emailheaders($body))) { die("Inject detected"); } function has_no_newlines($text) { return preg_match("/(%0A|%0D|\n+|\r+)/i", $text); } function has_no_emailheaders($text) { return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text); } function validemail($email) { return (preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$/i",$email)) } ?>