-
Posts
1,903 -
Joined
-
Last visited
-
Days Won
3
Everything posted by mrMarcus
-
Have you checked your error_log's? Do you have error_reporting on? There may be an issue with your code in that file since the move to a new server. Did the PHP version also change?
- 14 replies
-
- a href
- links not working
-
(and 1 more)
Tagged with:
-
OK... when you click the submit button, what happens? Errors? Nothing? Something? Computer blows up?
-
You also failed to explain the issue in greater detail. I can only read minds on the weekend. During the week, I require more details.
-
Doesn't work in what manner? You receive a Page Not Found error? Please expand. Does universityreport.php exist on the server? Are you now receiving PHP errors? If so, post them.
- 14 replies
-
- a href
- links not working
-
(and 1 more)
Tagged with:
-
127.0.0.1/page/pitem_buy.php?id=12559&foo=something&bar=something
-
As I mentioned, you could just simply add the image to the existing $statusMessage variable, like so: <?php $statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.</fieldset><br /><a href=\"holidaycalendar.php\"><img src=\"/images_common/web_cal_christmas_2012.png\" alt=\"Christmas Calendar\" /></a><a href=\"/files_common/MI_cal_2012.pdf\"><img src=\"/images_common/print_button2.gif\" width=\"560\" height=\"37\" border=\"0\" style=\"margin-bottom: 20px;\" /></a>";
-
Download the code and study the ins and outs. Reverse-engineering code is how I started learning PHP in the first place. But your needs sounds extremely specific, so perhaps you should just spend some time searching the Google machine yourself.
-
"the query fails" is quite vague. Luckily, it's a simple fix. You have 10 `columns` to your 9 values to be inserted. I would recommend using mysql_error(), y'know, for debugging purposes.
-
There are many ways to go about it. One of which I posted: html2canvas
-
Just to be 100% clear, you would like somebody else to write the script for you. If you were going to write it yourself you would have already.
-
It is possible, yes... easy, no. As was mentioned, in order to take a "screenshot" the page must first be fully rendered. You can look into html2canvas as one method. It might suit your needs.
-
Agreed. I am assuming she will be echo'ing $statusMessage at some point. @kjetterman: The basic logic for returning a "success" page could be the following: if (something was successful) { include('successpage.php'); } else { include('error_page.php'); } That is extremely basic, pseudo code. But since you are not going that path, why don't you not include the success page and just code it inline, within the $statusMessage variable? Looks like your successpage.php is only a few lines of code, anyway.
-
Sorry, but this is not good advice. Neither of the second conditions should even be run if birthYear is empty. And the second two conditions can be run in one condition, there is no reason for two separate if statements here. In my opinion, this is better: if (!empty($trimmed['birthYear'])) { if ($trimmed['birthYear'] >= $oldestYear && $trimmed['birthYear'] <= $newestYear) { // ... } else { $errors['birthYear'] = 'Birth Year must be between ' . $oldestYear . ' and ' . $newestYear; } } else { $errors['birthYear'] = 'Please enter a birth year between x and y'; } Since you are using "birthYear" as the $errors index you can only have one error associated with that condition anyway. So you might as well save the overhead of unnecessarily running conditionals. These days I do NOT trust anything I write. I am in such awe and fear of Web Development and the Internet, and I have been so humbled here in how little I know sometimes, that I think I'd need to verify if I turned on the lights if they really were on!!! Sorry, but these final days of me testing my code and re-visiting old code and testing it, and looking for *security* issues, is really making realize how fricking complicated this stuff is, and has me freaked out to no end... And in most cases you are over-exaggerating the risk. You should be focusing on completing the task AND THEN profile it and unit test it and penetration test it and so forth. You're right. I rushed the snot out of that example without thinking about it which I do quite often.
-
It's really only as complicated as your logic dictates. While logical thinking is generally something people are born with, it can, however, be improved by reading up and TESTING TESTING TESTING. Test things for yourself. Don't be scared to ask for help, but always try it first. Try it 100 different ways. And take note of how people around here format their code and implement their logic. You'll start getting those "Ahhhhhh" moments and your coding style will greatly improve, along with your abilities.
-
Interesting suggestion. I guess I just set off checking my User Details Form using this kind of coding style... // Validate Gender. if (!empty($trimmed['gender'])){ // Gender Exists. if (($trimmed['gender'] == "1") || ($trimmed['gender'] == "2")){ // Valid Gender. $gender = $trimmed['gender']; }else{ // Invalid Gender. $errors['gender'] = 'Gender must be "Male" or "Female".'; } }//End of VALIDATE GENDER Debbie I find nesting conditions becomes a nightmare. A simple setup like below will serve the exact same purpose as nested, but will allow you to easily handle your conditions and errors, should there be any. $errors = array(); // start checks if (empty($trimmed['birthYear'])) { $errors['birthYear'] = 'Please enter a birth year between x and y'; } if ($trimmed['birthYear'] >= $oldestYear) { $errors['birthYear'] = 'Birth Year must be between ' . $oldestYear . ' and ' . $newestYear; } if ($trimmed['birthYear'] <= $newestYear) { $errors['birthYear'] = 'Birth Year must be between ' . $oldestYear . ' and ' . $newestYear; } // .. and so on // then... if (empty($errors)) { // no you can run your query because there are no errors } EDIT: this way, there is no *real* need for else statements as you're simply catching the errors when they occur. Then, as long as $errors array is empty, you can run your queries/whatever.
-
You're missing the point... I am trying to test for "edge conditions" that could break my code. I want to make sure if someone hacked the Form or whatever, and a "0" is sent to my Form, it says, "Stop! Your Birth Year must be between 1912 and 1983." And, yes, a Birth Year = 1 should fail the same way. Thanks, Debbie Simple. Don't use nested condition blocks. Test each condition separately and handle errors accordingly.
-
And you should never allow your query to execute if your mandatory conditions are not met. Something simple like this would suffice: Pseudo code $error = false; // start checks if (empty($trimmed['birthYear'])) { $error = true; } if (empty($trimmed['birthDay'])) { $error = true; } // .. and so on // then... if (!$error) { // no you can run your query because there are no errors }
-
Setting 'birthYear' to 0 will not pass your first condition as you stated. Why must 'birthYear' be 0 for testing? I wouldn't suggest writing different conditions for development that will need to be changed for production. Instead of rewriting your code to accommodate development, try rethinking your test methods. Can 'birthYear' be set to 1 for your testing needs? That will (obviously) fall outside of any birth year you will be allowing on your site.
-
php/mysql query not showing results in a table
mrMarcus replied to learningcurve's topic in PHP Coding Help
You shouldn't need to substitute anything. Take exactly what was echo'd to the screen and put it directly in your sequel pro. -
php/mysql query not showing results in a table
mrMarcus replied to learningcurve's topic in PHP Coding Help
Try echo'ing your $query to make sure it's what you're expecting: $query = "SELECT q1, q2, q3, q4, q5 FROM surveys.SGID_satisfaction WHERE q1='$evaluator' AND q2= '$date' ORDER BY created"; echo $query; And check for query errors: $result = mysql_query ($query) or die(mysql_error()); -
Warning: mysql_num_rows() expects parameter 1 to be resource
mrMarcus replied to bleured27's topic in PHP Coding Help
Not relevant, but, replace session_register with $_SESSION['user'] = $user; $_SESSION['pass'] = $pass; -
mysql_real_escape_string
-
I does not have to, no. But it will not validate and is U-G-L-Y.
-
'txtUsername' and 'pass' are not yet set when they're being set to their respective variables. Same thing with trying to test if $_POST['butSubmit'] == true since 'butSubmit' does not yet exist. Change things up a bit by replacing that condition IF statement with: if (isset($_POST['butSubmit'])) { and not defining variables $username and $pass until you've checked that they're set. This is just standard handling of your incoming data, ESPECIALLY if you're going to be using them within a query. $errors = array(); if (isset($_POST['butSubmit'])) { if (!isset($_POST['txtUsername']) || empty($_POST['txtUsername'])) { $errors['username'] = 'Please enter a valid username'; // username not set or contains no value; trigger error and do not run query } if (!isset($_POST['pass']) || empty($_POST['pass'])) { $errors['password'] = 'Please enter your password'; // username not set or contains no value; trigger error and do not run query } if (empty($errors)) { // continue with script // can now run SQL query as username and password have values } else { // show errors; $i = 1; foreach ($errors as $error) { echo $i .'. <b>'. $error .'</b><br/>'; $i++; } } } Just some sorta pseudo code for you. And you're creating your query twice. Do this: $sql = "SELECT * FROM $db_table WHERE username='$username' AND password='$pass'"; $result = mysql_query($sql); And please use mysql_real_escape_string for $username. And, are you not hashing your passwords in your table? I sure hope you're not storing plain-text passwords. You need to use, at least, md5 to hash your passwords.