-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
new install of xampp ... str_pad() expects parameter 4 to be long
PFMaBiSmAd replied to dsdsdsdsd's topic in PHP Coding Help
After you fix what is causing each warning/notice/error, the issue in most of these cases is simply that your error_reporting/display_errors settings where hiding all the warnings/notices/errors. Your code was always producing the warnings/notices/errors but you did not see them. For the specific example you posted, your code wasn't producing the intended result the way you had it (with the quotes), so it is likely that a lot of your code will start doing what you expect after you fix what is causing each warning/notice/error. -
Your link is currently missing the & that separates the different parameters. I recommend just forming and outputting the entire link at once - echo "<a href='../main_scripts/db_insert_assignment_question.php?question_id={$row['question_id']}&assignment_id={$_GET['assignment_id']}'>Add Question</a>";
-
There's a note in the array_search documentation that will help. You need to test if the value is exactly (===) or not-exactly (!==) a FALSE value.
-
^^^ You are assigning the results that GetUser() returns to the variable named $User, not $UserInfo, You would need to use - echo $User['forename']; echo $User['surname'];
-
The interesting thing about programming is you can try anything you want in just a handful of seconds and observe for yourself if it does what you expect or not. You don't have to guess, assume, or take someone else's (mistaken) word for what works or does not work.
-
You are not fetching the data that mysql_query() returns (hint it returns a result resource, not a data value.)
-
help with using variables to SET mysql UPDATE
PFMaBiSmAd replied to thameslink's topic in PHP Coding Help
Actually, STR_TO_DATE() expects a STRING as the first parameter and since you are providing a literal value in the query, you need single-quotes around it - STR_TO_DATE('$product_sku','%Y-%d-%m') Without the single-quotes, it is taking 2011 - 4 - 2, which is 2005 -
help with using variables to SET mysql UPDATE
PFMaBiSmAd replied to thameslink's topic in PHP Coding Help
CURDATE() returns a mysql DATE value and STR_TO_DATE() returns a mysql DATE value. You can directly compare what STR_TO_DATE($product_sku,'%Y-%d-%m') returns with a CURDATE() value. -
If you get and GROUP the rows using the MIN() value, the groups HAVING a COUNT() of 1 would match what you are looking for.
-
The previous problem (the mysql error) was because $editid was empty and since the query expected a numeric value in $editid, the result was a sql syntax error. Your code should be validating ALL external data, but more seriously, the code that is supposed to be putting a $_GET['editid'] onto the end of the URL is not working. The latest problem is because you changed the query to begin and end with single-quotes and the php variable $editid inside that query is no longer being replaced with the value in $editid.
-
help with using variables to SET mysql UPDATE
PFMaBiSmAd replied to thameslink's topic in PHP Coding Help
You can only do greater-than/less-than comparison of dates when the fields making up the dates are ordered, left to right, most significant digit (year) to least significant digit (day) (month would go in the middle.) Your '%Y-%d-%m' format does not fit that definition and cannot be compared greater-than/less-than. -
You would want to use the entered 'name' (Value 1, Capacity lbs, ...) as the Label for a field, not necessarily the field name you use in the underlying code. For a dynamically generated form based on user defined fields, you could generate your own field names and associate them with the correct field. Only your form and your form processing code would care what the actual field names are.
-
You would never use a cookie with a simple value in it to indicate someone is logged in because anyone could set that cookie themselves and become logged into a site. You can use a cookie to identify someone (using a unique and hard to guess value), but you must only use a value stored on the server to indicate if they are logged in.
-
^^^ Based on where your <?php tag is at, you have a tab or some space characters before the <?php tag. You cannot output any characters to the browser before a session_start() statement.
-
In a query, why does $_SESSION[cid] work, but $_SESSION['cid'] not work?
PFMaBiSmAd replied to darp's topic in MySQL Help
The php parser needs a little help delimiting array variables when used in a string. If you put {} around $_SESSION['cid'] it will work without producing an error inside of a string. -
How to get PHP to auto-create Months/Years
PFMaBiSmAd replied to Call-911's topic in PHP Coding Help
You can execute a select query to get the distinct year/month-name values based on your datetime values. Should work - SELECT DISTINCT YEAR(datetime_column) as yr, MONTHNAME(datetime_column) as mn FROM your_table ORDER BY datetime_column DESC -
Your $sel query is producing an error because you don't have any single-quotes around the $player string data in the query. You need to use error checking and error reporting logic on all queries you execute.
-
Can not get $_Post, even though I Can Print_r it
PFMaBiSmAd replied to dpw134's topic in PHP Coding Help
Check your spelling. -
Have you searched for and/or asked about this problem on the Webspell CMS site? If the problem is session related, then either - 1) There are too many session data files in a folder (the max the operating system can store in one folder) and/or session garbage collection is not running to clean out old data files or the session data is being stored in a database and there are is no index and/or old records are not being cleaned out or a query error is occurring or the database server is experiencing a problem, 2) The disk where the session data files are being stored is full or is experiencing disk errors, 3) The session data file that is being read when you attempt this is corrupted or a huge amount of data is being stored in the session data files or something about the specific session data is causing the code to loop forever (does the page eventually load or do anything after a 30-60 second timeout?) 4) About 6-12 other things that could be causing the problem, but without any specific symptoms to pin down which direction to look, no one can really specifically help with. You haven't exactly provided any specific information in this thread that would help pin down what is happening. Have you checked that none of your script files have been altered by a hacker? Have you looked at where your session data is being stored to see if there is anything unusual about how many session data files there are or what size they are or how much free space there is on that disk? Have you checked any of the server logs to see if there are relevant error messages?
-
mysqli_error() expects exactly 1 parameter, 0 given
PFMaBiSmAd replied to genzedu777's topic in PHP Coding Help
This is like the third thread where you have had this same problem with leaving out the link parameter in the mysqli_error() statement. -
Or you could put it into a clothes dryer with one of those nice smelling dryer sheets and let it tumble around for a while. That would get any loose food crumbs out as well.
-
Two MySQL connections, only second one works.
PFMaBiSmAd replied to Jerred121's topic in PHP Coding Help
When you don't supply a mysql connection link in the mysql_xxxxx($a,$link) statements, they use the last link that was created. If you have code that requires more than one mysql connection and you want that code to ALWAYS work, with the least amount of effort on your part, you would need to use the correct connection $link in the code that needs it. If that code happens to be inside of a function definition, simply pass the connection link into the function as a parameter when you make the call to that function. -
Two MySQL connections, only second one works.
PFMaBiSmAd replied to Jerred121's topic in PHP Coding Help
Everything inside of a function definition is 'local' to that function. This is so you can write functions that do whatever is necessary to accomplish the task you have defined for that function without needing to keep track of the variables you use inside that function. You would need to add a third parameter to your function definition to serve as the mysql $link and then pass the mysql connection link variable into the function when you call your function - function fncGrabNemsis($ele,$val,$local){ -
@drisate, Nesting functions like that prevents you from doing any error checking and error reporting that a real application needs to do. That's the opposite of what should be done.
-
The use of or die() in the above line of code causes the line to be evaluated as a logical expression and the whole line/expression returns a TRUE or 1 value, which is what is echoed. You are basically echoing the fact that $lastid = mysqli_insert_id($dbc) was successful. Removing the or die() would be your best bet (the place where someone suggested using that was specifically for troubleshooting why a mysqli_query() statement was not working.)