-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
post to-self this will reload the form with the new data or use AJAX
-
well when your done.. remember to click solved bottom left
-
Ahhhh.. scrapping.. have you tried file_get_contents ie <?php $data = file_get_contents("http://www.google.com"); echo str_replace("Lucky","Unlucky",$data); ?> if you need more control your need to use cURL or fSockets
-
[SOLVED] convert magic quote string to non-magic quote string...
MadTechie replied to Fog Juice's topic in PHP Coding Help
you could do this <?php $firstname = "Chris"; $string = 'Hello my name is $firstname'; preg_match_all('/\$(\w+)/si', $string, $result, PREG_PATTERN_ORDER); for ($i = 0; $i < count($result[0]); $i++) { $rep = $result[1][$i]; $string = str_replace("$$rep", $$rep, $string); } echo $string; ?> -
Okay lets say i have a script that acts as an image.. ie <?php header("Content-Type: image/jpeg"); $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); imagestring($im, 1, 5, 5, "This is a image!", $tc); imagejpeg($im); ?> Loading it up by itself works fine.. BUT if add echo "Hello world"; to the start.. (before or after the header) it fails the reason is because the client browser reads the header and expects to get VALID image data and will display it as an image.. now, just say i wanted to use a function to create the image ie <?php function DisplayImage() { header("Content-Type: image/jpeg"); $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); imagestring($im, 1, 5, 5, "This is a image!", $tc); imagejpeg($im); } ?> this is fine..but how are we going to call it ?? remember you can NOT send anything to the browser before hand! one solution may be this <?php $test="test.jpg"; DisplayImage($test); echo "<img src=\"$test\">"; function DisplayImage($file) { //header("Content-Type: image/jpeg"); $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 150, 30, $bgc); imagestring($im, 1, 5, 5, "This is a image!", $tc); imagejpeg($im,$file); } ?> NOTE: i commented out the header! as we are creating a file
-
Add a new Auction Item - Cant Figure Out How To Place the Script -
MadTechie replied to FuZzI's topic in PHP Coding Help
Well i am not going to read all the code until you give more details ABOUT how it didn't work Need more detail -
to grab that try this <?php $html = 'unfortunately, I cannot grab the page as the "http://www.somedomain.com/forum/search.php?do=getdaily" link returns the page I need as a result of the search.'; $found = ""; if (preg_match('/(https?:\/\/)[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/si', $html, $regs)) { $found= $regs[0]; } echo $found; ?>
-
My way uses a phase stored in a config.php file which is not part of the SQL system and the tables doesn't have to be a single table! i fail to see how you can even consider that is safer than
-
still wrong section post in "PHP Installation", 'make clean' gets rid of improperly compiled files.
-
while its a pain to fix its the better option for example add $file = $_GET['file']; to the start of THAT script should work
-
change <input id="file" type="file" name="file"> to <input type="file" name="file"> and <input id="submit" type="submit" name="submit" value="Upload me!"> to <input type="submit" name="submit" value="Upload me!">
-
Can you click solved (bottom left) your need to test in milliseconds, storing in an array will take more memory and is a tad slower Unless you use the array over and over in which case its worth the extra memory as it becomes quicker
-
Try this <?php $sSQL = "SELECT prodnum, description FROM products WHERE discontinued=0 ORDER BY prodnum "; $result = mysql_query($sSQL) or die(); //Put rows into an array $list = array(); while($row=mysql_fetch_row($result)) $list[] = $row; for ($r=0; $r<20; $r++) { /* regular textboxes work so I know connection is good and getting right information */ print '<select name="text' . $r . "3" . '">'; //Reuse the array foreach($list as $row) { print '<option value=' . $row[0] . '>' . $row[0] . " " . $row[1] . '</option>'; } print '</select>'; // etc etc } ?> *untested **Comments added
-
Can you post the form itself
-
okay <?php //Build a list of all days and remove the found ones ?> what code do you have so far ?
-
<?php $ct++ ; $list= array();//<--add this first (at the start of the script) $list[$ct] = $subcat2; $concat = $concat.", ".$list[$ct]; ?> *corrected typo
-
Build a list of all days and remove the found ones
-
can you not do this SELECT credits.*, debits.* FROM credits, debits ORDER BY debits.date, credits.date ASC
-
I think i know what you mean.. are you trying to extract the FULL URL ?
-
A few things, i fixed them except 2 which need to be set.. <?php //$rname=""; <---You need to set this //$yname=""; <---You need to set this ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="550" height="400"> <param name="movie" value="ecard.swf?yname=<?php echo $yname; ?>&rname=<?php echo $rname; ?> " /> <param name="quality" value="high" /> <embed src="ecard.swf?yname=<?php echo $yname; ?>&rname=<?php echo $rname; ?> " quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed> </object> </body> </html>
-
do you have session_start(); at the start of the script ?
-
if you use a function to create the image your need to output to an image FILE (then return the file path/name) or call it without outputting ANYTHING else.. (read up on headers for more info)
-
Add a new Auction Item - Cant Figure Out How To Place the Script -
MadTechie replied to FuZzI's topic in PHP Coding Help
Need more detail -
something like this <?php $fulltext = "blar <p>Hello world</p> blar"; $text = ""; if (preg_match('%<p>(.*?)</p>%si', $fulltext , $regs)) { $text= $regs[1]; } echo $text; ?>
-
If you don't know i have to assume you didn't write the class.. in which case i would recommend you read the documentation that came with the class