premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
$result = @mysql_query("SELECT postTXT, postID, postTITLE, posterEMAIL, DATE_FORMAT(DATE_SUB(postTIME, INTERVAL 1 HOUR), '%h:%i %p | %m/%d/%Y') as postTIME FROM comtbl ORDER BY postID DESC"); Not sure if that will work but yea.
-
Oh, I thought you were using your code, hence the post it part =) But yea, that works.
-
If you want help to fix it, I would suggest posting the code and highling or make a notation where line 31 is.
-
Have you tried it? I am not sure, but I would say no. The best way to find out is just try it and see what happens. If it does work, sure why not. But why would you need to dynamically define what a class extends?
-
Right, did you try the above? It is not very good practice to do your own time formatting when you have so many available resources... <?php $dbcnx = mysql_connect("localhost", "88888", "888888"); mysql_select_db("888888"); $result = @mysql_query("SELECT postTXT, postID, postTITLE, posterEMAIL, DATE_FORMAT(postTIME, '%h:%i %p | %m/%d/%Y') as postTIME FROM comtbl ORDER BY postID DESC"); if (!$result) { echo("<b>Error performing query: " . mysql_error() . "</b>"); exit(); } while ($row = mysql_fetch_array($result) ) { $msgTxt = $row["postTXT"]; $msgId = $row["postID"]; $SigName = $row["posterNAME"]; $SigDate = $row["postTIME"]; $msgTitle = $row["postTITLE"]; $url = $row["posterEMAIL"]; /* All of this is useless code now, no need for it. $yr = substr($SigDate, 2, 2); $mo = substr($SigDate, 4, 2); $da = substr($SigDate, 6, 2); $hr = substr($SigDate, 8, 2); $min = substr($SigDate, 10, 2); if ($hr > "11") { $x = "12"; $timetype = "PM"; $hr = $hr - 12; }else{ $timetype = "AM"; }*/ if (!$url) { $url = "#"; }else{ $stat = $url; $url = "mailto:" . $url . ""; } echo("<p><b>$msgTitle</b> $msgTxt<br><div align=right> $SigDate | $msgId, <a href='$url'>$SigName</a></div></p>"); } ?> Is that not a ton simpler...? And, if my SQL is bad, all you have to do is follow the errors to correct it, but I think it should be good, the only thing I wonder about is the " | " symol, not sure if that is kosher. Give it a try and see what happens.
-
You would use the filemtime function and most likely put the results in an array using that as a key, then do a ksort on the array and then a foreach to iterate through and print the images back... <?php $featured_dir = 'images/'; $dir = 'thumbs/'; $scan = scandir($dir); for ($i = 0; $i<count($scan); $i++) { if ($scan[$i] != '.' && $scan[$i] != '..') { if (strpos($scan[$i], '.jpg') !== false) { $fileAr[filemtime($dir . $scan[$i]]['dir'] = $dir; $fileAr[filemtime($dir . $scan[$i]]['filename'] = $scan[$i]; $fileAr[filemtime($dir . $scan[$i]]['path'] = $dir . $scan[$i]; } } } ksort($fileAr); foreach ($fileAr as $files) { echo ' <div id="imageList"> <ul><a href="' . $featured_dir . $files['filename'] . '"> <img src="' . $files['path'] . '" alt="' . $files['filename'] . '" /> </a>'; echo '' . $files['filename'] .''; echo '</div>'; } ?> If you want the oldest first, krsort instead. Untested, but I think the logic should work.
-
Why not use the date function to get the time displayed how you want it, instead of doing your weird logic? If the timestamp, isn't really a timestamp, you can do strtotime or in your mysql query use the DATE_FORMAT function. (Preferably the DATE_FUNCTION) This: $result = @mysql_query("SELECT * FROM comtbl ORDER BY postID DESC"); Becomes: $result = mysql_query("SELECT postTXT, postID, postTITLE, posterEMAIL, DATE_FORMAT(postTIME, '%h:%i %p | %m/%d/%Y') as postTIME FROM comtbl ORDER BY postID DESC") or die(mysql_error()); I am unsure if that is proper syntax, but yea that would reduce your PHP code just by getting the date out of the DB in the correct format =)
-
Multi Dimmensional array: <?php $towns = array("london" => array("jim" => array("city" => "testCity", "state" => "testState", "dave" => array("city" => "testCityda", "state" => "testStateda")), "Birmingham" => array("james" => array("city" => "testCityJa", "state" => "testStateJa"))); foreach ($towns as $town => $occupants) { echo "Town: " . $town . "<br />"; if (is_array($occupants)) { foreach ($occupants as $occupant => $info) { echo "Occupant " . $occupant . "<br />"; if (is_array($info)) { echo " City" . $info['city'] . "<br />"; echo " State" . $info['state'] . "<br /><br />"; } } } } ?> Should display them all. Now this is just an example for you to see/understand how it works. When you would get it from the DB, you could create a new array $towns where the index is $returnDBValue['town'] so $towns[$returnDBValue['town']][$returnDBValue['name']] = $returnDBValue which would make it a multi dimmensional array which is indexed first by town then by name. Now you may not have to go that far to do what you want, but that is the basic gist. The simpler/easier approach is GingerRobot's example, that is how you should do it. My example was just to help you understand the power of arrays =)
-
Basically $size is not an index in the array. You can avoid this by checking that index of the array with isset before trying to use that: <?php for($size = 0; $size <= count($tab_loc); $size++){ if($this->id == $size && isset($tab_loc[$size])){ $tab_list .= '<div class="visit_tab_outer"> <div class="visit_tab_inner"> <a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a> </div> </div>'; continue; } if (isset(isset($tab_loc[$size])) { $tab_list .= '<div class="tab_outer"> <div class="tab_inner"> <a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a> // line 41 </div> </div>'; } } echo $tab_list; } ?> That way it is only echoed out if that size is in the array.
-
Since you did not respond with the solution you found, here is the solution for anyone else with the same problem: You would use the (double) cast IE: <?php $firstDouble = (double)"4734.1400"; $secondDouble = 4734.14; if ($firstDouble == $secondDouble) { echo 'Yep'; }else { echo 'Nope'; } ?> I am not sure if the .1400 will cause it to not be correct, but if so, you can use number_format to just make it 2 decimal places.
-
FREE php availability/reservations calendar
premiso replied to coolphpdude's topic in PHP Coding Help
http://www.google.com/search?hl=en&q=php+events+calendar&btnG=Google+Search&aq=f&oq= Events calendar is what you will be looking for. There should be plenty of free already built scripts, it is just a matter of finding one that has the functionality you want. -
You can create your own using glob and unlink Shouldn't be to hard, and I bet inside the glob user comments you can find a script howto in there.
-
[SOLVED] why i can not see textbox what can i do?
premiso replied to bakigkgz's topic in PHP Coding Help
What "textbox" are you referring to? "hello"? Please specify. Edit: Please take the advice that Ginger gave you here first before asking the same question in a different way: http://www.phpfreaks.com/forums/index.php/topic,233160.msg1082163.html#msg1082163 -
Well I do not see the "more info" but... $returned = get_path($parent); foreach ($returned as $path) { $bc[] = $path[1]; } $bc = implide(" -> ", $bc); echo $bc; Will at least do the home and about us.
-
I would suggest sticking to 1 set of quotes and staying that way, you go in and out different times with different quotes. <?php $content .= '<td valign="bottom"><br><a href="admin.php?p=temp_models&id='.$info['tempmodelid'].'"><strong>Delete this application</strong></a><br>'.$info['name'].'<br><a href="mailto:'.$info['email'].'?subject=Jimmys Promotions and Modelling Agency Model Application">'.$info['email'].'</a><br><a href=images/applications/'.$info['picname'].' rel="lightbox"><img src="images/applications/'.$info['picname'].'" alt="'.$info['name'].'" width="300" /><a/><br><br></td>'; ?> You will also notice I put ' around the array indexes to avoid the "undefined constant" notice.
-
Parse error</b>: syntax error, unexpected T_PUBLIC in
premiso replied to anavas's topic in PHP Coding Help
I voted "3", not sure what that means. But yea PS (Show us the actual code as Brian said.) -
[SOLVED] PHP paths as variable arguments?? (like wikipedia?)
premiso replied to thepip3r's topic in PHP Coding Help
mod_rewrite is what you want to look into. -
mmm not really... <?php // load the file that contain the ads $adfile = "ads.txt"; $ads = array(); // one line per ad $fh = fopen($adfile, "r"); while(!feof($fh)) { $line = fgets($fh, 10240); $line = trim($line); if($line != "") { $ads[] = $line; } } // randomly pick an ad $num = count($ads); $idx = array(); while (count($idx) != 10) { $rand = rand(0, $num-1); if (!in_array($rand, $idx)) $idx[] = $rand; } foreach ($idx as $id) echo $ads[$id] . "<br />"; ?> Something like that would work, this assumes you have more than 10 items in that list, and with the random, the scripts execute time will vary. EDIT: The difference between this one and Brians, is that the one I posted should guarantee 10 unique ads, Brian's may not. But yea, whichever one better suits your needs.
-
There you go. Even I missed the missing ) after the !empty portion. As stated, it makes a ton less confusing omitting them =)
-
if($FormError == "1" && $_REQUEST['Process'] == "AddCat") { ?> <tr> <td colspan="2" align="center" bgcolor="#222222" style="font-family: Tahoma, Verdana, sans-serIf; font-size:16px; color:#f30">*<p>missing information! category name required...</p></td> </tr> Should solve it.
-
<%If Request("Process")="AddCat" and FormError=1 Then%> Looks like it is an ASP line. That is not valid php.
-
It is probably just the phpDesigner. That code looks valid to me. It most likely does not like everything being on oneline. But I would go with Flyhoney's if, since the simple fact that you do not need the extra parans and they just make it more confusing.
-
Maybe it is a bug in Thunderbird? I would check that version and see if there are any bug reports about it. Also, I think your $headers should be seperated by a "\r\n", you have "\n" on the from, but it should be "\r\n" and you should have it on each of them.
-
Chances are it works, but his version of PHP is different from yours. If your friend created it I would ask them this question, as they would know the system in and out. It could literally take me, or anyone else on here hours just to find this bug in this code since we do not know it, and even then we are not guaranteed that it is the problem. Probably not the answer you wanted, but yea. That is the realistic point of view.