premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[SOLVED] PHP Code Write/Create File Wont Write/ Create
premiso replied to jnerotrix's topic in PHP Coding Help
Are you sure the file is writeable (chmod 0775) ? Chances are you do not have the permission to open the file. I would remove the die and see what the fatal error shows up. -
We need a portion of the file to see what we are dealing with and help you. And any code you have already done helps out too.
-
http://corz.org/blog/inc/cbparser.php Why re-invent the wheel? As far as the images, I am not sure how you would do that other than just looping through all the img tags first and checking it that way, if it is invalid width/height than let them know and have that commented out?
-
Awesome thanks man.
-
<?php $time1 = strtotime('10/27/2008'); $time2 = strtotime('12/6/2008'); $newtime = time(); if ($time1 < $newtime && $time2 > $newtime) { include('script.php'); } ?>
-
[SOLVED] Figuring out whether each part of a query is not matching
premiso replied to limitphp's topic in PHP Coding Help
<?php $queryCheckUser = "SELECT email, secretAnswer, fname, lname FROM user WHERE username = '$username' LIMIT 1"; $resultCheckUser = mysql_query($queryCheckUser) or die (mysql_error()); $rowCountCheckUser=mysql_num_rows($resultCheckUser); if ($rowCountCheckUser > 0) { $row = mysql_fetch_assoc($resultCheckUser); if ($row['secretAnswer'] != $secretAnswer) { $message = "Your secret answer is wrong."; }elseif ($row['email'] != $email) { $message = "email is invalid."; }// etc.... }else { $message = "Username does not exist."; } ?> Let me know if you need more clarification. -
<?php $string = '<table border="0" cellspacing="0" cellpadding="2" class="ysptblclbg4" width="100%" style="border-collapse: collapse" bordercolor="#111111"><tr><td class="yspdetailttl" valign="bottom" height="12"> Sat, Dec 6</td></tr> <tr><td> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <tr> <td nowrap> San Francisco <span class=\'yspscores\'><a href="javascript:void(window.open(\'http://cosmos.bcst.yahoo.com/up/collegetest/?cl=10487697\',\'playerWindow\',\'width=793,height=608,scrollbars=no\'));" ><img border="0" src="http://l.yimg.com/a/i/us/sp/ed/ic/free_video_box.gif" width="16" height="12" alt="Free Video"></a> </span> vs. Long Beach St. <span class=\'yspscores\'></span> - Men\'s Basketball </td> <td nowrap> </td> <td width="100%" nowrap class="yspscores"> 10:00 pm EST </td> </tr> </table></td></tr> </table><table border="0" cellspacing="0" cellpadding="2" class="ysptblclbg4" width="100%" style="border-collapse: collapse" bordercolor="#111111"><tr><td class="yspdetailttl" valign="bottom" height="12"> Mon, Dec 8</td></tr> <tr><td> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <tr> <td nowrap> Lehigh <span class=\'yspscores\'><a href="javascript:void(window.open(\'http://cosmos.bcst.yahoo.com/up/collegetest/?cl=10603183\',\'playerWindow\',\'width=793,height=608,scrollbars=no\'));" ><img border="0" src="http://l.yimg.com/a/i/us/sp/ed/ic/pay_video_box.gif" width="16" height="12" alt="Subscription Video"></a> </span> vs. Albany <span class=\'yspscores\'></span> - Men\'s Basketball </td> <td nowrap> </td> <td width="100%" nowrap class="yspscores"> 6:30 pm EST </td> </tr> </table></td></tr> </table> </table>'; preg_match_all("~<td class=\"yspdetailttl\" valign=\"bottom\" height=\"12\">(.*)</td>~",$string, $matches); foreach ($matches[1] as $match) { $dates[] = $match; } //print_r($dates); preg_match_all("~<td nowrap> (.*)</td>~",$string, $matches); foreach ($matches[1] as $match) { $vs[] = " " . $match; } //print_r($vs); preg_match_all("~<td width=\"100%\" nowrap class=\"yspscores\">(.*)</td>~",$string, $matches); foreach ($matches[1] as $match) { $time[] = $match; } //print_r($time); $count = count($dates); for ($i=0; $i<$count; $i++) { echo $date[$i] . "<br />" . $vs[$i] . "\t\t" . $time[$i] . "<br /><br />"; } ?> I will let you figure out the displaying of them. Not sure if that is the most efficient way, but it works.
-
[SOLVED] Figuring out whether each part of a query is not matching
premiso replied to limitphp's topic in PHP Coding Help
Yea, I was just enlightening you on why it would be done that way. Let me know if my explanation on how to do it helps you out or not, I can elaborate if you need me to. -
I think this would also work too: <form method="post" action="unsub.php" name="unsub" id="unsub"> <div style="text-align: center;"> <span style="font-weight: bold;">Email Address </span> <input size="35" name="EmailAddress"> <br> </div> <img src="Images/bg_button.gif" onClick="document.unsub.submit();" /> </form> Not to say either is better, but yea. With the onClick function anything is possible. The only downside is that this version you need to have javascript enabled vs Brian's you do not.
-
So I am learning a bit of regex using preg, and I have this code I am trying to figure out how to parse more efficiently and for reasons I cannot find the definition to so I can fix it thus I am asking here. <?php $string = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="400" height="300"><param name="src" value="../bcms_uploads/myVideo.flv" /><param name="width" value="400" /><param name="height" value="300" /><embed type="application/x-shockwave-flash" src="../bcms_uploads/myVideo.flv" width="400" height="300"></embed></object>'; $html=preg_replace('~<object.*src="(.*)["](.*)</object>~','<a href="$1" style="display:block;width:400px;height:300px" id="player">df</a>',$string); echo $html . " HTMLs"; ?> The printed code is: <a href="../bcms_uploads/myVideo.flv" width="400" height="300" style="display:block;width:400px;height:300px" id="player">df</a> HTMLs What it seems to be doing is finding the last " before it starts finding other stuff, I am not sure why it displays the width and height and not other information, but how do I get it to just stop after the first quote instead of finding some others first then stopping? I hope what I said made sense and that it is not too hard of a question to answer. I know there are other ways to achieve the results, but I would just like to know why this is happening and if there is a way to do it with the above code. Note: width="400" height="300" Shouldn't be in the end result.
-
Post an example of the html you are parsing ( a short snippet) and I will attempt to help you. (I do not like going to external urls and finding the area myself, just plain too lazy to do that). And also post how you want it displayed.
-
Nested Loop for displaying agenda/calendar info
premiso replied to mishasoni's topic in PHP Coding Help
Post some code. Chances are it is your loop that is the problem, move the day definition so it is not printing every time the loop is ran, only when it is needed to be printed. -
[SOLVED] Figuring out whether each part of a query is not matching
premiso replied to limitphp's topic in PHP Coding Help
I wouldnt give them the reason. This helps hackers etc figure out more stuff. But to answer the question, pull out all the date where the username is equal, then run through the array returned and check the values against those and populate $message with the appropriate error. -
Very possible, just md5 the security answer. And when they try to use you just have to check against the md5 hash. I usually handle it on the form as a non-password type. Cause the password type is just to prevent people looking over your shoulder from seeing. Just remember it will case sensitive if you use the md5 hash.
-
In order to do that I believe you have to delete the table then recreate it and re-populate the data. The id should not matter really, if you are a person who likes it to be in order, I would suggest you get used to it, cause it is not probable if you have 1,000 records and one gets deleted to go through and re-order every single record just to make it 1-1000. Imagine if you had 10,000 records and you deleted 100 records a day, wow thats a load on the server.
-
Your for loop only goes twice, so the year 3 is impossible to print out right now. <?php function work_out_yr_status($started,$duration) { $started = strtotime($started); $start_month = date("n",$started); $start_year = date("Y",$started); $current_month = date("n"); $current_year = date("Y"); $yr_duration = $duration; $end_month = 6; $yr_difference = $current_year - $start_year; for($i = 0;$i <= $yr_duration;$i++) { if($yr_difference > $yr_duration && $current_month > $end_month) { echo "Course completed in "; echo $start_year + $yr_duration; } elseif($yr_difference == $i && $current_month >= $start_month)//first academic year and before new year { echo "in progress"; } elseif($yr_difference == $i && $current_month <= $end_month) { echo "completed"; }else { echo "not started"; } } } ?> I think that is what you are looking for?
-
You can always use file_get_contents then use a preg_replace that finds the title tags and replaces them with what you want then echo the html file to the screen. Other than that you have to manually edit each file. Fun stuff.
-
I think (\s$search\s) is sort of what you are looking for...I am not exactly sure what data.txt contains or where $search is populated, but hopefully that will help you get it figured out
-
I got really bored and decided to shorten the regex =) <?php $string = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="400" height="300"><param name="src" value="../bcms_uploads/myVideo.flv" /><param name="width" value="400" /><param name="height" value="300" /><embed type="application/x-shockwave-flash" src="../bcms_uploads/myVideo.flv" width="400" height="300"></embed></object>'; $html=preg_replace('~<object.*value="(.*)(\.\w{3})(" />)(.*)</object>~','<a href="$1$2" style="display:block;width:400px;height:300px" id="player"></a>',$string); echo $html . " HTML"; ?> Found another way that works which may be more dynamic (not requiring a param of src) $html=preg_replace('~<object.*src="(.*)(\.\w{3})(")(.*)</object>~','<a href="$1$2" style="display:block;width:400px;height:300px" id="player">df</a>',$string); A bit shorter and should get you desired results too =) (I wanted to learn a bit more about regex so yea)
-
If you dont have curl a slower function is file_get_contents That tends to work, just about 1-2 seconds slower, but the call is much easier <?php $html = file_get_contents('http://www.example.com'); //now all the html is the $html ?> =)
-
Acting like a 2 yearold and throwing a tantrum will not help your cause. I challenge you to go somewhere else and find even nearly the same support as you find here. while($row = mysql_fetch_array($result)){ $match = $match+1; } if($error >= "1"){ echo"<table width='700'><tr><td><br><br><br>The information you have provided does not match our database of CBC Magazine paid subscribers.<br><br>If you paid to receive the CBC® Magazine regularly and should be in our database, please call Holly at 216.831.9557 or email her at ****, and she will process your $35 registration manually.<br><br>If you did not pay to receive the magazine, you can click back to continue your registration for Amplify at the $45 non-subscriber rate.<br><br>If your event registration is not processed and confirmed within 48 hours, A CDG representative will contact you. Thank you.</td></tr></table>"; } Why even bother doing a while? Why not use mysql_num_rows $rows = mysql_num_rows($result); if($rows > 0){ echo"<table width='700'><tr><td><br><br><br>The information you have provided does not match our database of CBC Magazine paid subscribers.<br><br>If you paid to receive the CBC® Magazine regularly and should be in our database, please call Holly at 216.831.9557 or email her at ****, and she will process your $35 registration manually.<br><br>If you did not pay to receive the magazine, you can click back to continue your registration for Amplify at the $45 non-subscriber rate.<br><br>If your event registration is not processed and confirmed within 48 hours, A CDG representative will contact you. Thank you.</td></tr></table>"; } And what you expect people to be waiting at your becking needs, it was not even an hour since you posted the problem then you threw a "tantrum" and started bashing the forums.
-
SELECT *, DATE_FORMAT(blog_item_datetime, '%M %Y') as month_year FROM blog_items WHERE blog_category = 1 ORDER by blog_item_datetime DESC I think that should work.
-
$string = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="400" height="300"><param name="src" value="../bcms_uploads/myVideo.flv" /><param name="width" value="400" /><param name="height" value="300" /><embed type="application/x-shockwave-flash" src="../bcms_uploads/myVideo.flv" width="400" height="300"></embed></object>'; $html=preg_replace('~<object\s[^>]*/swflash.cab[^>]*><param name="src"\s[^>]*value=("[^"]*")(??!</object>).)*</object>~is','<a href=$1 style="display:block;width:400px;height:300px" id="player"></a>',$string); Should get you the correct results.
-
$sql = "SELECT timest FROM tbl_name"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) echo date("m/d/Y", $row['timest']); It's all about the date function.