Jump to content

maxudaskin

Members
  • Posts

    628
  • Joined

  • Last visited

Everything posted by maxudaskin

  1. Uhh.. wouldn't it be better to do this? <?php if(!empty($url)) { /* add your news*/ } else { /*add your news as null*/ } ?>
  2. I have an online test that uses radio groups. I have an answer key as an array and I wanted to use arrays to mark it... can you either tell me a better way to do it or help me complete this simple part of it... <?php $test_key = array("c","b","a","d","d","c","c","b","d","a"); $given_ans = array($_POST['q1'],$_POST['q2'],$_POST['q3'],$_POST['q4'],$_POST['q5'],$_POST['q6'],$_POST['q7'],$_POST['q8'],$_POST['q9'],$_POST['q10']); ?>
  3. Well... I feel dumb... I used it like this: substr(string,start_char,end_char) instead of substr(string,star_char,num_of_chars)
  4. I have a (portion of) a script below, the input would be, lets say 20082407. It echos 2008.24. and not the last 2 numbers... any ideas? <?php $start = substr($row['start'],0,4) . "." . substr($row['start'],5,6) . "." . substr($row['start'],7,; echo $start; ?>
  5. <?php $string = isset($isset) ? "Yes" : "No"; echo $string; ?> Outputs No <?php $isset = 1; $string = isset($isset) ? "Yes" : "No"; echo $string; ?> Outputs Yes
  6. Bump... I really need to fix this issue and I am out of Ideas...
  7. Array( [0] Postcard [0] 2.99 [1] Book [0] 7.99 [2] Compact Disc [0] 12.99 )
  8. Because the way it is written and encoded. I believe that word is just like an RTF.
  9. if you want it to cut it off at about x characters but leave the last word there you will have to use a combo of strlen/substr and preg_match/preg_match_all
  10. It is still being an SOB.
  11. substr <?php $file = "hello.txt"; $fp = fopen($file, "r"); while(!feof($fp)) { $data = fgets($fp, 1024); echo substr($data,0,150); // Echos first 150 characters echo "<br />"; } fclose($fp); ?>
  12. This script is one of my older scripts... which means that I didn't comment it or indent it... or use the more complex functions either... lol.
  13. Yes there is, it is called doing this: <?php echo "<?php echo \"Hello World!\" ?>"; ?>
  14. And it says Pirep Denied.
  15. I tell it to change a 1 to a 2 but it ignores the command, if I input deny, instead of changing it to 2, it changes it to 0. <?php if(!$logged_in){ echo 'You are not logged in'; }else{ if($_SESSION['type'] == 1){ $action = $_GET['action']; $pirep = $_GET['pirep']; $admin = 'OOM'.$_SESSION['username'].' '.$_SESSION['name']; $get_user_info = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pid = mysql_fetch_array($get_user_info); $usersql = mysql_query("SELECT * FROM users WHERE pid = '{$pid}'"); $user_array = mysql_fetch_array($usersql); $user = $user_array['fname']." ".$user_array['lname']; $rank = $user_array['rank']; $date = date("Y-m-d H:i:s"); if(!empty($action) || !empty($pirep)){ if($action == 'accept'){ mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '0' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo 'PIREP Accepted.'; echo $user_array['email']; $to = $user_array['email']; $subject = "Flight Report Accepted"; $pirep_sql = mysql_query("SELECT * FROM pireps WHERE pirepid = '{$pirep}'"); $pirep_info = mysql_fetch_array($pirep_sql); $message = $rank ." ". $user .", The recent flight report that you have filed has been accepted. Your hours have been updated accordingly. The report was accepted by ".$pirep_info['acceptedby']." on ".$pirep_info['accepteddatetime']; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers) or die ("<br /><br /><div class=\"status_message status_error\">ERROR: Email not sent to user.</div>"); }elseif($action == 'deny'){ mysql_query("UPDATE `zoomdb`.`pireps` SET `type` = '2' AND `approvedby` = '$admin' AND `approvedatetime` = '$date' WHERE `pireps`.`pirepid` ='{$pirep}' LIMIT 1") or die('ERROR: Application not accepted due to internal error; '.mysql_error()); echo "Pirep Denied."; }else{ echo 'You have specified an unknown action.'; }} }else{ echo 'You are not a staff member.'; } } ?> Inputs: action=deny&pirep=141
  16. I forgot about the catch... It is in a database as a post... Hey everyone, I found this cool site at http://www.coolsite.net and I thought you'd like to take a look! Some User
  17. How could I turn some text formatted like this: http://www.someurl.com into <.a href="http://www.someurl.com">http://www.someurl.com</.a> Please ignore the periods, they are there to prevent the a href part from turning invisible.
  18. I hate dislike syntax errors. Error: Cannot view events. MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' at line 1 Database: Code: <?php function selectDate(){ if(!empty ($_GET['month'])){ $month = $_GET['month']; }else{ $month = gmdate("n"); } echo "<form id=\"seldate\" name=\"seldate\" method=\"GET\" action=\"events.php\">"; echo "<input type=\"hidden\" name=\"p\" value=\"cal\" />"; echo "<input type=\"hidden\" name=\"do\" value=\"view\" />"; echo "<select name=\"month\">"; if($month == 1){ echo "<option selected=\"selected\" value=\"1\">January</option>"; }else{ echo "<option value=\"1\">January</option>"; } if($month == 2){ echo "<option selected=\"selected\" value=\"2\">February</option>"; }else{ echo "<option value=\"2\">February</option>"; } if($month == 3){ echo "<option selected=\"selected\" value=\"3\">March</option>"; }else{ echo "<option value=\"3\">March</option>"; } if($month == 4){ echo "<option selected=\"selected\" value=\"4\">April</option>"; }else{ echo "<option value=\"4\">April</option>"; } if($month == 5){ echo "<option selected=\"selected\" value=\"5\">May</option>"; }else{ echo "<option value=\"5\">May</option>"; } if($month == 6){ echo "<option selected=\"selected\" value=\"6\">June</option>"; }else{ echo "<option value=\"6\">June</option>"; } if($month == 7){ echo "<option selected=\"selected\" value=\"7\">July</option>"; }else{ echo "<option value=\"7\">July</option>"; } if($month == { echo "<option selected=\"selected\" value=\"8\">August</option>"; }else{ echo "<option value=\"8\">August</option>"; } if($month == 9){ echo "<option selected=\"selected\" value=\"9\">September</option>"; }else{ echo "<option value=\"9\">September</option>"; } if($month == 10){ echo "<option selected=\"selected\" value=\"10\">October</option>"; }else{ echo "<option value=\"10\">October</option>"; } if($month == 11){ echo "<option selected=\"selected\" value=\"11\">November</option>"; }else{ echo "<option value=\"11\">November</option>"; } if($month == 12){ echo "<option selected=\"selected\" value=\"12\">December</option>"; }else{ echo "<option value=\"12\">December</option>"; } echo "</select>"; echo "<select name=\"year\">"; $i = 2008; $o = gmdate("Y") + 10; while($i <= $o){ if($_GET['year'] == $i){ echo "<option selected=\"selected\" value=\"" . $i . "\">" . $i . "</option>"; }else{ echo "<option value=\"" . $i . "\">" . $i . "</option>"; } $i ++; } echo "</select>"; echo "<input type=\"submit\" name=\"Submit\" value=\"Change Month\" />"; echo "</form>"; } if(!$logged_in){ die("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\"><tr><td><div align=\"center\" class=\"status_message status_error\">You cannot view this page as you are not logged in.</div></td></tr></table>"); } if($_SESSION['type'] == 0){ die("<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"5\"><tr><td><div align=\"center\" class=\"status_message status_error\">You cannot view this page as you are not an administrator.</div></td></tr></table>"); } /* Define Dates */ $today = gmdate("Y/m/d"); // Set today's date | 2008/05/13 $today_unix = gmdate("Ymd"); // Set today's date | 20080513 $today_day = gmdate("d"); // Set today's day | 13 $today_month = gmdate("m"); // Set today's month | 05 $today_year = gmdate("Y"); // Set today's year | 2008 if(empty($_GET['month'])){ $month = $today_month; }else{ $month = $_GET['month']; } if(empty($_GET['year'])){ $year = $today_year; }else{ $year = $_GET['year']; } $days = cal_days_in_month(CAL_GREGORIAN, $month, $year); selectDate(); echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td width=\"3%\" style=\"border-top:solid #FFFFFF 1px;\" height=\"20\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"> </td>"; echo "<td width=\"32%\" colspan=\"2\" style=\"border-top:solid #FFFFFF 1px;\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"><span class=\"white_text\">Date</span></td>"; echo "<td width=\"65%\" style=\"border-top:solid #FFFFFF 1px;\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"><span class=\"white_text\">Event(s)</span></td>"; echo "</tr>"; $i = 1; while($i < $days + 1){ // Problem Line ///////////////////////////////////////////////////////////////////////////////////////// $query = mysql_query("SELECT * FROM events WHERE month = '$month' AND year = '$year' AND day '$i'") or die("Cannot view events. MySQL Error: " . mysql_error()); ////////////////////////////////////////////////////////////////////////////////////////////////////////// $date = $year . "/" . $month . "/" . $i; $day = date("l", strtotime($date)); echo "<tr style=\"height:18px; vertical-align:middle; background-color:#FFFFFF; padding-left:10px;\" onMouseOver=\"this.style.backgroundColor='#EFF4FB'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">"; echo "<td height=\"30\"> </td>"; echo "<td>" . $day . "</td>"; echo "<td>" . $i . "</td>"; echo "<td>"; if(mysql_num_rows($query) > 0){ while($row = mysql_fetch_array($query)){ echo "<a href=\"#\"><div>" . $row['name'] . "</div></a>"; } }else{ echo "No Events."; } echo "</td>"; echo "</tr>"; $i++; } echo "</table>"; selectDate(); ?>
  19. I have this page: http://www.virtualzoom.net/admin/events.php Error: Warning: mktime() expects parameter 5 to be long, string given in /home/.grable/vzoom/virtualzoom.net/admin/events.php on line 267 Code: <?php /* Define Dates */ $today = gmdate("Y/m/d"); // Set today's date | 2008/05/13 $today_unix = gmdate("Ymd"); // Set today's date | 20080513 $today_day = gmdate("d"); // Set today's day | 13 $today_month = gmdate("m"); // Set today's month | 05 $today_year = gmdate("Y"); // Set today's year | 2008 function dayofWeek($day,$month,$year){ global $day; $utime = mktime (1,1,1,$month,$day,$year); // Line 267 $day = date('w',$utime); if($day == 0){ $day = "Sunday"; }elseif($day == 1){ $day = "Monday"; }elseif($day == 2){ $day = "Tuesday"; }elseif($day == 3){ $day = "Wednesday"; }elseif($day == 4){ $day = "Thursday"; }elseif($day == 5){ $day = "Friday"; }elseif($day == 6){ $day = "Saturday"; } } if(empty($_GET['month'])){ $month = $today_month; }else{ $month = $_GET['month']; } if(empty($_GET['year'])){ $year = $today_year; }else{ $year = $_GET['year']; } $days = cal_days_in_month(CAL_GREGORIAN, $month, $year); echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr>"; echo "<td width=\"3%\" style=\"border-top:solid #FFFFFF 1px;\" height=\"20\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"> </td>"; echo "<td width=\"32%\" style=\"border-top:solid #FFFFFF 1px;\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"><span class=\"white_text\">Date</span></td>"; echo "<td width=\"65%\" style=\"border-top:solid #FFFFFF 1px;\" align=\"center\" valign=\"middle\" bgcolor=\"#333355\"><span class=\"white_text\">Event(s)</span></td>"; echo "</tr>"; $i = 1; while($i < $days + 1){ dayofWeek($i,$today_month,$today_year); echo "<tr>"; echo "<td height=\"20\"> </td>"; echo "<td>" . $i . $day . "</td>"; echo "<td>No Event</td>"; echo "</tr>"; $i++; } echo "</table>"; ?> Any Ideas?
  20. How does that work?
  21. <?php $year = 2007; while($year < 2020){ $year ++; $month = 0; while($month <= 12){ $month ++; $i = 1; $num = cal_days_in_month(CAL_GREGORIAN, $month, $year); while($i < $num){ echo $month . "-" . $year . " " . $i . "<br />"; $i ++; } } } ?> Output: http://www.virtualzoom.net/Untitled-1.php It gives an error for the 31st of December... Warning: cal_days_in_month() [function.cal-days-in-month]: invalid date. in /home/.grable/vzoom/virtualzoom.net/Untitled-1.php on line 9
  22. Try <?php mysql_query("INSERT INTO catalog (`column1``column2`,`column3`,`column4`,`column5`,`column6,`column7`,`column8,`column9`,`column10`,`column11`,`column12`,`column13`,`column14`,`column15`,`column16`,`column17`,`column17`)VALUES('','test','test','test','test','test','test','Hard','test','New','$test','$test','$test','test','test','test','Yes','Yes')") ?> But replace column1 or whatever with the column name.
  23. You need to put all the columns in first... Eg: INSERT INTO table (column1,column2,column3) VALUES ('$testvar','test','test')
  24. Ok, the key count is 1, but it does not echo the image or print the result... <?php $text = $posts['text']; $message = preg_replace($find,$rplc,$text); preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); $imagekeys = array_keys($url[1]); for($i=0;$i<count($imagekeys);$i++){ print_r($url[$i][0]); echo "<img src\"" . $imagevals[$i] . "\" height=\"" . $height . "\" width=\"" . $width . "\" alt=\"We Cannot Find This Specified Image\" /><br />"; } $message = str_replace($smilies,$locations,$message); echo nl2br($message); ?>
  25. Any Idea why the following code brings up Warning: array_values() [function.array-values]: The argument should be an array in /home/.grable/vzoom/virtualzoom.net/comm/forum.php on line 566 We Cannot Find This Specified Image Input [img=http://www.virtualzoom.net/screenshots/jan-screen-lg.jpg] <?php $text = $posts['text']; $message = preg_replace($find,$rplc,$text); preg_match_all('/\[img\](.+?)\[\/img\]/', $text, $url); $imagekeys = array_keys($url[1]); for($i=0;$i<count($imagekeys);$i++){ $imagevals = array_values($url[$i][0]);// Line 566 echo "<img src\"" . $imagevals[$i] . "\" height=\"" . $height . "\" width=\"" . $width . "\" alt=\"We Cannot Find This Specified Image\" /><br />"; } $message = str_replace($smilies,$locations,$message); echo nl2br($message); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.