-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
This code is kicking my butt. Help! Functions --
PFMaBiSmAd replied to Jax2's topic in PHP Coding Help
Have you determined that $recipeID has a value at all at any point your code? To pin point the location of the problem in your code, you must determine at what point $recipeID has an expected value and at what point it does not. -
This code is kicking my butt. Help! Functions --
PFMaBiSmAd replied to Jax2's topic in PHP Coding Help
Using the 'global' keyword inside the function actually does the opposite. It makes the function 'hard-wired' to use whatever value is in that variable and you cannot use more than one instance of that function on your page without needing to remember to setup that variable (adds extra code and extra work for the programmer to remember to do this for each function call) before each function call. You should only pass values into functions using function parameters (like you are already doing with the $link and $num values.) Can you imagine what php would be like as a programming language if it brought values into all its' built-in functions using the global keyword. They would all need to be uniquely named so that you could use more than one function in a row without them conflicting with each other and it would make for a programming nightmare because the programmers would need to remember or lookup ALL the names of the variables they needed to set before calling a function. As to your current problem, you have not shown how you are setting $recipeID or including shoutbox.php, so it is simply impossible for anyone in a forum to help with why $recipeID does not have a value when your function is called. -
Since the data is contained in the URL, the problem is because the page is being requested twice and it receives the data twice. Different browsers do this for different reasons and some url rewriting and even how hosts setup accounts can cause this. Most of the causes for a double page request are out of your hands, so the best method to prevent this is to detect and prevent duplicate data entry. If you can, setup unique indexes in your table(s) so that duplicate data will be prevented. You can also set a session variable to prevent the page from processing more than one time.
-
If the data is present in both sets of records being inserted, it is likely that your form is submitting twice. Do you have an javascript that is submitting the form (along with the browser's normal form submission)? What is your form? Also, what is the whole code on the page, because you may have other queries being executed on that page that are causing the problem (I notice that you don't have an exit statement after the header() redirect so any further code on that page is still being executed while the browser performs the redirect.)
-
How do I recall a variable variable in PHP?
PFMaBiSmAd replied to langemarkdesign's topic in PHP Coding Help
This syntax you are using to 'set' the variables does not work in any version of php - $to_name_ . $num = "Fred"; You should just use HTML array variables for your form fields - http://www.php.net/manual/en/faq.html.php#faq.html.arrays You can then just use php's array functions (like a foreach() loop) to iterate over the data. Using variable variables is three times slower than using an array. Also using variable variables is taking twice the memory, you are processing the data an extra time just to produce the variables, and the code is more complicated. -
If a file is not selected, you will get an upload error value of 4. I recommend examining and using some for the error checking logic in this post - http://www.phpfreaks.com/forums/index.php/topic,292945.msg1386624.html#msg1386624
-
If clause code returning unexpected results
PFMaBiSmAd replied to SaturdayNightSpecial's topic in PHP Coding Help
Your code is doing exactly what your program logic and the data is telling it to do. For the supplied trkname, you are getting the values echoed that match the data in that row in your database table. -
If clause code returning unexpected results
PFMaBiSmAd replied to SaturdayNightSpecial's topic in PHP Coding Help
To get help with what your code is (or is not) doing, you need to post your code, from the point where the query statement is being formed through to the last line of the code that is producing the output that is not working. You probably have an if(){} statement that is overwriting the value instead of testing the value. -
If clause code returning unexpected results
PFMaBiSmAd replied to SaturdayNightSpecial's topic in PHP Coding Help
Umm. From your first post, the values that are not working are the - $row_rs_track_details['sat'], $row_rs_track_details['tues'], ... values, so I'm not directly sure why you are trying to echo the $row_rs_track_details array because you would need to be using print_r() to do that (i.e. what thorpe just posted.) I suspect that your code is doing exactly what you designed it to do and that there are no "Y" values stored in the columns for the days that are 'not working'. You have not exactly provided any evidence showing what you are getting and what you should be getting. -
Creating a self-signed SSL certificate is fine for testing or when you have control over the clients using the certificate (such as within a corporation), but for general purpose use you will need a certificate that is signed by a trusted certificate authority so that the browser warnings concerning using a self-signed certificate don't scare away your visitors.
-
supplied argument is not a valid MySQL result resource? Help
PFMaBiSmAd replied to decneo's topic in MySQL Help
Actually, that means that there was a typo in the post, which you should have been able to figure out because all the mysql functions start with mysql -
If clause code returning unexpected results
PFMaBiSmAd replied to SaturdayNightSpecial's topic in PHP Coding Help
Have you echoed the values that are not working so that you know exactly what is in them at that point in your code? What exactly are the Friday, Saturday, ... values that you are echoing? Are those defined constants? -
How would a human detect a change in a value? He would remember the previous value and when the new value is not the same as the last value, it changed - $last_value = NULL; // remember the last value (initialize to a value that will not exist in the data) while (list($eventname,$festivalid,$image,$thumb,$description,$username) = $result->fetchrow()) { if($last_value != $festivalid){ $last_value = $festivalid; // remember the new value // do any special processing here when the value changes ... } // the rest of your code inside the loop }
-
Yes, fix the code. Also, your xampp system either has display_errors set to OFF or error_reporting set to less than E_ALL and that specific problem in your code was being hidden. A lot of the all-in-one xammp packages simply are not setup correctly as development systems to report and display all php errors, causing a lot of lost time when code is moved to a live server.
-
Read the definition of what the second parameter is - http://php.net/mysql_fetch_array
-
http://www.phpfreaks.com/forums/index.php/topic,292945.msg1386624.html#msg1386624 The code at that link will check for and display upload errors. At the point where it has a the comment // put any type, size, file name/extension, or content validation here, you can put in any of the application level validation you need before you use move_uploaded_file() or put some of the uploaded file information into a database query statement.
-
Your files are probably failing to upload and your code is not checking for any of the possible upload errors before accessing any of the uploaded data. Do you have any error checking logic in your code?
-
You don't have an echo statement as part of the else{} code so nothing will be output to the browser. You can also simplify the code (eliminates duplicate code) that is inside of the while(){} loop - if ($Year != $DataArray["Year"]) { echo $DataArray["Year"]."<br />"; $Year = $DataArray["Year"]; } echo $DataArray["Production"]." - ".$DataArray["Role"]."<br />";
-
The code up to the mysql_query() statement is attempting to UPDATE an existing record in your members table. The code after that point is from a log in script. Updating a record and logging someone in are two different tasks and your code really does not make any sense. What are you trying to accomplish in that code?
-
Return row's with max (lastest) update time for a product
PFMaBiSmAd replied to GregL83's topic in MySQL Help
http://dev.mysql.com/doc/refman/5.1/en/example-maximum-column-group-row.html -
The most obvious problem with your code is that it relies on register_globals. It is 8 years out of date and should have been updated or replaced long ago. Your web host must have finally (8 years too late) disabled the register_globals setting to prepare for upcoming php6, were register_globals have been completely removed.
-
If you search for any portion of that error message you will find that it means that your query failed to execute due to an error. For debugging purposes only (remove it after you are done), echo mysql_error(); on the next line right after the line with the mysql_query() statement.
-
We cannot really help you with what your code is doing when you don't post your actual relevant code. It just wastes everyones time.
-
What does a 'view source' of the page in your browser show?
-
If that is all the relevant code, then there IS only one matching row. What does echoing mysql_num_rows($resultWriters); show?