-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
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.
-
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?
-
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";}
-
retrieve and selected advanced <UL><LI> using php / mysql / html
PFMaBiSmAd replied to whynot's topic in PHP Coding Help
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>"; -
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.
-
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 -
-
retrieve and selected advanced <UL><LI> using php / mysql / html
PFMaBiSmAd replied to whynot's topic in PHP Coding Help
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>"; -
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?
-
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;
-
$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
-
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
-
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.
-
Help Assigning Query Rows to Different Variables
PFMaBiSmAd replied to dmhall0's topic in PHP Coding Help
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] -
Need to capture & echo back drop down menu selection
PFMaBiSmAd replied to n1concepts's topic in PHP Coding Help
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" -
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."
-
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);
-
PHP/MYSQL broken by the evil browser Internet Explorer
PFMaBiSmAd replied to ktroztafy's topic in PHP Coding Help
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. -
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?
-
PHP/MYSQL broken by the evil browser Internet Explorer
PFMaBiSmAd replied to ktroztafy's topic in PHP Coding Help
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. -
WHERE clause wont use variables with spaces.
PFMaBiSmAd replied to UrbanDweller's topic in MySQL Help
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. -
Display query based off selection on child page
PFMaBiSmAd replied to chutchick's topic in PHP Coding Help
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. -
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);