-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
This topic has been moved to Third Party PHP Scripts. http://forums.phpfreaks.com/index.php?topic=364326.0
-
Because each actual image is static, you can get a 'signature' for them (filename, filesize, and/or actual binary data of the image) that lets you map the question to the correct image. You would need to dynamically alter the images each time they are output, varying the size/color/name... so that any one actual image has a random signature each time it is used.
-
The problem is due to conversion of the number to binary. Some fractional numbers cannot be represented exactly as a binary number and you end up with a loss of precision. To avoid this conversion error, you need to store and operate on the numbers as BCD (binary code decimals), the same as what a calculator does. See the following bc math extension - http://php.net/manual/en/book.bc.php
-
I'm going to guess that your UPDATE query is failing. You don't have any error checking/error reporting logic in your code to get it (your code) to tell you if and why a query might be failing. For debugging purposes, use var_dump($sql); right after the line with the UPDATE query and see what value the mysql_query statement returned. If it returned a FALSE value, use mysql_error to find out why the UPDATE query is failing.
-
The DOC for that 'parser' indicates it just wants an expression that produces an assignable value. The code probably does use eval internally to accomplish that, but that is not directly an issue. The OP is apparently testing using eval, but since the {item.xxx} is the parser's syntax to indicate data values and is not valid php, directly using eval should produce an error. I'm going to guess the following might work - {{date('Y-m-d H:i:s', strtotime(str_replace('/','-',{item.StartDate})))}}
-
I would go the str_replace route to get strtotime to work with that format - $dateStr = str_replace('/','-',$dateStr);
-
I am getting loose results from FROM_UNIXTIME
PFMaBiSmAd replied to Monkuar's topic in PHP Coding Help
Are you sure your column isn't a Mysql TIMESTAMP data type? -
Php: Keeping selection after submission in a for form data
PFMaBiSmAd replied to LoolKovsky's topic in PHP Coding Help
Your code is not using the $i variable when you have it inside of a single-quoted string, because php variables are only replaced with their value inside of a string when the string is using double-quotes. You should also always use full opening <?php tags, since the short opening tag <? are not always enabled and you might not have the ability to enable it on any particular server. -
Help with error about printing name from database in title tag
PFMaBiSmAd replied to thugsr's topic in PHP Coding Help
Both the error message and the work-around that you used to stop the error indicate that you are including the file twice. -
What does the 'view source' of the blank page show? What exact URL are you entering in your browser for that page?
-
Since you are using a prepared statement, in general, you would need to do it the way you came up with. I would form an array with keys/values and do this all in one simple statement - $myarray[] = array('name'=>$name,'address'=>$address,'town'=>$town);. If you have php5.3+ and are using the mysqlnd driver, you can convert the result from a prepared statement into a mysqli result set using - http://php.net/manual/en/mysqli-stmt.get-result.php This will allow you to use traditional mysqli fetch statements to iterate over the result set.
-
Help with error about printing name from database in title tag
PFMaBiSmAd replied to thugsr's topic in PHP Coding Help
You are either including the file twice or you are including it inside of a loop. Also, don't use the global keyword (ever.) Using it outside of a function doesn't do anything, except to waste processing time. Using it inside of a function for your connection variable makes your code is hard-coded to only be able to use that one connection. You should pass variables into a function as a call-time parameter and return any result from your function to the calling code, to make your function general purpose. -
This topic has been moved to Application Frameworks. http://forums.phpfreaks.com/index.php?topic=364215.0
-
The right direction to take would be to put back in the update logic you had and to find and fix what was causing the error in it.
-
I recommend a rewrite as well. The posted code is apparently processing a form submission. However, it has no logic to test if a form was even submitted; it is not validating any of the submitted data (the code shouldn't even get to the point of executing the query when the $studentid is empty); and it is not doing anything to prevent sql injection/query errors due to unexpected/hacked data values.
-
The form processing code that was posted should not be used, ever. Not only does it not address how to process the array of multiple uploaded files, it is derived from the w3schools site and since it tests for upload errors AFTER it has tried to use the uploaded file information, it will never correctly report upload errors. See example #3 at the following link for how you would loop over the resulting array of uploaded files, testing for upload errors first, then only using the uploaded file information when there were not any upload errors - http://us.php.net/manual/en/features.file-upload.post-method.php You would insert your validation logic right before the move_uploaded_file statement in the php.net example code.
-
Problems Converting WAMP Site From Localhost To Domain
PFMaBiSmAd replied to X51's topic in Other Web Server Software
The code was also producing that error on the server, but the error was being hidden by the error_reporting/display_errors settings. Php was still detecting that problem every time the code runs, but it was not being reported and/or displayed and if php was actually logging the error to the error log file, you are gradually building a humongous error log that makes it difficult to find actual errors that might be occurring when your code runs. All code should not produce any kind of errors during its normal execution. Only for abnormal things, such as a legitimate visitor feeding your script unexpected values that you didn't take into account or a hacker trying to break into your script, so that you can find and fix actual problems. Unless you are trying to develop a general purpose script that would work on a minimum php/mysql version, your development system should have the same version of php/mysql as your live server so that you don't waste time making changed just due to the version differences. -
You can use a FIELD() statement in a query to produce any custom ORDER BY term - ORDER BY FIELD(your_column, 2,3,1)
-
The error is because you are calling a mysql_query statement a second time with a variable as the first parameter (the query statement) that does not exist.
-
Autoincrement field does NOT use the next available value
PFMaBiSmAd replied to phdphd's topic in MySQL Help
Then the most likely cause is - What's your code that is forming the SELECT query through to the point where you are executing the insert query? Do you have error checking logic in your code to detect and report when a query fails? What approximate quantity of queries are you executing and are they enough to account for the number of auto-increment values that are used/skipped? 10s, 100s, 1000s? It's also possible that your code is being requested multiple times by the browser and/or you have code that is inserting, then deleting rows, thereby using up auto-increment values. Do you have any header redirect statements that don't have exit/die statements after them to prevent the remainder of your code from running while the browser requests the target of the redirect? You could be failing to stop the execution of your php code and it goes on to delete rows that were just inserted. The short answer is, there are multiple things that could be causing such a symptom and to either confirm or eliminate the code, the most common cause of unexplained computer behavior, as the cause, it takes seeing all the code that reproduces the symptom. -
Autoincrement field does NOT use the next available value
PFMaBiSmAd replied to phdphd's topic in MySQL Help
The times I have seen an auto-increment field 'skip' values is when an insert query either produces an error or you have a query that intentionally ignores errors. The query still gets the next available auto-increment value, but does not use it. Any chance your code is intentionally setting the auto-increment value in a query and you have a logic error that is causing this or perhaps you are mass inserting data that already exists and the insert query is getting auto-increment values but not using them (the next successful insert would use the next available one and would appear to skip values) or perhaps a hacker has been feeding your script data values that cause the query to fail and get/use up auto-increment values.