-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
[SOLVED] only showing a value if it equals something?
MadTechie replied to shadiadiph's topic in PHP Coding Help
Remove debug's after testing directly <?php require("global/admin_functions.php"); if(!empty($_GET['adid'])) { $query = sprintf("SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=%d",$_GET['adid']); $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) > 0) { $img = mysql_fetch_assoc($result); $data = $img["thumbnail3"]; $type = $img["thumbnailtype3"]; die("FOUND: DATA type $type");//DEBUG header("Content-type: $type"); print $data; exit; } die("ERROR: No Records found"); //DEBUG } die("ERROR: adid not set"); //DEBUG header("Content-Type: image/png"); echo readfile('../pix/noimage.png'); ?> But i think the SQL is probably wrong try changing $query = sprintf("SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=%d",$_GET['adid']); to $query = sprintf("SELECT thumbnail3,thumbnailtype3 FROM zloads where ProductID=%d",$_GET['adid']); -
[SOLVED] How to draw a thick arc (20 pixels)
MadTechie replied to ExpertAlmost's topic in PHP Coding Help
Humm Well ImageSetThickness($img, 25); should do it but i think its a little buggy.. try saving as gif instead of png and use imagefilledarc twice, one with the foreground color then the background color ie <?php header("Content-Type: image/gif"); $img = imagecreatetruecolor(350, 350); $black = imagecolorallocate($img, 0, 0, 0); $red = imagecolorallocate($img, 255, 0, 0); imagefill($img,0, 0,$black); imagefilledarc($img, 70, 175, 300, 300, 315, 45, $red,IMG_COLOR_STYLEDBRUSHED); imagefilledarc($img, 60, 175, 300, 300, 315, 45, $black,IMG_COLOR_STYLEDBRUSHED); imagegif($img); ?> [attachment deleted by admin] -
Memory limit issues when downloading a large file to host.
MadTechie replied to shlomikalfa's topic in PHP Coding Help
Why do you say thats the problem ? Your not helping yourself by not giving ant useful infomation back, IE -
[SOLVED] Having to submit buttons for same form
MadTechie replied to jeff5656's topic in PHP Coding Help
Doesn't undermine mine as it mine doesn't use JS.... the javascript was in his existing code and probably does some validation.. The reason i didn't use the submit button value is due to the fact the values were are used to prompt the user and chaging those values would mean your need to update the php code.. when the button name are not seen by the (general) user.. thus updating the interface won't effect the code.. -
[SOLVED] Having to submit buttons for same form
MadTechie replied to jeff5656's topic in PHP Coding Help
Yeah you can't really have a form in a form like that <form name="newsubmit" method="post" action="addbill.php"> <input name="dx1" type="text" size="20" /> <input name="dx2" type="text" size="20" /> <input name="dx3" type="text" size="20" /> <input name="dx4" type="text" size="20" /> <input type="hidden" name ="id_incr" value="<?php echo $id_incr; ?>"/> <input type="submit" name="point1" value="Add and continue" onClick="return check('newsubmit', this.name)"/> <input type="submit" name="point2" value="Add and return to main view" onClick="return check('newsubmit2', this.name)"/> snipped lines that update the database based on the POSTed form mysql_query($query) or die(mysql_error()); if(isset($_POST['point1'])) { header("Location: editdos.php?action=edit&id=".$pt_id); } if(isset($_POST['point2'])) { header("Location: ../billview.php"); } ?> -
[SOLVED] Testing for newly created MS Word file
MadTechie replied to jhartog's topic in PHP Coding Help
LOL, Yeah well don't feel too bad i spend ages trying to work out why flush; wasn't working.. opps i mean flush(); it happens to all of us.. -
[SOLVED] delete same code numbers and save the text?
MadTechie replied to mr.echo's topic in PHP Coding Help
Okay forget that.. after i re-read your post i get what you mean now.. try this <?php $str = file_get_contents('input.txt'); $lines = preg_split('/\r\n/', $str); $NewFile = ""; $dirty = false; $dataset = array(); $dups = array(); foreach($lines as $line) { if (!isset($dups[$line])) { $dups[$line] = true; preg_match('/\|?([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)/sim', $line, $result); if(count($result)>0) { $dataset[$result[1]]= array($result[1], $result[2], $result[3], $result[4], $result[5]); //Only Use the last code $NewFile[$result[1]] = $line; } }else{ $dirty = true; } } if($dirty) { //write back $NewFile = implode("\r\n",$NewFile); file_put_contents('input2.txt',$NewFile); $str = $NewFile; } ksort($dataset); echo ' <style> .DersTablo { border:1px solid black; } .DersTablo td { text-align:center; border:1px solid black; margin:0; padding:0 } .DersTablo th { text-align:center; border:1px solid black; margin:0; padding:0 } </style> <table width="100%" class="DersTablo"> <tr> <th>code</th> <th>name</th> <th>credit</th> <th>need code</th> <th>explanation</th> <tr> '; foreach ($dataset as $k => $row) { echo '<tr>'; foreach ($row as $v => $field) echo '<td>'.$field.'</td>'; echo '</tr>'; } echo '</table>'; ?> -
[SOLVED] delete same code numbers and save the text?
MadTechie replied to mr.echo's topic in PHP Coding Help
you could make it display the dups.. as for auto deleting at the moment it only keeps the last one found.. but without knowing conditions thats the easiest option.. Heres a quick version to show dups.. (kinda a rush job but you get the idea) <?php $str = file_get_contents('input.txt'); $lines = preg_split('/\r\n/', $str); $code= "ELM2131"; //Manual Delete $NewFile = ""; $dirty = false; $dataset = array(); $dups = array(); foreach($lines as $line) { if (!preg_match('/^\|'.$code.'\|/i', $line)) { preg_match('/\|?([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)/sim', $line, $result); if(count($result)>0) { if(isset($dataset[$result[1]])) { $dups[$result[1]][0]= $dataset[$result[1]]; $dups[$result[1]][]= array($result[1], $result[2], $result[3], $result[4], $result[5]); } $dataset[$result[1]]= array($result[1], $result[2], $result[3], $result[4], $result[5]); //Only Use the last code $NewFile[$result[1]] = $line; } }else{ $dirty = true; } } if($dirty) { //write back $NewFile = implode("\r\n",$NewFile); file_put_contents('input2.txt',$NewFile); $str = $NewFile; } ksort($dataset); echo ' <style> .DersTablo { border:1px solid black; } .DersTablo td { text-align:center; border:1px solid black; margin:0; padding:0 } .DersTablo th { text-align:center; border:1px solid black; margin:0; padding:0 } </style> <table width="100%" class="DersTablo"> <tr> <th>code</th> <th>name</th> <th>credit</th> <th>need code</th> <th>explanation</th> <tr> '; foreach ($dataset as $k => $row) { echo '<tr>'; foreach ($row as $v => $field) echo '<td>'.$field.'</td>'; echo '</tr>'; } echo '</table>'; ksort($dups); echo "<pre>";print_r($dups); ?> -
$package1 = "'".implode("','", $_POST['pack'])."'"; // string #$package1 = implode(",", $_POST['pack']); // numbers echo $package1; $sql = "SELECT * FROM dailypicks1 WHERE sport = '$sport' AND active = '$active' AND package IN ($package1)";
-
$result = mysql_query("SELECT * FROM `pm` WHERE `username`= '".$Data8['username']."' AND `status`='unread' ") or die(mysql_error()); $num_roows = mysql_num_rows($result); you missed the field selection
-
[SOLVED] Testing for newly created MS Word file
MadTechie replied to jhartog's topic in PHP Coding Help
have you tried $this->assertTrue(file_exists(substr($test_dir, 0, -3) . 'txt')); also break it down a little and test each part.. -
it depends on how your calling the .tpl file.. if you include it it should work fine.. if your getting its contents then you could use str_replace() to replace a marker/tag ie Hello world We have <!--MovieCount--> Movies $movies = 100; $str = file_get_contents("myfile.tpl"); $str = str_replace("<!--MovieCount-->", $movies, $str); echo $str; If your using ITX then you could try this add {Movies} to the tpl flie look in your code for something like this $template = new HTML_Template_ITX its the part that loads in your template.. Note the Red part and use the same below Now add this after the SQL query $MoveCount = 999; $template->setVariable("Movies", $MoveCount);
-
[SOLVED] delete same code numbers and save the text?
MadTechie replied to mr.echo's topic in PHP Coding Help
It should be deleting dups automatically.. But it saves them in input2.txt you could change that to input.txt at your own risk -
A little example This is HTML<br> Total TV Shows : <?php echo $row['TotalMovies']; ?><br> Total Episodes : <?php echo $row['TotalCats']; ?><br> Not the HTML is outside the <?php tags you could also do this <?php echo "Total TV Shows : ".$row['TotalMovies']; ?>
-
[SOLVED] delete same code numbers and save the text?
MadTechie replied to mr.echo's topic in PHP Coding Help
Okay heres an update.. it allows you to remove any code manually, but also automatically removes any dups.. <?php $str = file_get_contents('input.txt'); $lines = preg_split('/\r\n/', $str); $code= "ELM2131"; //Manual Delete $NewFile = ""; $dirty = false; $dataset = array(); foreach($lines as $line) { if (!preg_match('/^\|'.$code.'\|/i', $line)) { preg_match('/\|?([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)/sim', $line, $result); $dataset[$result[1]]= array($result[1], $result[2], $result[3], $result[4], $result[5]); //Only Use the last code $NewFile[$result[1]] = $line; }else{ $dirty = true; } } if($dirty) { //write back $NewFile = implode("\r\n",$NewFile); file_put_contents('input2.txt',$NewFile); $str = $NewFile; } ksort($dataset); echo ' <style> .DersTablo { border:1px solid black; } .DersTablo td { text-align:center; border:1px solid black; margin:0; padding:0 } .DersTablo th { text-align:center; border:1px solid black; margin:0; padding:0 } </style> <table width="100%" class="DersTablo"> <tr> <th>code</th> <th>name</th> <th>credit</th> <th>need code</th> <th>explanation</th> <tr> '; foreach ($dataset as $k => $row) { echo '<tr>'; foreach ($row as $v => $field) echo '<td>'.$field.'</td>'; echo '</tr>'; } echo '</table>'; ?> -
Well i could read all your code and try to work it out but.. it would be easier if you told us what you mean but
-
Hi Happy Holidays I'll assume this in a SQL Database, and you have the following fields ID = an autonumber (likely primary) Added = timestamp for when the reocrds was created (recommeded) Name = Movie Name Categories = Movie categories (i'll also assume you have data with this field containing TV an Episodes and i'll guess the table is called Movies SELECT count(*) as TotalMovies FROM Movies $Row['TotalMovies'] SELECT count(*) as TotalCats FROM Movies GROUP BY Categories $Row['TotalCats'] SELECT * FROM Movies ORDER BY Added DESC Limit 5 you could used ID instead of Added but i recommend you have a timestamp Hope that helps i assumed alot so it probably wrong lol
-
[SOLVED] delete same code numbers and save the text?
MadTechie replied to mr.echo's topic in PHP Coding Help
I'm not 100% sure what your asking but if you wanted to delete the ELM2131 (record) you could do something like this <?php $filename = 'input.txt'; $fp = fopen( "input.txt" , "r" ); $str = fread( $fp, filesize($filename)); //Remove the BIM2111 record $code= "BIM2111"; $str = preg_replace('/('.$code.'(?:\|[^|]*))\|/sim', '', $str); // you may want to write it back to the file (not sure, of the goal) -
The 'example' i gave gives you the 'name' the example should give you all the info you need to do almost anything with the supplied XML file!
-
it does but then you don't use the row ..... then the loop starts and it pulls the next record as a associative array until no more records exist.. if that makes sence
-
[SOLVED] users in groups and echo the group on profile
MadTechie replied to contra10's topic in PHP Coding Help
I did also say that -
heres a quick update <?php $html = 'this is some stuff <a href="http://www.mydomain.com/dir/thefile.pdf">Read More</a> for update dating the <a href="http://youdomain.com/another.pdf">Other Stuff</a>html'; $html = preg_replace('%<a href=(["\'])(.*?\.pdf)\1>(.*)</a>%sim', "<div class=\"pdf\">\r\n<a href=\"\2\" target=\"_blank\" title=\"\3\"><img class=\"left\" src=\"images/pdf_download.png\" alt=\"Download PDF\" width=\"64\" height=\"74\" /></a>\r\n<span class=\"title\">\3</span>\r\n<span class=\"info\">download pdf</span>\r\n<a href=\"\2\" target=\"_blank\" title=\"\3\" class=\"link\">DOWNLOAD</a>\r\n</div><div class=\"pdf-bot2\"></div>", $html ); echo $html; ?> what input are you using ? and what do you expect to see ?
-
Yeah but your missing the first row because of this line $row = mysql_fetch_array($bus_result); remove it shoild fix the problem $bus_result = mysql_query("SELECT * FROM regions ORDER BY `country`, `region`"); // $row = mysql_fetch_array($bus_result); //<---REMOVE $oldgroup=""; $first=1; while ($row=mysql_fetch_assoc($bus_result)) { if ($row['country']!=$oldgroup) { if (!$first) echo "</optgroup>\n"; echo "<optgroup label=\"".$row['country']."\">\n"; $oldgroup=$row['country']; $first=0; } echo "<option value=\"#".$row['region_variable']."\">".$row['region']."</option>\n"; } echo "</optgroup>
-
Memory limit issues when downloading a large file to host.
MadTechie replied to shlomikalfa's topic in PHP Coding Help
If you can give me a link of a large file i'll take a look, i don't have an account so it could be a pain.. in anycase try a simple script like this <?php echo download("http://file_to_download.zip", "localstorage.zip"); function download($filename, $write) { $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($filename, 'rb'); $writer = fopen($write, 'w'); if ($handle === false) return false; while (!feof($handle)) { set_time_limit(0); fwrite($writer, fread($handle, $chunksize)); ob_flush(); flush(); } $status = fclose($handle); fclose($writer); return $status; } ?> -
[SOLVED] users in groups and echo the group on profile
MadTechie replied to contra10's topic in PHP Coding Help
Okay its 4am so i'm about to get some shut eye.. but i would have the users table ie UserID - Name - email 1 - Admin - ME@me.com 2 - John - john@me.com 3 - Sam - sam@me.com 4 - Paul - paul@me.com a Groups Table ie GroupID - Name 1 - Admins 2 - Users 3 - Noobs then a third table to join them UserID - GroupID 1 - 1 2 - 3 4 - 3 3 - 2 3 - 3 Soo then an SQL like SELECT Users.*, Groups.Name FROM Users JOIN UserGroups ON UserGroups.UserID = Users.ID JOIN Groups ON Groups.id = UserGroups.GroupID Where Users.ID = $UserID If you only want 1 group per used then just add an extra field in the users table to hold the Group ID then alter your SQL statment like so current SELECT * FROM Users Where ID = $UserID SELECT Users.*, Groups.Name FROM Users JOIN Groups ON Groups.id = Users.GroupID Where Users.ID = $UserID assuming the added to users field was called GroupID Hope that helps EDIT: corrections .. but its probably still wrong.. ahh bed is calling