Jump to content

Firemankurt

Members
  • Posts

    56
  • Joined

  • Last visited

Everything posted by Firemankurt

  1. Thanks ignace. So much to remember in such little brain space. Anyone else need a memory upgrade?
  2. I am trying to grasp jQuery and I am having trouble translating this JS from prototype to jquery. /* My working Prototype Script */ showDetails = function (id) { new Ajax.Updater('Detail', 'MemDir/ajax/Details.php', { method:'get', parameters: {mem:id}, onSuccess: function() {}, onFailure: function(transport){alert('Loading Details Failed - Please check your connection.');} }); } // Jquery version not working function showDetails(id) { $.ajax({ type: "GET", url: 'MemDir/ajax/Details.php', data: 'mem='+id, success: function(data){ $("#Detail").html("Result: " + data); } }); } It is a simple function that is just meant to grab a persons contact info from the server and insert it into a Div with ID of Detail. I have been using Prototype for several years but just starting out with JQuery. Thanks in advance for any assistance with this...
  3. Thanks Nightslyr... That is a good point and something I will have to analyze as I continue with my design. Any other thoughts from members?
  4. I have not used pass by reference much at all in my designs but I am trying to get more efficient as I learn. Is there any advantage to passing by reference in the model below? <?php class Core { private $_SOMEVALUE; // Number of days till an entry should be removed from database public function __construct() { $this->_SOMEVALUE = 1234; }// End Constuct public function giveSomeValue() { return $this->_SOMEVALUE; }// End addNew() }// End Class Checklist class Checklist { public $_CORE; // Number of days till an entry should be removed from database public function __construct(&$CORE_obj) { $this->_CORE = $CORE_obj; }// End Constuct public function test1() { return $this->_CORE->giveSomeValue(); }// End addNew() }// End Class Checklist class Grouplist extends Checklist { public function __construct(&$CORE_obj) { parent::__construct($CORE_obj); }// End Constuct public function test2() { return $this->_CORE->giveSomeValue(); }// End addNew() }//End Class Grouplist $CORE_obj = new Core(); $GL = new Grouplist($CORE_obj); echo '<br />test1='.$GL->test1(); echo '<br />test2='.$GL->test2(); ?> The "Core" class in my actual application contains a function "DBquery()" that handles all mysql queries. This keeps me from having to add a global "$mysqli" variable everywhere I use a query and allows for centralized error handling.
  5. try changing $filstorlek = bytestostring($r['size'], ""); to $filstorlek = bytestostring($r['size'], 0); or $filstorlek = bytestostring($r['size']);
  6. I am rebuilding a CMS system that I have been developing over the last ~6 years. It needs to have many different kinds of modules depending on the installation (Like Drupal or Joomla does) I have a Core class that does the major processing. I am currently developing the part of the system that loads the actual module into the index.php page. While experimenting I came up with an idea that is probably really horrible but I started to wonder if maybe it could actually work well. I am looking for feedback on this Core class function: public function LoadMods($ModsToLoad) { foreach ($ModsToLoad as $mod) { $MainFile = ABSPATH.DS.$mod.DS.'main.php'; if (file_exists($MainFile)) include ($MainFile); else $this->_MAIN .= 'Error: The "main" file for "'.$mod.'" module could not be found<br/>'; } } It will receive an array of Module names and those names correspond to a directory that holds the "main.php" file for that module. Example: index.php?mod=Photos Will load the "Photos" module. Here is the thing that has me concerned... A module might have it's own class or classes and that class will likely get included in the "main.php" file for that module. What effect is that going to have on my core class because it starts nesting classes inside classes. Is this an efficiency advantage or am I heading down a road paved by code stink? What's you opinion?
  7. Solved it... I had ids in form elements but not names..... Duhhhhh...
  8. Not sure exactly what you have going on here but for starters, each element ID in your document must be unique. <label id='lbF".$cnt."'> is repeated several times.
  9. Have you considered http://www.prototypejs.org/api/ajax/updater callAjax = function () { new Ajax.Updater('iframe_chat', 'forum_chat.php', { parameters: {ID: $F('chat')}, onFailure: function(){alert('Error.');} }); }
  10. You can not have two divs with the same ID "statediv" Change div ids and pass them with your onChange event.
  11. I am a PHP guy struggling with JS. I dynamically create forms with several fields that can change names at any time. I need to gather all form input names and values into a string that I can then send in one $_GET element? I will separate them out again in the PHP that receives the $_GET element. Here is the section of my code giving me trouble. I simplified to reduce the possibility of masking one problem with another. <html> <head> <title>FD Manual</title> <script src="http://train.iaff106.org/js/scriptaculous/prototype.js" type="text/javascript"></script> <script src="http://train.iaff106.org/js/scriptaculous/scriptaculous.js" type="text/javascript"></script> <script type="text/javascript"> NewSlidePreviewRequest = function (typeid) { var newdata = $('S').serialize(true); alert(newdata); var jsonstr= JSON.stringify(newdata); alert(jsonstr); // AJAX stuff sends string to PHP receiver for parsing and response } </script> </head> <body> <form id="S"> <label for="ImgTopCaption">Image Top Caption</label> <input type="text" id="ImgTopCaption" value="Image Top Caption"> <label for="Text">Text</label> <textarea id="Text">This is my text</textarea> <a href="#" onclick="NewSlidePreviewRequest(1)" >Click HERE</a> </form> </body> </html> I was expecting one of those alerts to contain a string like: {ImgTopCaption: 'Image Top Caption', Text: 'This is my text'} But not working like I hoped.
  12. You should always run user input through a cleanup function prior to using it in a query. Here is the one I use: function cleanValues($value) { //undo slashes for poorly configured servers $value = (get_magic_quotes_gpc()) ? (stripslashes($value)) : ($value); //determine best method based on available extensions if (function_exists('mysql_real_escape_string')) { $value = mysql_real_escape_string($value); } else { $value = mysql_escape_string($value); } return $value; } This should also escape the single quote to prevent th issue you are having.
  13. try surf to : [url=http://www.whatsmyip.org/]http://www.whatsmyip.org/[/url] This will give you your ip address.
  14. if you add var_dump(file); at the end of your script does it show any values in "file" array?
  15. 1 - I'm guesing you are not actually connected to MySQL database before calling [b]mysql_real_escape_string ()[/b] somewhere (looks like file is :  [b]connect.php[/b] on line 30) [i]string[/i] mysql_real_escape_string ( [i]string[/i] unescaped_string[i] [, resource link_identifier][/i] ) 2 - maybe your script is putting a boolean  value in place of the optional [u]resource link_identifier[/u]. I'm not sure why you believe the problem is in the code you posted???
  16. You could query the columns info and then use the results to set the values in a form. Here is a start point: from: [url=http://dev.mysql.com/doc/refman/5.0/en/describe.html]http://dev.mysql.com/doc/refman/5.0/en/describe.html[/url] DESCRIBE provides information about the columns in a table. It is a shortcut for SHOW COLUMNS FROM. As of MySQL 5.0.1, these statements also display information for views. (See Section 13.5.4.3, “SHOW COLUMNS Syntax”.) col_name can be a column name, or a string containing the SQL ‘%’ and ‘_’ wildcard characters to obtain output only for the columns with names matching the string. There is no need to enclose the string within quotes unless it contains spaces or other special characters. [code] mysql> DESCRIBE city; +------------+----------+------+-----+---------+----------------+ | Field      | Type    | Null | Key | Default | Extra          | +------------+----------+------+-----+---------+----------------+ | Id        | int(11)  | NO  | PRI | NULL    | auto_increment | | Name      | char(35) | NO  |    |        |                | | Country    | char(3)  | NO  | UNI |        |                | | District  | char(20) | YES  | MUL |        |                | | Population | int(11)  | NO  |    | 0      |                | +------------+----------+------+-----+---------+----------------+[/code]
  17. I have seen a few projects like this on sourceforge. You might search around like: [url=http://sourceforge.net/search/?type_of_search=soft&words=school]http://sourceforge.net/search/?type_of_search=soft&words=school[/url] You might get ideas or just use something you find there.
  18. If you want to do this after the query then something like: [code] <?php $mystring = 'This is a long block of usles text <!stop> that goes on forever.'; $findme  = '<!stop>'; $pos = strpos($mystring, $findme); $ShortStr = substr($mystring, 0, $pos); echo $ShortStr; ?> [/code]
  19. [code] <?php $result = mysql_query("SELECT clients_name, id FROM clients_info WHERE city='$city' AND $category='x'group by clients_name"); while ($row = mysql_fetch_array($result, MYSQL_NUM)) {   $filename="/data/11/0/77/86/729738/user/744719/htdocs/b/admin/client_pics/$row[1]/";   if (file_exists($filename))   {     $dir = "/data/11/0/77/86/729738/user/744719/htdocs/b/admin/client_pics/$row[1]/";     $dh  = opendir($dir);     while (false !== ($filename = readdir($dh)))     { //      $files[]=$filename;  ---- Remove this ----     $Exten = substr($filename, -3);     if ($Exten=="jpg" || $Exten=="gif") $files[]=$filename;       //echo "filename: $filename : filetype: " . filetype($dir . $filename) . "\n";     }   $PicCount = count($files); // Count number of files found   } if ($PicCount >2)// this is how you know there are pics and not just directories   {     $PictNum = rand(2, $PicCount); // choose random picture     print "<TR><TD><img src=/phpThumb/phpThumb.php?src=/b/admin/client_pics/$row[1]/$files[$PictNum]&w=100>/b/admin/client_pics/$row[1]/$files[$PictNum]</TD></TR>";   }   else {       echo "This client has no pictures";   } [/code]
  20. How about: [code]       $ImageSet = $num_rows / 20;       $total_pages = round($ImageSet);       if ($ImageSet > $total_pages) ++$total_pages;   }   if ($current_page == 1) {       $Limit_finish = 20*$current_page;       $Limit_start = $page_finish-20;   } [/code]
  21. Her try this: [code]     $query_add_product_range = "INSERT INTO TestP ( product_id, product_category, product_title, product_name, product_code, product_quantity_description, product_weight, product_price, product_dangerous ) VALUES ( $product_id, $product_category, $product_title, $product_name, $product_code, $product_quantity, $product_weight, $product_price, $product_dangerous )"; [/code]
  22. <?php // Query above already done echo "<div align=\"center\">   <table width=\"100%\" cellspacing=\"2\" cellpadding=\"5\" bordercolordark=\"#000000\" bordercolorlight=\"#000000\">"; $i = 0; echo "<tr>\n"; while ($a_row= mysql_fetch_row($Result)){   if($i == 4) { echo "<tr>\n"; $i = 0; } echo"<td width=\"100\">         <div align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">"; if (file_exists("$abpath/path to image/$a_row[id]-top.jpg")) { echo("<img src=\"http://$domain/path to image/$a_row[id]-top.jpg\" width=\"100\"><br>$a_row[#####]</td>"); $i++; } } echo "</table>"; // More php... ?>
  23. Couple simple things to help find your problem add this while debuging: [code] var_dump($_POST); ... mysql_select_db($db) or die(mysql_error()); mysql_query("INSERT INTO 'guides' VALUES ('$title','$summary','$screenshot','$content','$overallrating','$media','$gameplay','$graphics','$sound','$value')"); $ErrNum = mysql_errno (); $ErrText  = mysql_error(); echo "Error : ".$ErrNum."  ".$ErrText; Print "Your information has been successfully added to the database."; [/code] Then you can see what was recieved in the post and then see any MySQL errors.
  24. I am not sure what you are after but I know you can include html pages into php pages like: [code] <html> <head> </head> <body> <?php echo "some PHP content"; ?> <IFRAME SRC="recipe.html" TITLE="The Famous Recipe"> <!-- Alternate content for non-supporting browsers --> <H2>The Famous Recipe</H2> <H3>Ingredients</H3> .... </IFRAME> </body> </html> [/code] You would save this as a php file. You could also insert php into an html page like: HtmlPageWithPhpInside.htm [code] <html> <head> </head> <body> <?php echo "some PHP content"; ?> html... blah... blah... </body> </html> [/code] and then include this in a php doc. New.php [code] <?php include ('HtmlPageWithPhpInside.htm'); ?> [/code] Anyway... If you give me more info I can see if there is more I can help with.
×
×
  • 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.