Jump to content

kool_samule

Members
  • Posts

    169
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

kool_samule's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. fantasic. thanks for the help
  2. Thanks for the reply, is there anything out there that could jump to a column in a line?
  3. Hi Chaps, I have been given an invalid XML file, which when run through 3rd party software, gives me the line & column numbers of the error. Instead of opening the file and manually searching for the line/column numbers (which can take a whie, as the file is vast!), is there a way to parse the XML file and locate the error, using the line/column numbers? And maybe display/highlight the error in a browser? e.g.: 1: open bad-file.xml 2: read bad-file.xml 3. go-to line 50 4. go-to column 3620 5. open in browser 6. highlight error Cheers S
  4. OK my bad, thanks for the heads up. Cheers!
  5. Yeah, is this a bug, in issue with 5.2.10? Any idea of how to work around this? It seems to be a problem when the DAY you are querying against happens to be the first day of the given MONTH. I've just tried it with "October 2012 fourth Monday" and it returned: 2012-10-29, when it should be 2012-10-22..
  6. Hi Chaps, I have a problem trying to find out the fourth Thursday of a Month of a Year, for example November. date_default_timezone_set('Europe/London'); echo strtotime("November 2012 fourth thursday")."</br>"; // returns 1354147200 SHOULD BE 1353542400 echo date('Y-m-d', 1354147200)."</br>"; // returns 2012-11-29 echo date('Y-m-d', 1353542400)."</br>"; // returns 2012-11-22 So the problem is with the strotime calculation, I'm using PHP Version 5.2.10 on Windows/Apache. Anyone know how to solve this or alternatives?
  7. Thanks guys, Advice is noted..I'll crack on and hopefully get it sorted. Cheers for the help.
  8. Hi Chaps, Apologies if this topic should be in MySQL...I wasn't sure. I'm trying to create a MS Outlook-style Appointment application with Recurrence for a PHP calendar. I've got all the same options that Outlook gives, e.g.: Daily - every DAY, or every WEEKDAY Weekly every X WEEK(S) on X DAYS Monthly - on DAY of every X month or Nth DAY of every X MONTH(s) Yearly - recur every X YEAR(S) on DAY of MONTH or Nth DAY of every X MONTH(s) My question is what is the best way to store the recursive appointment information in MySQL Database (Columns, etc), so I can then use a PHP algorithm to calculate whether an appointment is within a calendar view, or if reminders need to be sent. Any advice will be a great help.
  9. Yeah, clicked around to trigger an error, but nothing happened..got me baffled.
  10. Hi, Yeah, I've already done that, should have mentioned. FireBug > Console > Debug Info / FireBug > Script > Breakpoints / = Nothing ....?
  11. Hi Chaps, Scratching my head with this one, hopefully someone can tell me where I'm going wrong...my Javascript/jQuery skills are low. Overview: I have multiple jQuery 'connectedWith' sortable lists in a form, when groupItems are moved/connected, an updated SUM of two amounts is displayed, using the Net/Gross Calculation function. The order of each group is added to the group array, using the groupItemOrder# functions. Upon submitting the form, the correct group/groupItemOrder is displayed (for this demo, I'll add the MySQL scripts afterwards). I have a problem the two functions, Net/Gross Calculation & groupItemOrder#, won't work on the same page. They both work if the other is not 'active', so to speak. Function: Net/Gross Calculation function: /* START OF Net/Gross Calculation function - used to calculate the Net/Gross of each group - won't work if the groupItemOrder# on-the-fly array updater are active */ $(document).ready( function () { $('ul.connectedSortable').sortable({ update: function (ser) { $(".connectedSortable").each(function (i) { var total_net = 0; var total_gross = 0; $(this).find(".net").each(function () { total_net += parseInt($(this).text()); }); $(this).find(".gross").each(function () { total_gross += parseInt($(this).text()); }); $("div#total_net" + i).remove(); if(total_net > 0){ $(this).append($("<div id='total_net" + i + "'></div>").text('Total Net: ' + total_net)); } $("div#total_gross" + i).remove(); if(total_gross > 0){ $(this).append($("<div id='total_gross" + i + "'></div>").text('Total Gross: ' + total_gross)); } }); }, }); }); /* END of Net/Gross Calculation function */ Function: groupItemOrder# /* START of groupItemOrder# functions - used to update each group array on-the-fly, to obtain the correct order of each group item, on submit of form - won't work if Net/Gross Calculation function is active */ var groupItemOrder1 = ''; $(function() { $("#sortable1").sortable({ update: function(event, ui) { groupItemOrder1 = $("#sortable1").sortable('toArray').toString(); } }); $("#sortable1").disableSelection(); }); scriptAr1 = new Array(); scriptAr1[0] = "one"; scriptAr1[1] = "two"; scriptAr1[2] = "three"; function setValue1() { var arv1 = groupItemOrder1.toString(); document.form.arv1.value=arv1; } var groupItemOrder2 = ''; $(function() { $("#sortable2").sortable({ update: function(event, ui) { groupItemOrder2 = $("#sortable2").sortable('toArray').toString(); } }); $("#sortable2").disableSelection(); }); scriptAr2 = new Array(); scriptAr2[0] = "one"; scriptAr2[1] = "two"; scriptAr2[2] = "three"; function setValue2() { var arv2 = groupItemOrder2.toString(); document.form.arv2.value=arv2; } var groupItemOrder3 = ''; $(function() { $("#sortable3").sortable({ update: function(event, ui) { groupItemOrder3 = $("#sortable3").sortable('toArray').toString(); } }); $("#sortable3").disableSelection(); }); scriptAr3 = new Array(); scriptAr3[0] = "one"; scriptAr3[1] = "two"; scriptAr3[2] = "three"; function setValue3() { var arv3 = groupItemOrder3.toString(); document.form.arv3.value=arv3; } /* END of groupItemOrder# functions */ FULL HTML: <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "sort-group")) { $original_groups = $_POST['original_groups']; // returns 3 for example $i = 1; do{ $ss = $_POST['arv'.$i]; $tok = explode(',',$ss); $order = 1; foreach($tok as $var) { $id = $var; if(is_numeric($id)){ echo "(GROUP: $i) Item ID: $id (Order: $order)</br>"; $order++; } } $i++; }while($i-1 < $original_groups); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI Sortable - Connect lists</title> <link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"></link> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script> <script> /* START OF Net/Gross Calculation function - used to calculate the Net/Gross of each group - won't work if the groupItemOrder# on-the-fly array updater are active */ $(document).ready( function () { $('ul.connectedSortable').sortable({ update: function (ser) { $(".connectedSortable").each(function (i) { var total_net = 0; var total_gross = 0; $(this).find(".net").each(function () { total_net += parseInt($(this).text()); }); $(this).find(".gross").each(function () { total_gross += parseInt($(this).text()); }); $("div#total_net" + i).remove(); if(total_net > 0){ $(this).append($("<div id='total_net" + i + "'></div>").text('Total Net: ' + total_net)); } $("div#total_gross" + i).remove(); if(total_gross > 0){ $(this).append($("<div id='total_gross" + i + "'></div>").text('Total Gross: ' + total_gross)); } }); }, }); }); /* END of Net/Gross Calculation function */ /* START of connectWith function - works with both functions */ $(function() { $( "#sortable1, #sortable2, #sortable3" ).sortable({ connectWith: ".connectedSortable" }).disableSelection(); }); /* END of connectWith function */ /* START of groupItemOrder# functions - used to update each group array on-the-fly, to obtain the correct order of each group item, on submit of form - won't work if Net/Gross Calculation function is active */ var groupItemOrder1 = ''; $(function() { $("#sortable1").sortable({ update: function(event, ui) { groupItemOrder1 = $("#sortable1").sortable('toArray').toString(); } }); $("#sortable1").disableSelection(); }); scriptAr1 = new Array(); scriptAr1[0] = "one"; scriptAr1[1] = "two"; scriptAr1[2] = "three"; function setValue1() { var arv1 = groupItemOrder1.toString(); document.form.arv1.value=arv1; } var groupItemOrder2 = ''; $(function() { $("#sortable2").sortable({ update: function(event, ui) { groupItemOrder2 = $("#sortable2").sortable('toArray').toString(); } }); $("#sortable2").disableSelection(); }); scriptAr2 = new Array(); scriptAr2[0] = "one"; scriptAr2[1] = "two"; scriptAr2[2] = "three"; function setValue2() { var arv2 = groupItemOrder2.toString(); document.form.arv2.value=arv2; } var groupItemOrder3 = ''; $(function() { $("#sortable3").sortable({ update: function(event, ui) { groupItemOrder3 = $("#sortable3").sortable('toArray').toString(); } }); $("#sortable3").disableSelection(); }); scriptAr3 = new Array(); scriptAr3[0] = "one"; scriptAr3[1] = "two"; scriptAr3[2] = "three"; function setValue3() { var arv3 = groupItemOrder3.toString(); document.form.arv3.value=arv3; } /* END of groupItemOrder# functions */ </script> <style> #sortable1, #sortable2, #sortable3 { list-style-type: none; padding: 5px; margin-right: 10px; width: 300px; margin-top: 0; margin-bottom: 0; margin-left: 0; display:block; } #sortable1 li, #sortable2 li, #sortable3 li{ padding: 5px; font-size: 12pt; width: 200px; margin: 5px; cursor: pointer; } #sortable1 .net , #sortable1 .gross, #sortable2 .net , #sortable2 .gross, #sortable3 .net , #sortable3 .gross{ float: right; } </style> </head> <body> <form action="<?php echo $editFormAction; ?>" method="post" name="form" id="form" onSubmit="setValue1(), setValue2(), setValue3()"> <input type="submit" id="button" value="Sort Mulitple Lists" /> <ul id="sortable1" class="connectedSortable"> <li class="ui-state-default" id="6411"> 6411 <div class="net">100</div> - <div class="gross">250</div> </li> </ul> <input name="arv1" type="hidden"> <ul id="sortable2" class="connectedSortable"> <li class="ui-state-default" id="6230"> 6230 <div class="net">100</div> - <div class="gross">250</div> </li> </ul> <input name="arv2" type="hidden"> <ul id="sortable3" class="connectedSortable"> <li class="ui-state-default" id="6434"> 6434 <div class="net">100</div> - <div class="gross">250</div> </li> </ul> <input name="arv3" type="hidden"> <input type="hidden" name="original_groups" value="3" /> <input type="hidden" name="MM_insert" value="sort-group" /> </form> </body> </html> If anyone can help, it'll be hi-5-tastic. Thanks in advance.
  12. Thanks, managed to sort it using file_put_contents.
  13. Hi Chaps, I'm working on a PHP script to mysqldump database to file. Using this as a base: http://www.edmondscommerce.co.uk/mysql/php-mysql-dump-script/, I've managed to strip it down to this: set_time_limit(0); $mysql_host='localhost'; $mysql_database='database'; $mysql_username='username'; $mysql_password='pasword'; _mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password); $print_form = 0; header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="'.$mysql_database."_".date('Y-m-d').'.sql"'); $filename = $mysql_database."_".date('Y-m-d').'.sql'; _mysqldump($mysql_database); function _mysqldump($mysql_database) { $sql="show tables;"; $result= mysql_query($sql); if( $result) { while( $row= mysql_fetch_row($result)) { _mysqldump_table_structure($row[0]); _mysqldump_table_data($row[0]); } } else { echo "/* no tables in $mysql_database */\n"; } mysql_free_result($result); } function _mysqldump_table_structure($table) { echo "/* Table structure for table `$table` */\n"; echo "DROP TABLE IF EXISTS `$table`;\n\n"; $sql="show create table `$table`; "; $result=mysql_query($sql); if( $result) { if($row= mysql_fetch_assoc($result)) { echo $row['Create Table'].";\n\n"; } } mysql_free_result($result); } function _mysqldump_table_data($table) { $sql="select * from `$table`;"; $result=mysql_query($sql); if( $result) { $num_rows= mysql_num_rows($result); $num_fields= mysql_num_fields($result); if( $num_rows> 0) { echo "/* dumping data for table `$table` */\n"; $field_type=array(); $i=0; while( $i <$num_fields) { $meta= mysql_fetch_field($result, $i); array_push($field_type, $meta->type); $i++; } echo "insert into `$table` values\n"; $index=0; while( $row= mysql_fetch_row($result)) { echo "("; for( $i=0; $i <$num_fields; $i++) { if( is_null( $row[$i])) echo "null"; else { switch( $field_type[$i]) { case 'int': echo $row[$i]; break; case 'string': case 'blob' : default: echo "'".mysql_real_escape_string($row[$i])."'"; } } if( $i <$num_fields-1) echo ","; } echo ")"; if( $index <$num_rows-1) echo ","; else echo ";"; echo "\n"; $index++; } } } mysql_free_result($result); echo "\n"; } function _mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password) { global $output_messages; $link = mysql_connect($mysql_host, $mysql_username, $mysql_password); if (!$link) { array_push($output_messages, 'Could not connect: ' . mysql_error()); } else { array_push ($output_messages,"Connected with MySQL server:$mysql_username@$mysql_host successfully"); $db_selected = mysql_select_db($mysql_database, $link); if (!$db_selected) { array_push ($output_messages,'Can\'t use $mysql_database : ' . mysql_error()); } else array_push ($output_messages,"Connected with MySQL database:$mysql_database successfully"); } } The problem is, I want the file to save to a specific network location, rather than the output being sent to headers. I've tried to play around with: ob_start();.... $page = ob_get_contents(); ob_end_flush(); $fp = fopen("output.html","w"); fwrite($fp,$page); fclose($fp); But this outputs to the browser, then saves the file...I would like to load the page, and have the script create and save the file where I want it (without the output in the browser, or prompt to save/download file). Note: I need something like this as I'm running PHP/MySQL on IIS, so can use shell/system/etc. Any help will be hi-5-tastic!
  14. Hi Chaps, Hopefully an easy one for you, having a bit of trouble with an array within array. I'm parsing an XML document, and attempting to assign variables as I go along. I'm hitting some trouble with one particular child node, as it's in an array. PHP: print_r($parent->child); Array: Array ( [0] => XMLTag Object ( [tagAttrs] => Array ( ) [tagName] => child [tagData] => Something in tagData [tagChildren] => Array ( ) [tagParents] => 3 ) ) Im basically after the value of child [tagData] , so I'll be able to assign a variable: If anyone can help, it'll help me no end Cheers
×
×
  • 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.