Ahhhhh! It was the $db-> thing! Thank yewwww!
Running Update Query
Here's another one to make me sound stupider ;) I have a page that needs to change values in 3 tables when I press update. It changes the
https://hastebin.com/wuvahisigu.php
dates table properly, but I need it to update the calls and orders tables based on the $date value which is already defined. I am trying to replicate this using the approve functions you wrote for me, but it's not liking me. It keeps throwing $isactivate is undefined errors on my page. isactivate defined when the update is performed? Clearly it is because it does it in the dates table.https://hastebin.com/wuvahisigu.php
The isactive error is coming because you have that variable in your function, but you are not getting that info from anywhere. I'm guessing you mean status.
What is the isactivate column supposed to have on it? Is it supposed to be a 1 or 0, yes or no? What data are you trying to get in there?
What is the isactivate column supposed to have on it? Is it supposed to be a 1 or 0, yes or no? What data are you trying to get in there?
Mudmin,
Note my mispellings of
https://hastebin.com/asopijopoj.xml
The
Thanks for your help.
Note my mispellings of
isactivate instead of isactive lol. It is all correct in the code though. The isactive column is used in other portions of the system to verify if to include that call, order or date in the stats calculations. isactive is 1=Yes or 2=No, table defaults this column as 1. I have included the ddfunction.php page as a whole below:https://hastebin.com/asopijopoj.xml
The
isactive column is pulled from the DB, and is defined prior to the forms posted, and is defined again when the form posts, by the update query. So this properly updates the dates table, however when the validation runs the function to update the orders and calls table, it seems to not be able to pull the new isactive value. Why would this be?Thanks for your help.
Let's take a crack at this. I'm going to guess that your procedural mysqli calls are right in your page itself, although I'm a bit rusty on that. I made a few changes to protect you against sql injections (hacks) on your $_GET variables.
If this isn't it, it's pretty close...here is your function...
https://hastebin.com/zajidawoqu.xml
Here is your full page
https://hastebin.com/zupudufuvo.xml
If you are still having problems, this is what I would check.
1. Echo your date and make sure it's in the same format as the one in the database.
2. Double check your column and table names :)
3. Before line 57, I would do
If this isn't it, it's pretty close...here is your function...
https://hastebin.com/zajidawoqu.xml
Here is your full page
https://hastebin.com/zupudufuvo.xml
If you are still having problems, this is what I would check.
1. Echo your date and make sure it's in the same format as the one in the database.
2. Double check your column and table names :)
3. Before line 57, I would do
die($date); and then die($isactive); to make sure you have the right info there. You sir, work wonders. I'm trying to get everything switched to PDO and injection proof but between coding new plugins for this system and work itself, it's hard to take the time! And I honestly cannot find a reason that it would be beneficial (other than the obvious) since I am currently the only one using the system. Prior to it being deployed to the entire team of more than 100 users, I'll definitely have to have it converted! Just not really a need right now. Mind you, it would probably make it easier in the long run so I don't have to manually do it later lol. Decisions, decisions! Thanks again Mudmin!
haha. I get that. I'm going to work on putting out a video on the db class. I think it would be super helpful on this sort of stuff. Glad to help!
That would be awesome! I think that's my biggest struggle, is learning how this system inserts, updates and queries the database. Although I can kind of grasp it by looking at the functions that are currently in the system, it is hard for me to fully understand how to adapt it to work with my new functions. Once I get told though, I understand! Lessons learned lol!
I just posted a 35 minute video detailing how to use the database class.
https://www.youtube.com/watch?v=rb0kD5tCENM&feature=youtu.be
https://www.youtube.com/watch?v=rb0kD5tCENM&feature=youtu.be
I just got around to watching this, and THANK YOU! That was hands down the most informative video I've watched when it has come to coding! Thanks again!
I've almost mastered this...almost is keyword. I am trying to bind LIMIT variable. I'm testing this prior to using it for my pagnation. However, when I use the following statement, it returns an empty array:
But when I run:
It runs fine and returns a good array, but the point of PDO is to bind variable, I'm eliminating this purpose of I end up putting
Thoughts? Thanks in advance!
$q = $db->query("SELECT * FROM dates WHERE dateclosed = ? AND user_id = ? LIMIT ?", array(0,$uid,1));
But when I run:
$q = $db->query("SELECT * FROM dates WHERE dateclosed = ? AND user_id = ? LIMIT 1", array(0,$uid));
It runs fine and returns a good array, but the point of PDO is to bind variable, I'm eliminating this purpose of I end up putting
LIMIT $start,$finish right into the statement.Thoughts? Thanks in advance!
I don't think there is any kind of downside to not binding those variables. There really isn't anything anyone could inject into that limit that could be a real security vulnerability to you. I guess it's possible, but I think you're ok.
Sweet, I shall continue! Was just concerned something could go wrong :D