-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
The short <? opening php tag is not always enabled and you won't always be on a server where you can enable it. All code, especially posted, published, tutorials, examples, ... should use the full opening <?php tag.
-
How To Resolve “Notice: Array To String Conversion In”
PFMaBiSmAd replied to copperspeed's topic in PHP Coding Help
The issue are the [] you have around the array entry in - value=$brgObj->fetchOneBrg(array(['id'=>$ststres[ststval].to_id]))} That's making an array of array(s) and when you do the array_values, you are getting not an array of the values, but an array of the original nested array, which when accessed produces that notice (because of the 'Array' keyword that is returned), but actually supplies an array to the ->execute() method with a key/value that works (tested.) Remove the [] -
What does the opening php tag in the code look like? <? or <?php Have you tested if any php code in a .php file works?
-
The code you posted cannot possibly produce the error you are getting, ... string given ... unless your actual code is something like - $query_num_rows= mysql_num_rows($query);
-
Sessions And Cookies To Log Into A Website
PFMaBiSmAd replied to kevinkhan's topic in PHP Coding Help
You shouldn't expect a session to last longer than one browser session, since you would need to extend the session garbage collection maxlifetime setting to get the session data files to persist for the same amount of time you have set the session id cookie to persist. This would leave a session data file on the serve for every logged in user for the longer amount of time that you have chosen. A 'remember me' feature normally works by generating a unique id (similar to a session id), then store that id in a cookie and store it in the user's row in your user table. When someone visits your site and they have a 'remember me' cookie, with a properly formatted unique id in it, you use the unique id from the cookie to find the corresponding row, if any, in the user table to identify who the visitor is. -
What you tried was to add error checking and error reporting logic for your query using trigger_error(). While you do need to always check if statements like query/file operations fail, that's not what I suggested. And since what trigger_error reports and displays is dependent on the error_reporting/display_errors settings, you are still in the dark, or in this case the 'white screen', concerning the reporting and display of errors in your code. You need to set the error_reporting/display_errors settings, to the suggested values, in the master php.ini on your development system (so that even parse errors in your main file will be reported and displayed.) You can also set them in a .htaccess file (when php is running as an Apache Module), in a local php.ini (when php is running as a CGI application), or even in your script (which won't show any fatal parse errors in the main file since your code never runs to change the settings when there is a fatal parse error in the main file.)
-
mysqli_real_escape_string REQUIRES the mysqli link resource as the first parameter. Your code would be producing an error at that statement if your error_reporting was set to E_ALL and display_errors was set to ON. Don't go any further until you set the error_reporting/display_errors settings as suggested.
-
Sorry to be blunt, but your code is a gross misuse of a class/oop and variable variables, to the point that you don't even know the variable name that your query's result resource is in. Hint: it's not in $checkfirstime. One of the points of using classes/oop is the code and data needed for any particular purpose is encapsulated/self-contained. By using the global keyword and a variable variable on top of that, you are breaking that encapsulation/self-containment. Another point of functions/class methods is that they return the result they produce. Your ->query() method should return the false/true/result resource and you assign that to a program variable - $result = $database->query(.....); Forget you ever saw the global keyword and variable variables. They result in code that you won't be able to troubleshoot simple problem with (and would get you fired from a large project where unexplained values changing due to them will cause a bunch of wasted time for the team working on the project.) -------------------------------- Some hints for your class - 1) The type should be stored in a class property. The rest of the class code uses that stored value. 2) You should pass the database connection details/database name into the class, either in the constructor or using a specific 'setter' class method call. 3) The database link resource should be stored in a class property, i.e. $link (there's no need to have separate $mysql, $mysqli, $mssql since any one instance of your class can/should only operate on one database type.) 4) The query method should return the result from the query.
-
Problem With The 197 Columns In Uploading A .csv File
PFMaBiSmAd replied to mageamida's topic in PHP Coding Help
See the following link for the maximum amount of columns/data that can be stored in one row - http://dev.mysql.com/doc/refman/5.5/en/column-count-limit.html If you had some error checking logic for your query statement, you would be getting an error that indicates why your query is failing. As to the number of rows being inserted before the code randomly stops, your logic is foo-bar. Any time $data[0] evaluates as a FALSE value (0, '0', or an empty string) the loop will stop. You should be using a while(){} loop that will test if $data is false or not. There's an example at this link - fgetcsv -
Of course, start by really reading all the parts of the error message. It tells you where you are sending the output at on your page that is preventing the header from working. Then you identify what that output is and prevent it, usually by rearranging your logic on your page so that you determine if you are going to redirect or stay on the page first, then only send output to the browser if you are going to stay on that page.
-
Is There A Way To Search An Entire Table For Wildcard Word Or Phrase
PFMaBiSmAd replied to TecTao's topic in MySQL Help
I've seen people concatenate the columns together and use that on the left-hand side of a LIKE '%%' comparison. -
The output from your sessionstart.php file doesn't match the posted code above. Are you sure what's actually in that files? Could you post the sessionstart.php file again. Are you using any foreign language characters (non ASCII) or any control/non-printing in the 'test' array index name, so that what is actually showing in your file isn't what is being shown in your posts in the forum? We have seen times where the copy/paste into the forum post produces 'clean' code that works, but there is something in the actual code file that doesn't match. Try deleting the ['test'] portion of the $_SESSION variable and retype it. When I visit your two pages, I get the same session id cookie value on both pages. That indicates that the session_start on both pages is starting/resuming the same session data, but the ['test'] index isn't present on the 2nd page. There may be an issue with the server where the file name is being created, but the actual file isn't (there is typically a php error when this type of thing occurs.)
-
Edit to the above: you would actually store accessories as their own item in the cart, with the id of the accessory as the main array index and have a sub-array under that array entry for each accessory that relates it to the main item it is an accessory for.
- 5 replies
-
- cart
- cart design
-
(and 2 more)
Tagged with:
-
@gckmac, The 'Report' button in a post is for reporting problems with a post, not making a replying to the post.
-
To store data for any id as you have asked will require that you change the definition of your cart from a comma separated list of id's to an array of arrays, where the 1st dimension array index is the id and you store the additional information (quantity, condition, accessories) for each selection of that id as a sub-array. The accessories would also be an array of arrays with the accessory id, quantity, condition,... of each accessory selected. Doing this will also greatly simplify your existing code because you won't need to copy, explode, loop over the contents of the cart, and implode it every time you need to do anything to it. You will just reference the correct array element by using the id as the index - $_SESSION['cart'][$id] Also, you should not have any database queries inside of loops. You would use one query that gets all the rows you want at one time, then loop over the rows the query matched.
- 5 replies
-
- cart
- cart design
-
(and 2 more)
Tagged with:
-
This is the definition of a computer based template - You should only have one header.tpl file that determines the format/layout of your header. You would set the title and description values that are put into the header.tpl template, not select between two different template files.
-
It's more likely that you introduced a literal character or the BOM (Byte Order Mark) at the start of your file and that's what is causing your session variables to no longer work, and in the case where they started working again, that character/BOM got removed or didn't transfer when you copied file(s) to a server. Do you have php's error_reporting set to E_ALL and display_errors set to ON so that php will help you by reporting and displaying all the errors it detects? You are likely getting php errors that would point to why your session variables are not working. Also, echoing a $_SESSION variable on the page where it is set, doesn't mean that variable is part of a session if the session_start() statement on that page has failed. In this case, the $_SESSION variables are only local to the page they are set on.
-
How To Use Javascript Variable In Smarty Section Loop
PFMaBiSmAd replied to safey's topic in Javascript Help
Javascript code and its variables run/exist in the browser after the page has been sent from the server to the browser. Smarty template logic and its variables run/exist on the server when the page is requested. Smary can produce and output javascript on a page, but the only thing that javascript can do to a server is make a http request. To do what you are asking would require that you use AJAX to make a http request to a page on the server to pass the value in u as a GET or POST parameter, then send back the resulting html from the smarty logic and insert it into the DOM on the page.- 1 reply
-
- smarty
- javascript
-
(and 1 more)
Tagged with:
-
^^^ That's not a line in your query. Those are lines of php code. This is your error message - This is the code producing the SQL query statement - $sql = "INSERT INTO u_user(userID,groupCode,userName,password,email,userStatus) VALUES ( '".$_POST['groupCode']."', '".addslashes(strtoupper($_POST['userName']))."', '".addslashes(strtoupper($_POST['password']))."', '".addslashes(strtoupper($_POST['email']))."', '".addslashes(strtoupper($_POST['userStatus']))."', )";
-
Sessions...this May Help Others Dealing With The Issue
PFMaBiSmAd replied to dpiearcy's topic in PHP Coding Help
There's nothing inherent in a header('location: ....') redirect statement that would cause sessions to not work. It's more likely that your actual redirect was changing the host-name (www. vs no-www) or the path after the domain (and your session cookie parameters are net setup to match variations in the host-name or path) or you have some code on the page after the header() statement that is clearing the session variable(s) while the browser is requesting the new page (the header() statement doesn't stop php from running, it only sends a header to the browser.) -
Look at the end of line 8 in your query, for an extra character that implies there are more data values.
-
What's in $_POST['Item'] and the `item` column? If it's the item name/title, you would instead post the item id and use that. There's no reason to pass/store more than the identifier of an item.
-
Do you have php's error_reporting set to E_ALL and display_errors set to ON so that any session related errors will be reported and displayed? You could have a session.save_path problem or a header error due to your file's character encoding containing the BOM (Byte Order Mark) characters.
-
Validate Textbox Before Continuing To Paypal Payment Page
PFMaBiSmAd replied to Classico's topic in PHP Coding Help
Setting the price in a button or hidden form field is only 'safe' for donations, where the visitor is the one who set the amount he is willing to donate. For everything else, you need to set the amounts in your paypal account for each item (I don't recall exactly what this is called on the paypal side of things.) -
The syntax definition for an INSERT ... ON DUPLICATE KEY ... query is - INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [iGNORE] [iNTO] [i]tbl_name[/i] [([i]col_name[/i],...)] {VALUES | VALUE} ({[i]expr[/i] | DEFAULT},...),(...),... [ ON DUPLICATE KEY UPDATE [i]col_name[/i]=[i]expr[/i] [, [i]col_name[/i]=[i]expr[/i]] ... ] For your specific information - INSERT INTO tCurrentOrder (Item, Quantity, Date) VALUES ('{$_POST['Item']}',1,now()) ON DUPLICATE KEY UPDATE Quantity = Quantity + 1