-
Posts
5,451 -
Joined
-
Days Won
175
Everything posted by mac_gyver
-
yes there are programmers here who can help you with problems you encounter when you create your application. however, programming help means you are doing the programming, we only help when you have a problem or error that you cannot solve. we can only help you when you post specific questions or specific errors you get when you run your code. just asking if someone can help is not a specific programming question. lastly, we are not here to do your assignments for you. if you are completely lost about how to approach your assignment, you need to speak with your instructor, because they wouldn't have given this assignment without first having presented the groundwork needed to at least start on the assignment.
-
setting up contact form for sending emails
mac_gyver replied to MelissaSass's topic in PHP Coding Help
producing an application, in any programming language, requires that you go through a learning curve to - 1) learn the programming language, 2) learn how to write program logic that does what you want (i.e. to take the inputs you have, perform the processing you want, and produce the intended output/result), and 3) learn about and use things like security, validation, error checking/reporting so that it is a complete, safe, and useful application. you are either going to need to take the time and effort to learn and gain experience so that you can do this yourself, find a solution that does this for you, or hire someone to do this for you. -
setting up contact form for sending emails
mac_gyver replied to MelissaSass's topic in PHP Coding Help
be advised that a LOT of the php code posted (and for sale) on the web is crap. just enough effort was put into it to get it to run and look pretty, but it often lacks security or any useful error checking/error reporting. so, you can end up with a script that allows hackers to take over your site (or in this case send their email through your server) or of spending as much time trying to get something to work that it would have taken you to write it yourself. edit: the script you linked to is the general idea, but without seeing the code for it, there's no telling how good or bad it is. -
you will need to narrow down the problem and post just the relevant code. when you do post just the relevant code you need help with, YOU will need to FULLY document what each variable means and what data is in it. the code you have is using non-descriptive variable names, like $js, $o_MSC, $ot_MS... for anyone here to be able to help you, you will need to provide a comment on each variable telling us what it means and provide a sample (var_dump()) of what the data in them is. you will also need to describe or post any error or incorrect output you are getting from that relevant code along with a sample of what the correct output should be.
-
setting up contact form for sending emails
mac_gyver replied to MelissaSass's topic in PHP Coding Help
phpmailer is just an interface between php and your sending mail server. it does not process form data. to process form data you either need to - a) write some server-side code to take each input received from the form, validate it, and use it the way you want. b) find a general 'form processor' script that will let you define its inputs, data/validation types, and define an email template that uses the input values the way you want. -
Multi page forms, losing the session variable
mac_gyver replied to nharding99's topic in PHP Coding Help
your site isn't setting any session id cookie. it's likely that your session_start() statement isn't positioned in the code on your page before you output anything else to the browser. setting php's error_reporting to E_ALL and display_errors to ON or log_errors to ON would help you by displaying or logging all the php detected errors. -
the value being submitted likely contains a ' you may have seen this recommend before - you need to form the sql query statement in a php variable so that you can echo/var_dump/log it for debugging purpose so that you can see what it actually is. you will save a ton of time. also, please use the forum's bbcode tags (the edit form's <> button) around code when posting it in the forum.
-
unable to solve You have an error in your SQL syntax;
mac_gyver replied to runnerjp's topic in PHP Coding Help
you are missing one single-quote in your sql syntax. did you even look at the code you typed, at the point where the error is being reported in the sql statement, to find the problem? -
here's a different approach to your coding. it is a 'data driven' design, where you don't repeat blocks of code that perform the same processing, just because a value or where a value comes from changes. you write one block of general processing code and let a data definition, in this case an array, control where the data comes from or what the code does for each possible case. <?php // get leave amounts for a particular person, by name $tool = mysql_query("SELECT * FROM leave_member WHERE firstname = '$firstname' AND lastname = '$lastname' "); $fest = mysql_fetch_array($tool); // map the leave $type to the database column name - these are the only inputs that are dynamic for the processing code $leave_map['Annual Leave'] = 'annual'; $leave_map['Sick Leave'] = 'sick'; $leave_map['Compassionate Leave'] = 'compassionate'; $leave_map['Study Leave'] = 'study'; $leave_map['Maternity Leave'] = 'maternity'; if(isset($leave_map[$type])){ $column = $leave_map[$type]; // column name $amount = (int)$fest[$column]; // get the amount if($amount == 0) { echo "Sorry, you don't have any $type days available."; } else if ($workingDays > $amount) { echo "Sorry, the number of days you are requesting - $workingDays, is more than the number of days you have left - $amount. "; } else { // you have enough of the requested type $query = "INSERT INTO leave_request ( id, firstname, lastname, department, type, days, startdate, enddate, details, status ) VALUES ( NULL, '$firstname', '$lastname', '$department', '$type','$workingDays', '$startDate', '$enddate','$details', '$status' )"; $sql = mysql_query($query) or die(mysql_error()); } } else { echo "The requested type - $type, is not valid"; } this method of coding also helps accomplish DRY (Don't Repeat Yourself), because it lets you eliminate duplicated code.
-
the $event variable is apparently a null value. what debugging have you done to find out what is in $event? also, your table definition doesn't make sense. an auto-increment column is by design supposed to be for the database engine to assign values for, not for you to insert your own values. p.s. see my reply in your other thread concerning using the bindParam() statements in the wrong place in the code.
-
you are using ->bindParam() incorrectly. the ->bindParam() statements should be before your loop. the only thing that should be inside your loop is the code that gets/produces and assigns the dynamic values to the variables that were bound to the place holders and the ->execute() method statement. if you are submitting a radio button selection for each name, you would need to loop over both the array of radio inputs and the array of name inputs, using the same array index, to get the corresponding sets of radio/name values.
-
your database table design is not normalized. by having columns Picture01 ... Picture10, your code to store, update, delete, and retrieve information is more complicated, since it must find which columns are the ones in use, which is likely the reason you ended up with incorrect data stored in your table. you should have the information for the pictures stored in a separate table, related back to the parent table using the parent's id. this will allow you to store any number of pictures, update or delete any of them, and more importantly, select any number of them and simply loop over the selected rows to display them.
-
yes - suhosin.get.max_value_length 512 http://www.suhosin.org/stories/configuration.html#suhosin-get-max-value-length
-
Error: "Failed to open stream." - Image Upload Script
mac_gyver replied to glassfish's topic in PHP Coding Help
there's documentation for all the php functions at php.net. you don't have to guess or assume how something works. -
Error: "Failed to open stream." - Image Upload Script
mac_gyver replied to glassfish's topic in PHP Coding Help
if you look at the first error message and look at your code leading up to the imagejpeg() function, you will see that you are NOT supplying a file name - at this point, we cannot possibly help you because you not reading the error messages, nor are you even considering the information that someone took the time to give you in a reply. -
Error: "Failed to open stream." - Image Upload Script
mac_gyver replied to glassfish's topic in PHP Coding Help
you are not supply the file name to the imagejpeg() function. you are only supplying the path. edit: your code is allowing jpg/jpeg and png files to be uploaded. the make_thumb() function would need to be able to work for both of those type of images. also, one type of upload error, exceeding the post_max_size setting, will cause both the $_POST and $_FILES arrays to be empty. you must test if the upload worked before you can access any of the $_POST and $_FILES data. another problem is you are defining the make_thumb() function inside of a loop. this will result in a fatal runtime error on the second pass through the loop. functions should be defined only once and never in side of loops. and even another problem with your code is you are overwriting the $target_path inside the loop, so on the second pass through the loop, your code will be attempting to move the uploaded file to a jumbled up filename. -
Form does not seem to be posting values to script
mac_gyver replied to Paul_Withers's topic in PHP Coding Help
php variables are NOT replaced with their value inside of an over-all single-quoted string. you would either need to use initial and final double-quotes or use concatenation. p.s. i seriously doubt your form processing code is running, because your big long isset() statement is testing for at least one form field that doesn't exist. it was mentioned in a previous thread of your's that you only need to test for one of the known form fields to qualify running the form processing code. -
PHP & MySQL: Using $_GET['id'] to query matching table id
mac_gyver replied to Nickmadd's topic in PHP Coding Help
your use of a prepared query is incorrect. you do not put the value/variable directly into the sql statement, you put a place-holder into the sql statement where the value belongs and bind the value/variable to that place-holder. you are also not running the query that you are preparing. i recommend that you read the relevant sections of the php.net documentation as it shows working examples. -
i, in fact, don't get that error from your code, but then again, i typically remove leading and trailing white-space that you may have had in your file and that the forum software adds when it (mis)formats code in posts. you must be extremely careful about what comes before and after the starting and ending identifiers you use for the herdoc syntax.
-
yes, you are not the first person to ever have errors in your php code. if you search the web for that very common error message, you will find what it means and what to do to to find what is causing it.
-
$stmt->fetch() fetches a row of data from the result set and populates the variables that you used in the $stmt->bind_result($PersonID,$ImagePath,...) statement. the while(){} statement should be - while ($stmt->fetch()) { and you would not use $row[0], $row[1], ... you would use $PersonID,$ImagePath,...
-
do any $_GET parameters on the end of url's work on this server?
-
that error is a very common one. if you do a search for it, you will both find what it means and how to find what is causing it. next, if you find yourself repeating code over and over that only differs in the data or value it uses, you are doing things the hard way. you should run ONE query that retrieves the data you want in the order that you want it (even if that is a random order), then loop over the rows that the query returns.
-
Linking Checkbox value to a table record in PHP And Changing Values
mac_gyver replied to TecTao's topic in PHP Coding Help
you received a reply in your other thread that explains how to test for a checked (and not checked) checkbox.