Jump to content

AyKay47

Members
  • Posts

    3,281
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by AyKay47

  1. Blue and green all around me.... -.-
  2. Yes it's possible.
  3. Congrats Kicken.
  4. really? again. post your updated code, along with THE EXACT ERRORS THAT YOU ARE RECEIVING IN THE OUTPUT.
  5. sending an HTTP header via header() is normally the preferred solution, as that is what they are there for, perhaps if we saw the logic in your code we could provide a more detailed answer.
  6. the foreach loop is working just fine, the problem is your understanding of mysql_fetch_array. mysql_fetch_array() retrieves a single row from the results set of the query and returns an array of the corresponding data in the fetched row, and moves the internal pointer ahead. so in your code, the array $link6_array10 contains data from only one row of the results set, resulting in only one iteration of the specified foreach loop. to get all of the data from your results set, you must iterate over each row grabbed from your query, this is typically done by a while loop or for loop (refer to stj's reply), although other methods can also be implemented.
  7. it allows hyphens as is.
  8. open a "view source" in your browser and make sure that the proper values are present in your form to be sent, that it the first step. the second step is to debug the javascript handling of your form, making sure that the values are correct before submittal to the back end.
  9. well, what exactly are your results, a little more detail is needed for me to be able to help you out. Also, I notice that you are not escaping the $_POST values before submitting nor validating that they exist. include_once("connect.php"); if(isset($_POST['product'], $_POST['price'])) { $product = mysql_real_escape_string($_POST['product']); $price = mysql_real_escape_string($_POST['price']); $sql = "INSERT INTO cart (price, product) VALUES('$price', '$product')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql <br />" . mysql_error()); }
  10. im still thinking about the one, perhaps something along the lines of this: $(".myform").each(function(i,e)) { $(this).validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('process.php', $(this).serialize(), function(data) { $("#price").load("index.php #price"); $('#results').html(data); }); } }); } my thinking here is to iterate over each form object and call the "validate" method on each one, instead of the entire group in one call. I am not terribly familiar with the .validate plugin so some tweaking may need to be done.
  11. || is not like and, example, in your case if you had: <? echo ($info['Status'] == 'Sold' && $info['Status'] == 'on hold') ? "<span class='echo'>".$info['Status']."</span>" :"For sale"; ?> Using the && and operator, this would mean that Both conditions would have to be met in order for you to receive the TRUEnternary response. However in your case, since you are using the || or operator, only one of the conditions needs to be met in order for the TRUE ternary response to output.
  12. What errors are displayed?
  13. Debbie, your original question was "how much should you validate a first name". The answer is, all you can do is filter out rediculous fake names, as your regex does, and filter out things like fields that only contain spaces, as trim() will do. When it comes down to it, in this case, it would be very hard to prevent any sort of injection from simple first name checks, as the characters involved in SQL injecting a form can also be used in a name. The important thing is once the field is passed to your back end form handling code, it is properly sanitized and escaped. Since you are using prepared statements (this is the best SQL security in my opinion), the string will be internally sanitized and prepared for query use. So if you are indeed using prepared statements, your data will be secure, as this is the nature of prepared statements.
  14. By chance, does one of the form values get consistently submitted? It may be a case of the two tables not being unique, class, name, etc. try making each form unique (most likely by using a counter in your loop) and set your js selector to be unique as well. I can't say that I've had two of the same table in my DOM before, so I am not positive on the affects of this or if this will solve the issue, however I am fairly certain.
  15. As is, an SQL injectedmstringnwould pass these checks, if you are going to use this as your validation, at the minimum, escaping the value is a must (as always) before using this in a query.
  16. Only the first form is working because you have your JavaScript based on an id, when multiple ids are present in the DOM, only the first one is used, as having multiple ids of the same value defeats the purpose of ids and is invalid. You should be using a class on your form instead.
  17. This is because your query is failing and returning false, debugging measures should be in place. $result = mysql_query($query); if(!$result) { echo $query . "<br />"; echo mysql_error(); }
  18. Well, you telling me that your success functions runs means that the Ajax request is sent successfully, so I won't worry about the JavaScript for now. Debugging measures should be in place in your code, never expect your code to simply work. Take measures so that if something goes wrong, you will know exactly where. if(isset($_POST['vote'])) { echo $vote; exit; $vote_id = htmlspecialchars($_POST['vote']); $insert_sql = $db->build_query('INSERT', array( 'game_id' => $game_id, 'vote_for' => $vote_id, 'ip_address' => $_SERVER['SERVER_ADDR'], 'time' => time() )); $sql = "INSERT INTO votes $insert_sql"; $db->query($sql); } In your ajax, have the success function alert the data being sent from the server. The first step is to make sure that $vote is what you expect. If $vote is what you expect, the next step would be to check your build_query() method for internal errors, and debug that.
  19. Well, there are a few things to check for before pinpointing what is causing this. 1. Make sure that an Ajax request is even being sent. Is your success function being executed? 2. Make sure that var dataString is what you expect, output it to the browser. 3. If you are sure that an Ajax request is being sent, make sure error_reporting() is set to E_ALL and let us know if you are receceiving any back end errors. You telling us "this code doesn't work, help me fix it" number one isn't very friendly, and two doesn't help us help you. Tell us what errors you are receiving if any, what happens exactly when the script is ran?
  20. if you are expecting rows returned from your query but are not getting them, something is wrong with your query. Review the query, figure out why it is not grabbing any rows, then redefine the query to the correct one.
  21. depends, you will be able to grab an $_POST values that are being sent from the ajax data: property. Say this is your ajax request: $.ajax({ type: "POST", url: "index.php", data:test=1&variable=2, success: function() { alert ("success"); } }); to grab this data in "index.php" it would loo like this. if(isset($_POST['test'], $_POST['variable'])) { //variables are set, proceed with code }
  22. the first step would be checking for the POST values sent via ajax through the query string being set using isset. Once you are sure the values are present, you can begin writing the necessary validation and handling code.
  23. that or $('input:[name=vote_radio]:checked').val(); will work, I notice one major flaw in your code, you have multiple id's with the same name, which is the reason that you were receiving the value of one repetitively with the first suggested code. Id's should always be unique, as if they are not this defeats the purpose of an id and a class should be used instead. If multiples of the same id are present, when attempting to select them with a jquery selector, it will only select the first element in the group. This rule applies for CSS as well.
  24. for this, refer here Edit: first comment retracted, as I overlooked the fact that $_POST['product'] contains an array of check box values, apologies pika.
  25. with "lol" removed, can you run this code and post the results. if (empty($_SESSION['order']['content'])) { unset($_SESSION['order']['content']); print_r($_SESSION['order']); }
×
×
  • 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.