-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Because md5 values are a fix length (32 characters) and a relatively small set of characters (0-9, a-f), there are actually more collisions (same end values for different starting values) when you do an md5 of an md5 value, making it (slightly) easier for a hacker to produce a table that matches your md5(md5()) values.
-
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
I also see that your code has two (commented out) lines setting error_reporting and display_errors. Had those two lines been in effect, you would have been getting undefined notice messages when the non-existent $_POST variables were being accessed that would have directly called your's and our attention to where the problem was at. -
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
The following changes (should) fix the problem. Change the following line (in the display_cart function) - echo "<input type=\"text\" name=\"".$title."\" value=\"".$qty."\" size=\"3\">"; To this - echo "<input type='text' name='arr[$title]' value='$qty' size='3'>"; Change - if ($_POST[$title] == '0') { To this - if ($_POST['arr'][$title] == '0') { Change - $_SESSION['cart'][$title] = $_POST[$title]; To this - $_SESSION['cart'][$title] = $_POST['arr'][$title]; -
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
This problem is because php converts spaces and dots in post/get variable names (i.e. name="... ..." attributes) into underscores. The method being used in the code you are trying to use is not very good. The name="" attributes should not be the $title. They should be an array with the index either being the $title or better yet, the id of the book. -
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
The array indexes between the post and session arrays are not the same (spaces vs underscores), so the current logic is setting the session variables to nulls (non-existent post variables.) I'm going to guess this is because of some missing quotes in the form's html markup/php converting array index names to valid php variable names. Could you post the code that is generating the form? (edit: I guess that is the display_cart() function. I'll take a look at what it is doing....) -
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
Edit to the above: After you change the print_r logic, repost the data that is displayed when you run your code. -
Trouble parring single quote through post into table
PFMaBiSmAd replied to pioneerx01's topic in PHP Coding Help
When you output content (everything that is not specifically HTML markup) on a web page, you need to use htmlentities with the second parameter set to ENT_QUOTES so that any characters in the content that have significance in HTML won't break the HTML syntax on your page. -
Setting a zero Quantity in a shopping cart problem
PFMaBiSmAd replied to jayteepics's topic in PHP Coding Help
Could you change the print_r debugging code to the following so that the different arrays are distinctly identified - echo '<pre>'; echo "Post:" print_r($_POST); echo "Session:"; print_r($_SESSION); echo '</pre>'; Also, what does a phpinfo(); statement show for the register_globals setting? -
4) You have output buffering on (either in your script or in your php.ini) and you are redirecting to a different page (any output your script creates is discarded when the redirect occures.)
-
Some possible reasons - 1) Your code contains a fatal php parse error or a fatal runtime error and your code is not being executed. 2) The code where your echo statement is at is not being executed (it's inside of a conditional statement that evaluates as false.) 3) The code where your echo statement is at is inside of a HTML tag or inside of a HTML form element and the echoed output only appears in the 'view source' of the page in your browser.
-
What value are your empty lastnames? A null or an empty string? Edit: Assuming a NULL value, use this query - SELECT * FROM `users` ORDER BY IF(lastname IS NULL,0,1) DESC, mydatetime
-
There's nothing to explain. You are calling a mysql_fetch_ statement before the start of your loop, so of course the first row in the result set is missing. It has already been fetched. Computers only do exactly what their code tells them to do.
-
Neither code you just posted contains any logic that has an added "or die(mysql_error())" on the end of the mysql_query() statement that would be outputting a "Query was empty" message. Your original problem, the "mysql_num_rows() expects parameter 1 to be resource, boolean given" error message is because your query failed to execute at all due to an error of some kind (a connection problem, a sql syntax problem, a misnamed table or column.) Adding the "or die(mysql_error())" that TeNDoLLA suggested, on to the end of your mysql_query() statement would have told you why the query is failing. If you actually added that and you got a "Query was empty" message, it didn't come from the code you have been posting. If the "Query was empty" message is your interpretation of what you have seen in front of you, sorry but we cannot help unless you post actual error messages and actual code that produces those error messages.
-
If you are getting an error message "Query was empty" from mysql_error(), it means that your php code is not supplying any sql query at all to the mysql_query() statement. You either have a wrongly named variable or an empty string and the code you posted at that start of this thread cannot produce a "Query was empty" error. Post the actual code forming the sql query and executing the mysql_query() statement that is producing that error message.
-
Your problem is due to the old and outdated use of the $HTTP_HOST and $SCRIPT_NAME variables in your code. Those were depreciated in php4.1, over 9 years ago, in favor of $_SERVER['HTTP_HOST'] and $_SERVER['SCRIPT_NAME']
-
Without a specific example of what you are doing in your code, I am guessing that you are using a URL in an include statement. That DOES NOT include the php code/data into the current script. It only includes any output from that file, the same as if you browsed to that file. You need to include php code/data using a file system path/filename.
-
Your original code contained an extra $nt=mysql_fetch_array($rt); statement that was fetching and discarding the first row from the result set. Even though WebStyles posted a much simplified and commonly used way of executing a query and looping over the result set, I doubt that you changed all your code to use just those lines of code. Post your current code, from the line where you are executing the query through to the end of the loop you are using to iterate over the result set.
-
To allow larger files to be uploaded, you can typically set the upload_max_filesize and post_max_size on your web hosting, either in a local php.ini (when php is running as a CGI application) or in a .htaccess file (when php is running as an Apache Module.)
-
I recommend that you find a php class that does this so that you can pass it your basic query and it provides the methods/properties necessary to add pagination into your existing script.
-
There's nothing wrong with your posted code. Your actual code must be modifying the $bathrooms variable inside of the loop.
-
Your code (which appears to be based on the w3schools code) is not really performing any working error checking. Use the following code to find out why the upload is failing and give your visitors a more enjoyable experience (when validating user supplied data, you need to provide them with as much information as possible when the validation fails) - <?php include('SimpleImage.php'); // detect if a form was submitted if($_SERVER['REQUEST_METHOD'] == "POST"){ if(empty($_FILES) && $_SERVER['CONTENT_LENGTH'] > ini_get('post_max_size')){ // the files array is empty and the size of the post data is greater than the max echo "The uploaded file size: ". number_format($_SERVER['CONTENT_LENGTH']) . " bytes, exceeded the maximum permitted post size: " . number_format(ini_get('post_max_size')) . " bytes."; } else { // test for uploaded errors if ($_FILES["somefile"]["error"] > 0){ // in a real application, you would want to display a helpful user messages instead of a code number echo "An upload error occurred, Code: " . $_FILES["somefile"]["error"]; } else { // no upload errors, perform your validation tests here... $types = array("image/jpeg"); if(!in_array($_FILES["somefile"]["type"],$types)){ echo "The file type: {$_FILES["somefile"]["type"]} is not a permitted type. Only ". implode(',',$types)." are allowed."; } else { $max_size = 50000000; if($_FILES["somefile"]["size"] >= $max_size){ echo "The file size: ". number_format($_FILES["somefile"]["size"]) . " bytes, is greater than the permitted size: " . number_format($max_size) ." bytes."; } else { // an image was uploaded correctly, without any errors, of the permitted type and file size, process the file here... $image = new SimpleImage(); $largeimage = new SimpleImage(); $image->load($_FILES["somefile"]["tmp_name"]); $largeimage->load($_FILES["somefile"]["tmp_name"]); $w = $image->getWidth(); $h = $image->getHeight(); if ($w > $h) { $aspect = 'w'; $largeimage->resizeToWidth(798); $image->resizeToWidth(225); } else { $aspect = 'h'; $largeimage->resizeToHeight(798); $image->resizeToHeight(225); } $image->save('newuploads/small.jpg',IMAGETYPE_JPEG,75,null); $largeimage->save('newuploads/large.jpg',IMAGETYPE_JPEG,75,null); } } } } } ?> The most likely problem is that different browsers (and different versions of the same browser) send different type information for the same file. If so in your case, you need to add an array entry to the $types array in the above code to match the actual type information that is being sent by the offending browser.
-
Call to undefined function: mail()
PFMaBiSmAd replied to edwardw's topic in PHP Installation and Configuration
If you are getting the same error message (undefined function: mail()) on different systems, it is likely that your source file is corrupted and either has some non-printing characters or some non ASCII encoded characters as part of the 'mail' name. I would delete and retype the 'mail' name along with a few characters before and after that in the source code. -
Call to undefined function: mail()
PFMaBiSmAd replied to edwardw's topic in PHP Installation and Configuration
Does the output from a phpinfo(); statement contain any reference to 'mail' (search on the page using your browser's find function.) What exact problem did you originally have when trying to build/install php5? -
Use type="submit" buttons don't actually do anything unless you attach an event to them.
-
See this post - http://www.phpfreaks.com/forums/index.php?topic=340400.msg1604736#msg1604736