-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
I still think it is because he bound the age as a string rather than an int. And the quotes on the query parms that I previously mentioned. We'll just have to wait and see what the OP responds with.
-
Don't wrap the query parms in the single quotes. Also when you use bindvalue (which I don't) the default type will be a string which you don't want for the age value. This works much better for me: $stmt->execute(array('name'=>$_POST['name'],'age'=>$_POST['age']));
-
beginning programmer error. Always check things. Never assume.
-
What is weird is that you have a record with no values in it other than the id. Why haven't you browsed your table (phpadmin?) to confirm that there is data in there?
-
Very puzzling. Please try this in your code: //fetch the results while(list($id,$name,$email,$phone) = $result->fetch_row()) { echo "id $id name $name email $email phone $phone<br>"; }
-
So your returned value is False. That implies that the execute failed. Never write code that "does" something that could fail without checking the result. Especially a class where you plan on using it a lot. So - test the execute and display the error (on screen during development or in your error_log once in production).
-
When you throw a bunch of class-related code at us and give us way too much to look at without fully understanding the goal, it makes us not want to help you. Try debugging each of your methods to be sure that they are doing EXACTLY what you expect. Once you are happy with them, do the same debugging with your surrounding logic to be sure that you are giving those methods what they expect and that the returns are what you expect still. When you get down to one single point of contention - show us that roadblock and tell us what is not working.
-
Your output seems to be exactly what you are echo-ing. If you want it formatted, do it with your echo or simply add another echo to output a line break. (inside the loop). As for missing items and the limit 1 points - show us that code if you want to discuss it.
-
Submiting form with text fields and checkbox's Need help
ginerjm replied to ericjw316's topic in PHP Coding Help
What do you mean "how to display" your checkbox on a get. The incoming query string will look like: checkboxname=checkboxvalue. Of course if you don't have an actual value= attribute on your checkbox tag (as I pointed out earlier), then 'checkboxvalue' may be non-existent in the string. A better checkbox tag: echo "<input type='checkbox' name='chkbox1' id='chkbox1' value='1'> <label for='chkbox1'>Selection 1</label>"; Here I assign a value of '1' to the choice of 'Selection 1'. You can just as well use 'Selection 1' in your value attribute, but that is up to the situation you are in. -
Why do you need to do this with JS in real time? Simply have the uses submit the form with the entered times and let php do the work.
-
In that case - forget my comment. As for your problem though - do you understand what I posted?
-
?? I said "What URLs". You aren't showing any urls in your example, so I'm confused as to what you want to work on.
-
Uh - what urls?
-
That's not how you mix in your vars to the JS function. You can't use php in a js function since one is client-side and the other is server-side. Make you js function retrieve the values you want from the dom by using simple js things such as getElementById. (google it). Ps - Is English not your normal language? Cause if it is, how are you ever able to spell php functions correctly?
-
Pdo does not have to be used as OOP. I use it strictly in procedural mode and find it very easy to use. $q = "select * from (table) where key1= :mykeyvalue1"; // note use of : in the key argument here $qst = $pdo_conn->prepare($q); // $pdo_conn is created in a separate piece of connect logic that one can easily write in an included module if (!qst) echo "error doing prepare"; $qst->execute(array('mykeyvalue1'=>$key1)); while ($row = $qst->fetch(PDO::FETCH_ASSOC)) { (process the returned rows) } Hope this makes it clearer.
-
Yes - it is php code and s/b at the top along with all of your php code (and not your html) whenever you are developing your scripts.
-
Except you mixed your html and php code together.
-
Submiting form with text fields and checkbox's Need help
ginerjm replied to ericjw316's topic in PHP Coding Help
With all that input I would not use a GET for my input. Set your form method to be POST instead. Also - your checkboxes don't have a value clause which is usual. Of course you still have to check if they are set but then you can simply use the value as the value to be saved. if (isset($_POST['checkbox1'])) $checkbox1 = $_POST['checkbox1']; else $checkbox1 = 0; // or whatever you want saved -
Turn on error checking to see if something is wrong with your script. See my signature.
-
"Login system"? Is this something more than a simple form that asks for a user id and password? I've not heard it referred to as a 'login system' before. Normally it is simply the form and some logic and a db query to check the entries or to save them.
-
How to validate user login on every page only with cookies
ginerjm replied to thegweb's topic in PHP Coding Help
1 - create your text file and store it outside of your web-accessible tree for security purposes. 2 - create a small php script that contains a function that has two arguments - user and password. 3 - in this function open the text file and start a loop on it to read the lines one at a time. 4 - match the user and password argument against the contents of the current line you just read. If it matches, set the cookie and return true from the function 5 - if it doesn't match, read the next line from the text file and repeat step 4 6 - if you reach the end of the file and exit the loop, return false. -
Maxdd - I rarely use oop. Small projects, not enough repetition to warrant classes, use includes for standards pieces of code. Hansfore - function does stand out on the function header, but in use that word isn't obvious! Of course, function names in php are case-insensitive so it doesn't matter but it's just one of my own conventions.
-
as Maxdd says commenting a much ignored attribute of programmers. Sometimes when we get deep into a process and develop some code to do some tricky maneuver we lose all sense of it just a couple of months later when we come back to 'tweak' it a bit. Comments about your thought process when you write something are essential! Unfortunately, I can't agree with Maxdd on his use of camelcase for naming things. It's bad enough that JS endorses it - there is no reason for you to introduce it in your own code. A needless distraction in my opinion since it leads to many errors during development where you inadvertently leave out a capital letter which PHP will not catch and WILL give you an error or worse. IMHO - stick to all lowercase for your vars. Another of my preferences is to use initial caps on my own function names just to make them stand out. MyFunctionName() versus myFunctionName() or myfunctionname().
-
Sorry about my previous post. For some reason the forum is acting strangely today. I did not spread my code out like that intentionally.
-
$first = true; while($row = mysqli_fetch_assoc($result)) { if ($first) { $first = false; continue; } ... ... ...