Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Just use an UPDATE query, without a WHERE clause, to set the password field to be the sha1 of the password field, provided you have a known good backup of your database (just in case) and the password field length is sufficient to hold a sha1 value.
  2. I edited my post above with what the actual serialized data should have been (your's is in valid.) Any chance you did some kind of global search/replace/update query on the data to change the f_names, without actually re-serializing the data to match?
  3. While it doesn't have anything to do with your problem, you should be using a fetch_assoc statement to retrieve your data (you are using fetch_array now, giving both associative and numerical arrays in your data.) If that's your actual data, it is invalid for the 2nd set of values (the length of some of the strings doesn't match what the serialized syntax says they are.) What does using var_export on the data produce (so that someone here could reproduce the problem.) Edit: Specifically, the strings you show in that data would produce the following serialized output - a:4:{i:0;s:17:"register_password";i:1;s:11:"r_pass_word";i:2;s:9:"user_pass";i:3;s:13:"reg-pass-word";}
  4. You would need elements for B0 - B20. B0 is active when the data is 0, B1 is active when the data is .5, ... B20 is active when the data is 10. You would just start the for() loop at zero - <?php $data = ...; $value = 2*$data; //(0-20 in whole steps) echo "<ul>"; for($i=0;$i <=20;$i++){ echo "<li id='B$i'"; if($i == $value){echo " class='active'";} if($i > $value){echo " class='no'";} echo "></li>\n"; } echo "</ul>";
  5. Here's a different slant on the problem - variables created inside functions and class methods are local to that invocation of the function/class method and are destroyed when that function/class method call ends (unless you declare the variable static inside that function/class method) and there's no need for you to be freeing up resources inside functions/class methods unless you have complicated code in that function/class method that executes more than one query that returns large result sets.
  6. Only SELECT and SHOW (EXPLAIN) queries return result resources. INSERT/UPDATE queries only return boolean TRUE/FALSE and there is nothing for a free_result statement to free up. Edit: As stated in the documentation for the function you are trying to use -
  7. The data value (6 in the example) determines where to change the output as you are looping to produce that output - <?php $data = 6; // assigned from your query/fetch logic (0-10 in .5 steps) $value = 2*$data; //(0-20 in whole steps) echo "<ul>"; for($i=1;$i <=20;$i++){ echo "<li id='B$i'"; if($i == $value){echo " class='active'";} if($i > $value){echo " class='no'";} echo "></li>\n"; } echo "</ul>";
  8. Following works for me - <form action="formaction.php"> <select multiple="multiple" name="cars[]"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel" selected="selected">Opel</option> <option value="audi">Audi</option> </select> <input type="submit" /> </form> Are you sure you output the correct syntax in your actual form?
  9. Or if you only want to replace whole matching words - <style type="text/css"> span.highlight {font-weight:bold;} </style> <?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); echo $string;
  10. $buylink is an array (which is why mysqli_fetch_array was named that.) You would need to reference the correct index of that array - $buylink['mobo_buylink'] There are examples of all the basic php statement usage in the php.net documentation - http://us3.php.net/manual/en/mysqli-result.fetch-array.php
  11. 1) Your type="file" form fields should use an array for the field name, then you can simply iterate over the array in the php form processing code to test for upload errors and make use of the uploaded file information. See Example #3 at this link - http://us2.php.net/manual/en/features.file-upload.post-method.php If any of the uploaded file field are required or optional, you would need to address that in the processing logic (an upload error #4 UPLOAD_ERR_NO_FILE means that no file was picked for that upload field.) 2) Your php code needs to first check that a form was submitted. Since one of the possible upload error conditions (see the next item on this list) will cause the $_FILES and $_POST arrays to be empty, you need to use the following logic to check if a form was submitted - if($_SERVER['REQUEST_METHOD']=='POST'){ your form processing code goes here...} 3) You also need to test that the $_FILES array is not empty, since that would indicate that the total of all the posted data from the form exceeds the post_max_size setting. See this link - http://us2.php.net/manual/en/ini.core.php#ini.post-max-size 4) Then you need to check the uploaded file information for errors (see item 1 on this list) and process the successfully uploaded file(s). 5) Finally, after you have processed any/all of the uploaded files and validated all of the data from the form, you need to escape the string data values before putting them into your query statement. I also notice that your <form tag is missing the needed enctype attribute. Reading the entire upload handling section of the php.net documentation would probably help - http://us2.php.net/manual/en/features.file-upload.php
  12. A bigger question would be, how do you want to display/layout these multiple images on your page? Getting an array of the matching files would be a simple glob statement - $files = glob("pictures/{$id}_*.jpg"); You would then just iterate over the array of files and output the corresponding <img ...> tags.
  13. A) Don't put select queries inside of loops. It is extremely inefficient. B) Execute one query that gets all the rows you want in the order that you want them. C) Simply iterate (loop) over the row(s) that the query returns and output the data the way you want it on your page. dmhall0, its likely that your - 'different locations on a page' are actually an ordered list of some kind and you simply need to put the necessary code inside the loop that produces the output that you want. If you do need to do something that requires more processing of the data in order to output it, you would store the data in an array using an index that has meaning for how you would like to access the data. P.S. An array is a perfectly find variable, one with more than one dimension, that is used to store related data. P.P.S. mysql_result is the slowest way of accessing data in the result set since it performs a data seek every time you call it. Probably why a mysqli equivalent doesn't exist. P.P.P.S $profile.$i doesn't reference php scaler variables and the syntax that would is three times slower than using an array. To store the result into an array variable, you would use $profile[$i]
  14. Stop, stop, stop. Hold the presses (or in this case the http response.) You would never hardcode more than about two lines of repetitive code that only differ in the data value they operate on. You need to use an array that defines the abbreviation/value and the display name. Then simply loop over that array to produce the <option></option> list. Inside that loop you would test the submitted value and output the html needed to cause the current option to be selected. Also, the correct syntax to specify which option is selected is - selected="selected"
  15. The dologin.php code in that example only returns the 'success' status back to the ajax code. It would be up to you to modify your actual login code to do the same upon successfully authenticating the visitor's username/password. It would be your login code that sets up the necessary session variables to identify the current visitor and determine if he is logged in. Edit: That code you found would be better titled as - "jquery login form submission with success/failure message."
  16. The comment/documentation in that class definition has the wrong class name and even the include statement in the addclient.php code is for the wrong file. In addclient.php, you would change the $oauth = new OAuth2StoragePDO(); statement so that the (missing) parameter contains an instance of your desired PDO class. Assuming that your page makes an instance of a PDO class at some point - $dbConnection = new PDO('mysql:dbname=mydb;host=localhost', 'user', 'pass'); Change any use of new OAuth2StoragePDO() in the 'example' pages to - new OAuth2StoragePDO($dbConnection) Line 15 of addclient.php would become - $oauth = new OAuth2StoragePDO($dbConnection);
  17. Echoing something on the page won't accurately show what is happening if the page is being requested twice (you will only see the output from the last time the page is being requested), because the echoed output or lack there of will be replaced by the complement (lack of echoed output or the expected echoed output) on the second page request, which is why someone recommend logging definitive information about the page requests to help troubleshoot the problem. Edit: Here's another possibility that could fit these symptoms. You have a header redirect somewhere that doesn't have an exit; statement after it and when the remainder of the code on your page runs while the browser is making the request for the new page, the remainder of the code on that page causes your update query to run/not-run. This offending IE statement being present in the css on the page could affect if/when/how long the redirect takes and affects if the problem shows itself. I would recommend posting enough of your code that reproduces the problem so that someone could pin down the actual cause.
  18. What exactly symptom or error did you see in front of you that leads you to believe that the script has a problem connecting to your database and what steps have you taken to troubleshoot the problem?
  19. It's likely that statement is causing your page to be requested twice, once with an expected URL and once with an empty query string on the end of the URL. I would log (see the error_log statement) the date/time date('Y-m-d H:i:s') and $_SERVER['REQUEST_URI'] right before your if(empty()){} logic so that you can see exactly if, when, how many times, and what is being requested on the end of the URL.
  20. Since the OP's code is skipping the query code during the first three iterations of the loop, it's likely that the query(ies) that are not updating anything correspond to those first three iterations of the loop.
  21. That error means that code is not the actual code that is producing that error. ^^^ Means that the variable or literal value you supplied to the mysql_fetch_array() statement is a string. The posted code would have supplied a result resource if the query executed without any errors or a boolean false value if the query failed to execute due to an error. The only way the posted code could have supplied a string to the mysql_fetch_array() statement would be if there was a statement like - $sql = "a statement producing a string";, either somewhere between the mysql_query() statement and the start of the while(){} loop or somewhere in the actual code inside the while(){} loop.
  22. I tried your posted code using a valid and matching upload form and you will get an error at the move_uploaded_file statement because you have set the first parameter to be a GD image resource. move_uploaded_file expects the first parameter to be the original tmp uploaded file (kind of why they named it move_uploaded_file.) If your intent is to save the resized image in $image_resized to the $folder.$fileName location, you would need to use an appropriate GD output function - imagejpeg($image_resized, $folder.$fileName);
  23. It's not that hard to form and execute any kind of query. Where's your mysql_query() statement?
  24. If the mysql_error message is referring to a point in the query where your external data is at, it is likely that you are not escaping the data before putting it into the query and the data contains special sql characters. See this link - mysql_real_escape_string
  25. A false value means your query is failing due to an error of some kind. echo mysql_error(); right after the mysql_query() line to find out why the query is failing.
×
×
  • 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.