Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Let's start a little more basic than posting a ton of code. What application is this? Is it an open-source cart script, and if so, which one and which version? A commercial/purchased cart script? A custom script written for you?
  2. What have you done to narrow down where exactly your code and data are doing what you expect and where they are not? I can guarantee that the problem lies somewhere between those two points. If all you have done is tried your code and you are getting a query error, all you have narrowed down the problem to is somewhere in your code up to the point of that query. It could be a problem in your form or in your form processing code. For anyone here to be able to directly help with what your code and data are doing, you would need to post ALL the code needed to reproduce the problem (less any database credentials.) I can think of at least two possible reasons, one in the code producing your form (i.e. the data isn't what you expect) and one in the code producing the query statement, that could be causing a query to look like that.
  3. The url you gave produces 135 validation errors, 97 warning(s) - http://validator.w3.org/check?uri=http%3A%2F%2Fwww.livesoccerbets.com%2Findex.php%3Fpage%3DForum&charset=%28detect+automatically%29&doctype=Inline&group=0 I'll bet that fixing those makeup errors and warnings will fix most of the problems.
  4. The main point of using an id (identifier) for data is so that you can reference that data by its id. You should not need to use more than WHERE id=$id in the delete query. One possible reason your exiting query is not working is that some of the data values you are putting back into the WHERE clause may contain sql special characters and they are breaking the sql syntax. If this is the case, you would need to escape all that data before putting it into the where clause. It will be much simpler to just use the id in the where clause.
  5. You would add a content-length header to indicate the file size - header('Content-Length: ' . filesize($your_file));
  6. To perform the actual replacement in the string, see the following example (you would replace the <span></span> tag with a <a href='...'></a> tag) - <?php $search = "php|web"; // can be a single word or an OR'ed '|' list of words $string = "PHP is the web scripting language of choice, php, Web, phpweb"; $string = preg_replace("/\b($search)\b/i",'<span class="highlight">\1</span>',$string); // replace whole words only echo $string; To produce the list of words in the $search variable in that code, you would break up the initial string of text into words in an array, use array_unique to remove duplicates, perhaps filter the array to remove common words that would never end up being links, then query the database to find a list of the the words in the array that are to be links (implode the array of keywords and use it in an IN() comparison in the query statement.) You would then build the $search variable in that code from the matching words that the database query returned.
  7. A picture is worth a thousand words. Code to take a submitted country name (france, england, germany, spain, norway) and display the corresponding .jpg flag image - <?php $folder = 'flags'; // define folder with .jpg flag images $flags = glob("$folder/*.jpg"); // get a list of the flags (for building the option menu and validating the submitted value) $selected_flag = isset($_POST['country']) ? $folder.'/'.strtolower($_POST['country']).'.jpg' : ''; // build selected flag from the submitted country name $selected_flag = in_array($selected_flag,$flags) ? $selected_flag : ''; // test if submitted flag is valid (insure that only expected image files in the correct folder can be selected.) echo "<img src='$selected_flag' alt=''>"; // display selected flag If there's anything you don't understand after reading the code and comments and trying the code, just ask.
  8. Where exactly are you stuck at doing this? If your form is submitting the country name, all you would basically need to do is make the correct path/filename.ext and put that into an <img src='path/filename.ext' alt=''> tag.
  9. You can also do this on a single page, but display your form in multiple steps on that page - http://www.dynamicdrive.com/dynamicindex16/formwizard.htm
  10. What exactly is the query? Since you are not escaping the data being put into it, it might have special sql characters that are breaking the sql syntax. Echo the $q variable and post the result. Is your query failing due to an error of some kind? For debugging purposes, change your mysql_query line of code to - mysql_query($q,$con) or die("Query failed: $q<br />Error: " . mysql_error($con));
  11. Your current errors are because you haven't made a database connection before the mysql_query() statement and php is trying to make a database connection using default values, which generally fails. Where in your code are you making a database connection?
  12. @ both mohsened and insidus, This thread is over one year old. I'm pretty sure the OP discovered the problem in his code.
  13. A) What output do you get when there are too many fields and what exactly is wrong with the output? Show some sample data that works and some sample data that does not. B) We would need to have all the code necessary to reproduce the problem. Without the Product class, we have no way of knowing what the parameters even mean, what the code does, or what the data it returns looks like.
  14. I replied LOL to the information you supplied because I didn't know that nor did I scroll down in the manual page to see that information.
  15. LOL, that was fast. I just accepted a few seconds ago.
  16. I rather thought the problem was line 42 (i.e. http://en.wikipedia.org/wiki/42_Puzzle#42_Puzzle ) The reason for Pikachu2000's answer is that you posted no relevant information upon which to tell you what is wrong in your code, so you got an accurate as possible answer (i.e. a guess) based on the information supplied. Programming is an exact science. Computers only do exactly what their code and data tells them to do. We cannot tell you what your code and data are doing without seeing all the code and data needed to reproduce the problem. We are not standing right next to you and don't know what your code and data is.
  17. LOL. In your June 06 thread, you were correctly referencing the product_name and price data from your query. I suggest you look at the lines of code where you are getting the current errors and compare them with the similar lines of code in your June 06 thread.
  18. If the money_format function is undefined in your version of php, you have an extremely old version of php and need to upgrade it. It's also possible that you typed that function name using foreign language characters (the copy/paste to the forum post converted them to plain ascii) and you need to delete and retype the function name.
  19. The php string you are trying to echo starts and ends with double quotes - echo " ....... "; You are also trying to use double-quotes inside of that string around html attribute values. The first double-quote after the initial one closes the quoted string and anything after that is outside of the string and produces php syntax errors. The easiest fix would be to use single-quotes for everything that is inside of that echo " ....... "; statement. You can also put php array variables directly inside of a double-quoted string by surrounding them with {}. The following is the simplest php/html syntax that will do what you want - while ($row = mysql_fetch_assoc($result)){ echo "<tr> <td> <form method='post' action='p_select.php'> <input type='hidden' name='PID' value='{$row['ID']}'> <input type='submit' value='Submit'> </form> </td> <td>{$row['FName']}</td> <td>{$row['LName']}</td> </tr>"; } BTW - there's no need to give html elements id and name attributes unless you are actually going to reference those attributes. I did not include the id and name you had in your <form> tag. You might actually want to add a name attribute to the submit button so that you can test in the p_select.php code if a form was actually submitted.
  20. Edit: essentially states what KevinM1 posted above ... You are not using your code the way you intended, based on how you have written the ->connect() method. Your ->connect() method RETURNS an instance of the underlying database class (mysqli or pdo.) You need to assign that to a variable (you are not currently using the returned value at all) and then use that variable to reference the methods of the underlying database class. $LoginDB = new DBConnection; $DB = $LoginDB->connect('mysqli', 'persist', 'db418598519'); // $DB is an instance of the underlying database class ... $result = $DB->query("SELECT * FROM user WHERE email_address='$sanitized_email' AND password='$encoded_password'");
  21. When you supply the values via an array to the ->execute() method - This results in single quotes being added around the number, which is invalid for the LIMIT clause. You need to specifically bind the value as an integer - $stmt->bindParam(1, $max, PDO::PARAM_INT);
  22. If you search for php ACL (Access Control List) scripts, you can find general purpose role based scripts where you define roles that you assign specific permissions to. For any user/guest, you retrieve a list of their permissions based on the role defined for them. You would typically also have the ability to override or assign specific permissions on a user by user basis (i.e ban a specific user or give a specific user a permission(s) that their role doesn't have.) The permissions would be keyword based, so your logic would be like - if($ACL->hasPermission('access_guest')){// things that only guests can do...} The ACL class * at the following link is a good example - http://net.tutsplus.com/tutorials/php/a-better-login-system/ *However, the actual sample code using that class is insecure (they don't have exit; statements after security based header() redirects and some of the admin only scripts test permissions AFTER they have already executed form processing code on the page, allowing anyone to submit form data and alter settings.)
  23. I'll assume you mean you want to find names that start with the entered string. You would use a trailing % wildcard to match everything that starts with the entered string - $qry="SELECT * FROM Patient WHERE LName LIKE '$q%'";
  24. The correct php and mysql syntax would be - $qry="SELECT * FROM Patient WHERE LName LIKE '$q'"; Using LIKE without any wildcard characters in the pattern is in most cases the same as using an equal comparison - $qry="SELECT * FROM Patient WHERE LName = '$q'"; What LName value are you trying to match and what value are you putting into the $q variable?
  25. That's because you have single-quotes around the values when you build the array, making them strings. If you want the values at the time you build the array, remove the single-quotes from around each value.
×
×
  • 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.