-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
To simplify your input form and the resulting 'inventory' form I would keep them entirely separate. Let the users check the inventory with one form that queries the db and outputs a very simple screen that most easily can be done with an html table. Then give them a button that takes them to your 2nd form that lets them choose from a drop down of ages, and a dropdown of sex and updates the db with their choices. I assume that your db has one table that will have an age column and a sex column and the user id of any person who has made a commitment. Also you may have a table of those people who have committed that gives you contact info as well as the user id. So - 2 tables. Does this sound like something you can do?
-
My suggestion on this new NULL operator would be to use the OR ( || ) operator rather than ?? so to the reader it says "value or 'default' "
-
PayPal Integration in PHP (Step by Step Tutorial)
ginerjm replied to FabrizioCo's topic in PHP Coding Help
You're not telling us of any errors but you are also not checking for them. You say the db is not being updated, but do you know for sure that the query is actually being run? What does verifyTransaction tell you and do you know that it is returning a true value as well as checktxnid? -
Should have asked - do you understand the code that I wrote for you fully? And the part that Barand added? You should have a shortcut to the PHP manual function reference so that you can quickly look something up and truly understand it. Here is what I use: https://www.php.net/manual/en/funcref.php Add a browser icon on your desktop with a shortcut key assigned so you can call it up any time you need help. It has a handy search box (use Alt-S) in the upper right corner so you can type in a name to find the explanation for anything.
-
Hopefully you understand what I wrote for you as well as Barand's finish with the extra array to help identify those items to be R/O. As for php mode switching - I don't know who would think that doing things that way is 'clearer'. If anything it is more clumsy and adds so much to the coding as to make it tedious to read as well as to maintain later on. As for the 'extra line' complaint. Well - that means you need to stop with the loop to build the form and actually build it manually so that you can place the fields where you want them. Learn the use of css and div tags as well as margins, padding and perhaps html tables despite the current downplaying of that style of presentation. Having fun?
-
A little cleaned up version of your code and my notes on it. echo "<form method='POST'>"; foreach ($assetx as $key => $value) { echo "<label>" . ucfirst($key) . " "; $ro = ($key === 'id') ? 'readonly' : ''; echo "<input type='text' name='$key' id='$key' value='$value' $ro>" echo '</label><br>'; } echo "<input type='submit' name='submit' value='Submit'>"; echo '</form>'; 1. One doesn't have to keep going into and out of php mode. It especially makes it easier to comprehend if one doesn't. 2. I can't find any mention of an 'escape' function in my php manual. Can you explain what you are trying to do with your use of it? 3 Your foreach is processing an array I assume. If that is so, how do you expect to have 2 keys having the same value of 'id' ?
-
how to define connectionID in line with the function for mysqli_connect
ginerjm replied to AliG's topic in PHP Coding Help
You are new to all of this, aren't you? You are writing functions to 1 line of work. What is the point? And I don't believe that they are all even working for your. When you do the close function your don't capture the result of the close (RTFM) but you then try and return the value of the connection value that you called it with. That value is non-existent since you just closed it. You are doing a fetch of 1 row of data in another. Why? Just use a line in your current script - no need to use a function. And in your main body that calls all of these frivolous functions you make a connection and then you close it twice and then you try and do a query with a query that does not exist. I think I'll quit this topic while I still have hair left. Good luck with your growth. -
how to define connectionID in line with the function for mysqli_connect
ginerjm replied to AliG's topic in PHP Coding Help
Could you show us please? -
how to define connectionID in line with the function for mysqli_connect
ginerjm replied to AliG's topic in PHP Coding Help
your error message says unexpected..... in . Where is this 'in' thing. Show us the function with your changes so and point out the line number that is giving you the error. AND - I don't buy that you 'have to use this (connect) function'. Your function does absolutely nothing. It calls one line of code using arguments that you had to prepare outside of the function for everywhere that you use this function. Kind of silly. One writes a function to cut down on code and to simplify things. Your function is doing none of that for you. -
how to define connectionID in line with the function for mysqli_connect
ginerjm replied to AliG's topic in PHP Coding Help
$mysql = dbk_connect(......); Now you have the $mysql var as your connection for everything. Get rid of the close function. Just close it by yourself. PS - what is the point of this function? It's a 1 line 'block' of code that could easily be written into any script that you need a db connection. Why the overhead of calling a function? UNLESS you wanted to add some error handling to the function so that you didn't have to handle THAT everywhere you wanted to make a connection. Now there's an idea that you didn't think of it seems. Perhaps do a test on your connection call and if it fails get the error message and pass it back using a 5th parm on your function definition, return 'false' and let your caller check for that return and take the returned error message from the function and output it or something. Read up on using functions and how to add the 5th parm. Good learning opportunity. -
As Mac_gyver has said, "where is the data"? One doesn't (usually) store html code or 'literals' in a table - that is the place for pure data. What you are storing here is boilerplate - the labels, names, punctuation and presentation material, not 'information' that can't be stored elsewhere. Such a waster of time to make up a query to store this stuff when a couple of lines of html and it's done! Plus what's with the long concatenated value you are creating after the "now" variable? That alone is so against the RDBMS book that it is laughable. You need to re-think your approach (or understanding?) to data storage and database design and usage. It will be good reading and much improve your use of this technology. Enjoy the learning process.
-
Why the two multiples in your select tag? Why the if to simply set the 'selected' attribute for everything? Where is this database involved.? Why so many classes for a simple html page build? Looks like a very simple straight-forward task that is further complicated by the un-necessary separation into different classes. How about learning how write your code without going into and out of php mode? No need to make your code so difficult to read and follow. Try going into php mode and staying there. Set the values you need to insert and then simply insert them into the html instead of inserting a 'block' of php code inside your html. Start your echos with a double quote and wrap your array elements in braces to handle them.
-
If these 'categories' are simply different values from a possible choice of values, then those fields you are creating are wrong. Each of those fields represent the same thing so they should not be separate fields. Create a 'Categories' table and create a row that has the primary key of your entity along with a category value. An entity will have multiple categories that he/she belongs to so you will have multiple rows in the Categories table. Any query you do you simply write to select the key from the first table and join it to the Categories table to produce a result set that may have multiple rows for each selected entity. That is database normalizaton. Another thing - that categories table should probably use a code to represent the category with a 3rd table 'Category_name' that connects that code to a literal description for the category. I think that is the second normal of 'normalization' - to avoid repeating a string in every record when a simple (shorter) code will do.
-
Looks like something he/she copied. Oh, well....
-
Change 1 line in the above $arr[] = $line; S/B $arr[] = trim($line);
-
Since you haven't done anything here's a little something that was easy to produce: // Open a text file of state names // format of file is simply a state name on each line. $input_name = 'pathtotextfileofstates'; if(!$states_file = fopen($input_name, 'r')) { echo "Could not open input states file '$input_name'<br>"; exit(); } // read in the state names $arr = array(); // array to save names in for sorting and processing while($line = fgets($states_file,30)) { $arr[] = $line; } // put names into alphabetical order sort($arr); // create the output name $output_name = 'pathtooutputhtmlfile'; if (!$out_hdl = fopen($output_name, 'c')) { echo "Could not open output file '$output_name'<br>"; exit(); } // start creating option tags and the html file that you will use // in your mail form script $out_cnt = 0; foreach($arr as $st) { // create the option tag for the dropdown list to use $output_tag = "<option value='$st'>$st</option>"; $result = fwrite($out_hdl, $output_tag); if (!$result) { echo "Error writing state '$output_tag'<br>"; exit(); } else { $out_cnt++; echo "Wrote $output_tag<br>"; } } fclose($out_hdl); echo "Wrote out $out_cnt option tags<br>"; // include this file in the html inside of the <select> start and end tags // Obviously you only need to run this once. exit(); The idea is to produce the <option> tags for the states and save them in a plain text file. You will then include that in your script where you have the dropdown list. It is already in html so you just simply do the include in a block of php code: echo "<select name='state_dropdown'>"; require 'pathtostatesfile'; echo "</select">; (continue on with html)
-
Catching All HTTP Requests to Apache and Storing Them in DB
ginerjm replied to mongoose00318's topic in PHP Coding Help
Not sure what you just said. At all. -
Catching All HTTP Requests to Apache and Storing Them in DB
ginerjm replied to mongoose00318's topic in PHP Coding Help
And you can't figure out how to streamline the use of ajax to enable you to add this new function call? Sounds like a lot of scripts/calls -
A select tag for the us states - that's easy. What's the hangup? What is a "toggle" to you? Not a term I use.
-
Catching All HTTP Requests to Apache and Storing Them in DB
ginerjm replied to mongoose00318's topic in PHP Coding Help
OK then. So - if this is something to track how your app gets utilized, why not add a call from each script/page in your app to some new function that can save the data that you want to have saved? Too many pages/scripts to even consider? -
Catching All HTTP Requests to Apache and Storing Them in DB
ginerjm replied to mongoose00318's topic in PHP Coding Help
Not only as Requinix asked but what makes you think that all requests involve the use of PHP and therefore its SESSIONS? And I am sure that you realize that getting access to somebody's PHP SESSION array is pretty much impossible without the skills of a hacker which we certainly do not want to help you accomplish. -
So what is the problem? I would think that you would just include either the light css module or the dark one, depending upon the mode value. Use $mode as the name of the css file perhaps. You could also make that last line of code a lot easier to read/write: echo "<input type='checkbox' onChange='this.form.submit()' value='$mode' name='mode' $mode_chk_flag/>"; Set the $mode_chk_flag when you set the $mode value. AND - you don't really need the cookie unless you are trying to retain the setting between sessions.
-
Call to undefined method in included file
ginerjm replied to richarddunnebsc's topic in PHP Coding Help
You are already instantiating it in line 4. Then you are defining the class and method with the proper structure. It's where you then call EmailVerify that you are not passing the $data var. -
Call to undefined method in included file
ginerjm replied to richarddunnebsc's topic in PHP Coding Help
If you would just show ALL of your code that pertains to this we could solve this. The message is saying you wrote EmailVerify(), and not EmailVerify($data) when you called the function.