-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
I do not believe you can merge these files. One merges the DATA into one report. That's the thinking you need to do. If necessary you could simply do a page break in it after each person's info is printed.
-
I"m thinking that if you simply changed the query that grabs the data so that it grabs everyone the pdf reporting should be the same. If you thought about it beforehand that is. There's an awful lot of thought that goes into this business. Try a little.
-
How about generating the complete report instead one report for each person?
-
PHP code to the screen? That means you are missing the php tag perhaps. Or even that you haven't named your file as a .PHP file.
-
YOu have to start paying attention to the error messages and line numbers. The answer is always pretty close to what it says.
-
Altho keeping a password in a file may not be the best idea. Hopefully it is a php file. And not stored in the web tree.
-
Read a SQL manual for the functions available to be used in a query. Research! Feeling magnanimous - here: https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_month
-
The connection module is just THAT. It is not a query module. It is not an update module. It is simply your permanent connection module. You use it when you need to establish a connection and you keep it in play all during your script, if the script needs to communicate to the db. That is it. It is the one and only place you make a connection and that means you only have one place to maintain should there be any changes in your credentials or your database tool.
-
So the problem was with the credentials? Did you use the SHOWMSG argument to get the true error message?
-
Must be something in the hidden files that I can't see. I took the basics of your script and ran this: <?php session_start(); // If the user is not logged in redirect to the login page... // if submit button selected run code if(isset($_POST['submit'])) { $_SESSION['district'] = $_POST['district']; echo "You have selected ".$_POST['district']; } // output the html now ?> <!DOCTYPE html> <html> <body bgcolor=#fafafa> <br> <br> <form action="test.php" method="POST"> <label>Select District you raced at</label> <select name = "district"> <option value="" disabled selected>Choose your district</option> <option value="Z">Zwift TT - Z</option> <option value="">--------------------</option> <option value="A">Central A</option> <option value="B">East - B</option> <option value="C">Lincolnshire - C</option> <option value="D">Liverpool - D</option> <option value="E">London East - E</option> <option value="F">London North - F</option> <option value="G">London South - G</option> <option value="H">London West - H</option> <option value="J">Manchester - J</option> <option value="K">Midland - K</option> <option value="L">North - L</option> <option value="M">North East - M</option> <option value="N">South East Midlands - N</option> <option value="O">North Midlands - O</option> <option value="P">South - P</option> <option value="Q">South East - Q</option> <option value="R">South Wales - R</option> <option value="S">South West - S</option> <option value="T">Teeside - T</option> <option value="U">West - U</option> <option value="V">Yorkshire - V</option> <option value="W">Scotland - W</option> <option value="Y">National - Y</option> </select> <br><br> <input type="submit" name="submit" value="Submit"> <br> <br> </form> <?php exit(); This worked equally well on my pc and my iphone. So - look for a problem in the JQ perhaps?
-
And as I sadi last time the connect logic is failing you. Did you follow the instructions and have the module give you the full error message???
-
From the code you presented - yes it is that simple.
-
Why is your pdoconnect header not what I gave you??? I don't know what the mention of "structure" has to do with this topic. Nor the photograph. You're making it very difficult to help you. The error message obviously comes from the connect logic so that is where the problem lies. As for the main script - when you get a false result from the connect call why are you not exiting??? Add an echo to the pdoconnect logic to display the input dbname just to make sure you are actually executing this set of code. And - I assume that you are supplying the uid and pswd in the connect code and only left it as xxx and yyy for me.
-
So - add some echos to check what is going on. Or you could post the part of the current script that is making that connection call as well as the entire module that contains the connection code so that WE can see what you are seeing. That would be so very very helpful.....
-
No it does not. If the user clicks on a choice that is the value that should appear in your $_POST array as element 'district' Of course - on many mobiles the screen is so small it would be easy to select the wrong one with my big fingers.
-
I don't understand what this means: "seems to be random the course it selects " What is the problem?
-
You should NOT EVER store any kind of hint to a password. Once the user has logged in with his/her password all you need is perhaps the username and a token (maybe). You never need the pswd again.
-
I don't actually use try/catch in my code so it must have been left over from something I copied from you and edited. Actually - the catch is commented out so it should not be a problem. Do we still have a problem? Tomorrow.
-
So you have solved the error? What now? And what is the catch for? Seems like an orphan
-
Where's the code???????
-
I have no idea why your dbname is not getting passed. Did you try echoing it out from inside the function? Where is this other error? What is line 15? AND WHY DO YOU KEEP EDITING MY CODE? Do NOT include the db name in anything but the call to the connect!! Actually change the function header to this: function PDOConnect($l_dbname=NULL, $l_msg=null, $l_options=null) And get RID of the database name you supplied lower down. Tsk, tsk, tsk.
-
I doubt if the mail is being sent.
-
Here is my second demo. Please note the following changes. You don't put the dbname in the function header. You supply the name in the call to the function. Also - the connection function is something you should store in a folder along with all of your other generalized utility scripts that will be used in many of your future scripts. Somewhere outside of the root tree so that nobody can get there from a browser connection. You then always include it using a 'require' statement that points to that folder and script. You can include the uid and pswd in the script because nobody will be able to see it from the web. // start of script every time. session start(); // setup a path for all of your canned php scripts $php_scripts = '/home/user/php/'; // a folder above the web accessible tree // load the pdo connection module require $php_scripts . 'PDO_Connection_Select.php'; //******************************* // Begin the script here $ip2 = GetUserIpAddr(); if (!$pdo = PDOConnect("foxclone_data") { echo "Failed to connect to database" // exit? } else { $sql = "INSERT INTO LOGIN (ip_address) VALUES ('$ip2' )"; // use exec() because no results are returned $pdo->exec($sql); echo "New record created successfully"; } catch(PDOException $e) { echo "Query failed to run properly: $sql <br><br>" . $e->getMessage(); } exit(); //***************************************** // functions below //****************************************** function GetUserIpAddr() { if(!empty($_SERVER['HTTP_CLIENT_IP'])) { //ip from share internet $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //ip pass from proxy $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } return $ip; } //****************************************** // This code s/b removed once you place it into the php folder // and rely on the require line at the top. function PDOConnect($l_dbname, $l_msg=null, $l_options=null) { if ($l_options == null) { // set my default options $l_options = array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_FOUND_ROWS => true, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC); } if ($l_dbname == null) $host="mysql:host=localhost;charset=utf8"; else $host="mysql:host=localhost;dbname=$l_dbname;charset=utf8"; $uid = "xxxxxxx"; $pswd = "yyyyyyyyy"; try { $mysql = new PDO($host, $uid, $pswd, $l_options); } catch (PDOException $e) { if (strtoupper($l_msg) == "SHOWMSG") echo "Fatal Error<br>Failed to connect to mysql via PDO. PDO Error msg is:<br>".$e->getMessage(); else echo "Fatal Error<br>Possible bad dbname?<br>Failed to connect to mysql via PDO. Sensitive error msg may be viewed with additional parm to call to PDOConnect(dbname,'showmsg')"; return false; } if (!$mysql) return false; else // all worked - return handle to pdo connection. return $mysql; }
-
YOu put the function at the top. That's a big no-no!
-
Maybe you should show us the actual code then.... What about the points I made?