Jump to content

sumpygump

Members
  • Posts

    14
  • Joined

  • Last visited

sumpygump's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. http://www.php.net/manual/en/book.pdo.php http://www.php.net/manual/en/book.mysqli.php Are manuals in PDF format a requirement? What problem are you looking to resolve?
  2. Depending on the string search for and its context within the site, strpos might not be the best solution because of white space and other differences in the string that could lead to not matches. For example, spelling typos, missing or different punctuation, extra spaces or other white space including line breaks. A regex might be a better bet, but still have room for false negatives. What is the nature of the strings you are searching for? This is one of the problems, if not the main problem with the usefulness and reliability of "screen scraping."
  3. Okay, great! Welcome to the world of coding in PHP. So, by input I mean what do you pass into the function countModules(). The input is the text in between the parentheses, so in your example, it is 'left.' I don't know anything about Joomla, but I read the description of that page about countModules(). It seems like you have three modules which you are trying to use, which are 'left', 'main', and 'right.' Is that correct? I don't think you need to set the variable $left, $right or $main in your code. Instead I think you want to do something like this: <?php if ($this->countModules ('left')) : ?> <div id="left" class="four columns"> <jdoc:include type="modules" name="left" style="xhtml" /> </div> <?php endif; ?> <?php // assumes no sidebars $mainWidth = 'sixteen'; // detect if at least one sidebar if ($this->countModules('left or right')) { $mainWidth = 'twelve'; } // detect if both sidebars present if ($this->countModules('left and right')) { $mainWidth = 'eight'; } ?> <div id="main" class="<?php echo $mainWidth; ?> columns"> <!-- // main content here --> </div> <?php if ($this->countModules ('right')) : ?> <div id="right" class="four columns"> <jdoc:include type="modules" name="right" style="xhtml" /> </div> <?php endif; ?> That might be what you need based on your original description. If you're curious about what the return values of $this->countModules() is, instead of echo $left; try, echo $this->countModules('left');
  4. The problem is that you need quotes in your SQL query: $query = "SELECT * FROM Ammunition WHERE $dbrow = '$skuid'"; So the resulting SQL must be: SELECT * FROM Ammunition WHERE SKU = '105201030-105200989-20256'; This is because your SKUs contain non-numeric characters (-).
  5. You're right about the infinite loop problem. Sorry! So here is a working example. Note the following changes: - submit button name renamed to 'submit_button'. This is because naming it 'submit' overrides the forms default submit function. - I changed the code to not use the onsubmit html attribute and instead favor injecting the javascript with jQuery into the form. - form is set to 'this' and that means that it becomes the form DOM element. - When we submit the form after checking the ajax request we are using the browser native form submit() function which doesn't trigger it to use onsubmit which eliminates the infinite loop. <form id="myform" action="index.php"> <p><input type="text" name="captcha_code"></p> <p><input type="Submit" value="Submit" name="submit_button"/></p> </form> <script type="text/javascript"> $(function() { $('#myform').submit(function(event) { // Prevents form from doing it's default submission, so we can control // when it happens. event.preventDefault(); var form = this; var captcha_code = form.captcha_code.value; $.ajax({ type:'POST', url:'/includes/check.php', dataType:'json', data: 'captcha_code=' + captcha_code, success:function(result){ if (result==1) { alert("Wrong code input"); return false; } else { form.submit(); return true; } } }); }); }); </script>
  6. First, you should set your die() to the next statement. The $query = "..."; statement is just setting a string and will not evaluate to false. Like so: $query = "SELECT * FROM Ammunition WHERE $dbrow = $skuid"; $sql = mysql_query($query) or die(mysql_error()); I am not sure of what the values of $dbrow and $skuid are or what are the field names in the table, so I don't know what might be going wrong with the actual data returned. After $row = mysql_fetch_array($sql); add a line with var_dump($row); to see what the value of $row is.
  7. As long as the page isn't refreshing (form is not submitting) prior to returning from the ajax request then it is the exact same form. I am not sure what check.php is returning. Can you verify the output of result for a correct and incorrect captcha response? Is there something else in the form that needs to be sent to check.php so it knows which captcha to validate?
  8. You can use PHP's round() function. Example: $price = 19.9500; echo round($price, 2); So, in your case: <?php echo $this->helper('catalog/output')->productAttribute($_product, round($_product->getPrice(), 2), 'price') ?>
  9. You can submit the form like this (using jQuery): $('#myform').submit();
  10. I think the problem would be that using mysql_real_escape_string is actually preparing a string to be inserted into a database in SQL, so it is converting your linebreaks into a literal "\r\n" or "\\r\\n" so it doesn't equate to an actual carriage return and line break in the email. Similar problem with the single quotes which are getting the backslashes added. I would comment out or delete the lines that call mysql_real_escape_string() on the values prior to sending the email (but keep them for whatever code is inserting them into the database, which isn't shown).
  11. Is countModules a Joomla internal function or one you are making? What are the inputs and what is the expected output vs the actual output? You mention that it doesn't work. What exactly isn't working?
  12. The problem is that dosubmit is making an ajax call and then ending, that is causing the form to be sent (posted) right away. The success function is called later after the ajax request finishes. I think by having the dosubmit function return false (it'll not submit the form), and then have the value of the result from the success function either display the error or else submit the form. You'd probably want to disable the submit button while the ajax call is waiting for a response.
  13. I think the original definition of an assembly was in the right direction. Perhaps this page will shed some more light on the subject: http://msdn.microsoft.com/en-us/library/8wxf689z.aspx "Programmng with Assemblies"
  14. Can you provide some context around the word assembly that you are looking for? Do you mean "assembly language" or "an assembly of classes"?
×
×
  • 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.