Jump to content

TapeGun007

Members
  • Posts

    307
  • Joined

  • Last visited

Everything posted by TapeGun007

  1. What I gather from his post is... he has an email list of friends and family that are all using either yahoo, gmail, or hotmail. Those three companies require a "unsubscribe" option or his outbound emails immediately go to their spam folders instead of receiving them. I'm not sure why you can't just put at the bottom of the email an HTML link with unsubscribe (even if it does nothing) and prevent it from being flagged as spam (granted I don't know that's true).
  2. @gizmola, Yes, I just read that actually on a website, but I tried this instead and it seems to work fine (more along the lines of what Jacques suggested). I want to simply check for any data so it doesn't bother building out a table for nothing. $stmt = $con->prepare($sql); $stmt->execute($params); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($row){ echo "<br>Not Empty<br>"; }else{ echo "<br>Empty<br>"; }
  3. Yes, Barand made me convert... so I'm learning slowly... if ($stmt->num_rows == 0) { echo "<p>No record(s) found.</p>"; }else{ echo "<br>".$row['FirstName']."<br>"; } I'm getting no records found. So then I realize it's because (Barand made me convert) I'm on PDO not mySQLi. So I read about rowCount, but then it states the following (Which is disturbing): So what is the best alternative? From googling, I'm getting like so many different pieces of code, I'm not sure what is the best method. I just want to check to see if there are any values at all in the query.
  4. I kind of gathered that. I have donated in the past. I would just like to show my support even though $100 really isn't much in the grand scheme of things and it certainly wouldn't pay for all the help that I have received. A big thank you to whomever it is that runs this website.
  5. My company would like to donate $100 for all the help we have received.
  6. I love Barand. He has helped me out of a bind so many times while I'm trying to learn mySQL and sometimes even php. I've probably been on this site for 10+ years now, but off and on as I have not always been actively coding. What I really like about Barand is that often times when asking for help, some people will say, "Why are you doing it this way?" where Barand just gives you the answer. He's always very helpful!
  7. Ignorance. I just didn't know the proper method of going about that. But when I post on here, not only do I get the answer I am looking for, but I also get an education on how to do things the RIGHT way.
  8. I thought Psycho's way of writing my code was very neat and tidy yesterday, but I couldn't figure out how to apply it. Now I'm trying to figure out how to apply what you are telling me. This is my complete rudimentary and failed attempt at coding this: // $dbs tells us how many databases are in that array. $dbs = count($statedb); // Establish all of the connection strings that we will need. Some states will need 1, some states will need 10. $con = array(); foreach($statedb as $counter => $db_name){ $con[$counter] = new mysqli($DBServer, $DBUser, $DBPass, $db_name); //echo "$counter - $db_name<br>"; // Loop through each database name in the array and add it to the $sql $sql .= " SELECT FirstName, LastName, Email, Mobile, PromoCode FROM $db_name.<tablename> WHERE (Email LIKE ?) OR (Mobile LIKE ?) OR (PromoCode LIKE ?) "; $args .= "sss"; // This just stops adding to the string 1 count before so we do not get 3 extra $Search's if($counter < ($dbs - 1)){ $searches .= $Search.", ".$Search.", ".$Search; } // This prevents putting an extra comma at the end of the final string or we would get "$Search, $Search, $Search," if($dbs <> 1 && $counter < ($dbs - 2)){ $searches .= ", "; } /* If there is only 1 database, then we do not need a UNION. Also, we do not want a UNION at the end of our $sql either. */ if($dbs <> 1 && $counter < ($dbs - 1)){ // If the State selected has more than 1 database, then add the UNION to the SQL command. $sql .= " <p>UNION</p> "; } } echo "<p> $sql </p>"; echo "<br> $args - $searches<br>"; $stmt = $consd->prepare($sql); $stmt->bind_param($args,".$searches."); $stmt->execute(); $stmt->store_result(); $stmt->bind_result($ID, $FirstName, $LastName, $Email, $Mobile, $Code); But at least I was trying... LOL. I'll read up on mySQL variables. I get what you are doing, I just need to learn how to apply it. Thanks.
  9. This has to do with yesterday's thread found here: https://forums.phpfreaks.com/topic/303251-can-you-store-con-into-an-array/ So the actual mySQL is something like this: SELECT FirstName, LastName, Email, Mobile, PromoCode FROM <database>.<table> WHERE (Email LIKE ?) OR (Mobile LIKE ?) OR (PromoCode LIKE ?) A user fills out a search INPUT and so they can search based on the email address, cell phone or promo code stored in $Search. Then for the prepared statement I would simply use something like this: $stmt->bind_param('sss', $Search,$Search,$Search); So, the code we worked on yesterday pulls the SQL statement from potentially 1 database, or it could be 5 databases using UNION. So if there were 5 databases, then the bind_param would be set to say 'sssssssssssssss' and $Search x 15 times. I don't know how to accomplish this... I am assuming that for the 'sss' I can store that in a string easy enough, but what about duplicating the $Search field over and over? I'm not sure if I am making coherent sense here. Hopefully I am.
  10. Yes, I agree with both of you. It's because some states have a different # of databases. So if $statedb = "1", then "SELECT * FROM <db> WHERE... " else "SELECT * FROM <db> WHERE ... UNION..." Thanks for the code Psycho, I'm not familiar with implode so I'll go look that up. edit: You wrote what I wanted to do in a MUCH better way. Thanks again.
  11. I think I have it already... I was too quick to post. I see my syntax error above as well. I think this will work: foreach($statedb as $x => $x_value){ $con[$x] = new mysqli($DBServer, $DBUser, $DBPass, $x_value); }
  12. I'm looking for a temporary solution to a database issue. Eventually, I will put an end to all of this nonsense, so for all those would reply "Why in the world would you do that?"... I didn't. Someone else did. I'm just looking for a temporary fix. I have a set of databases all on the same server, same fields, same log in credentials. I simply want to create a $con array because based on user selection, there may only be one database, or there could be as many as 10 (all of which I would use UNION to join them). I know this is a syntax error on my part, I cannot seem to Google the right information to understand how to do this properly. $con = array(); $arrlength = count($statedb); echo "$arrlength<br />"; for ($x = 0; $x < $arrlength; $x++) { $con($x) = new mysqli($DBServer, $DBUser, $DBPass, $statedb($x)); echo $con($x); } So in the example above, let's say California was selected, there are 10 databases (all identical in login, layout, but different information). I'd like there to basically be $con x 10. I think the code above is pretty self explanatory.
  13. I think I'm not googling the right phrase so I can't seem to find the right answer. I'm not super great with CSS especially when it comes to drop down menus. I usually spend time on the back end of a website, not the front end. Here is my CSS: /***** Begin Menu CSS *****/ ul { width: 100%; list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } li { float: left; } li a, .dropbtn{ display: inline-block; font-size: 15px; color: white; text-align: center; padding: 14px 16px; text-decoration: none; border-right: 1px solid #bbb; } /* Color of the main menu text when hovering */ li a:hover { background-color: red; } /* Once the mouse has moved off the main menu button and is now highlighting a sub menu button, this defines what that main menu button color is */ .dropdown:hover{ background-color: red; } /* Color of main menu button when not selected */ .dropbtn { background-color: 333; } li .dropdown { position:relative; display: inline-block; } li:last-child { border-right: none; } .dropdown-content{ display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2); z-index: 1; } /* Links inside the dropdown */ .dropdown-content a{ color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; background-color: #f6f6f6; /* Sets background color of the drop down menu (not selected) */ } /* Change color of dropdown links on hover */ .dropdown-content a:hover {background-color: #ccc} .dropdown:hover .dropdown-content{ display: block; } /* I have no idea what this does as it appears nothing... li a:hover:not(.active) { background-color: #blue; } */ .active { background-color: #990000; } .active dropdown-content{ display: none; position: absolute; min-width: 160px; box-shadow: 5px 7px 5px 0px rgba(0,0,0,0.2); z-index: 1; } .active dropdown-content a{ color: black; padding: 12px 16px; text-decoration: none; display: block; text-align: left; } /***** End Menu CSS *****/ And here is the HTML: (PHP Function) function Active($menuselection, $page){ if($page == "$menuselection"){ echo "active"; }else{ echo "dropdown"; } } (HTML) <table width="100%"> <tr> <td> <ul> <li> <a class="<?=Active("menu.php", $webpage); ?>" href="menu.php">Home</a> </li> <li class="<?=Active("tms.php", $webpage); ?>"> <a href="javascript:void(0)" class="dropbtn">Territory Manager</a> <div class="dropdown-content"> <a href="#">Add TM</a> <a href="search.php?search=TM">Search TM</a> </div> </li> <li class="<?=Active("sales.php", $webpage); ?>"> <a href="javascript:void(0)" class="dropbtn">Sales</a> <div class="dropdown-content"> <a href="#">Add Sales Person</a> <a href="search.php?search=sales">Search Sales</a> </div> </li> <li class="<?=Active("drivers.php", $webpage); ?>"> <a href="drivers.php" class="dropbtn">Drivers</a> <div class="dropdown-content"> <a href="#">Add Driver</a> <a href="drivers.php">Search Drivers</a> </div> </li> <li class="<?=Active("passengers.php", $webpage); ?>"> <a href="javascript:void(0)" class="dropbtn">Passengers</a> <div class="dropdown-content"> <a href="#">Add Passenger</a> <a href="search.php?search=passengers">Search Passengers</a> </div> </li> </ul> </td> </tr> </table> So... the drop down menu works wonderfully except for one thing... if I were to click on "Drivers" for example, now that it is actively selected... the drop down menu is now gone so I cannot select "Add Driver" or "Search Drivers". I just cannot seem to figure out why I cannot get the drop to work on a menu item that is selected. Any help would be greatly appreciated. EDIT By Psycho: Wrapped HTML within code tags
  14. I have mySQLi statement that looks similar to this: $sql = "SELECT ID, FirstName, Last Name, Email, Mobile, PromoCode FROM table1 WHERE (Email LIKE ?) OR (Mobile LIKE ?) OR (PromoCode LIKE ?) "; $stmt = $consd->prepare($sql); $stmt->bind_param('sss', $Search,$Search, $Search); Works fine. But what I cannot seem to find is what if I had two databases with all the same tables and I want to query both of them using mySQLi? I've tried all types of things, but I *think* because it's older mysql code that I'm not getting the syntax quite right...
  15. Hey Jacques1, I didn't really know much about cURL, so I had to read up and learn how it works. I used a var_dump to help figure out what I was doing as well. Bottom line is, you got me pointed in the right direction so thank you for that. Here is the code that works: $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'https://www.google.com/recaptcha/api/siteverify', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => [ 'secret' => '***SECRET KEY HERE***', 'response' => $_POST['g-recaptcha-response'], ], ]); $response = json_decode(curl_exec($curl)); if($response->success){ echo "<p>Captcha was successful!</p>"; } var_dump($response); One curious question... is that my editor phpDesigner 8 gives me an error on the "curl_setopt_array" line with syntax error expected '[' Yet the code runs great. Is there something I am missing here?
  16. So when I run the code, the page loads... I check the captcha box and then submit... the echo "failed" is then triggered. I tried the following examples (and more): http://www.codexworld.com/new-google-recaptcha-with-php/ https://webdesign.tutsplus.com/tutorials/how-to-integrate-no-captcha-recaptcha-in-your-website--cms-23024 http://www.techflirt.com/integrate-google-no-captcha-recaptcha-in-php https://codeforgeek.com/2014/12/google-recaptcha-tutorial/
  17. Here's my code: <?php include 'recaptchalib.php'; if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){ echo $_POST['g-recaptcha-response']."<p>"; $secret = "<secret key>"; $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response']); $responseData = json_decode($verifyResponse); echo "Response:".$verifyResponse."<p>"; if($responseData->success){ echo "Success"; }else{ echo "Failed"; } } ?> <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="components/css/rs.css" /> <script src='https://www.google.com/recaptcha/api.js'></script> </head> <body> <form method="post" action="test2.php"> <input type="text" /> <div class="g-recaptcha" data-sitekey="<key>"></div> <input type="submit" /> </form> </body> </html> I've tried like 7 different websites coding example... my captcha fails every time. Their examples always work. What else could it be?
  18. Whoops... I thought it worked. but when submitting the form with nothing in the INPUT field it crashes on the if(!strlen($PostLicenseExp) == 10){ echo "yes"; $PostLicenseExp = DateTime::createFromFormat('m-d-Y', $_POST['LicenseExp'])->format('Y-m-d'); } I see... I didn't need the ! before strlen...I had it the wrong way around.
  19. I'm just curious if there's a much better way to do this: I have a form and the input looks like this: <td><input name="InspectionExp" value="<?=$InspectionExp; ?>" id="date4" placeholder="mm-dd-yyyy" /></td> The id on the form is for a jquery that auto formats the input field when selected to "__-__-____". By default a new user InspectionExp is a DATE field in mySQL and is set to NULL. So when the form is initially loaded up, the INPUT field above is blank with the place holder showing. So first I check if(isset($_POST['LicenseExp']) { Then for whatever reason this seems to be the only thing that works right, but seems really sloppy to me: if(!strlen($LicenseExp) == 10){ $LicenseExp = DateTime::createFromFormat('m-d-Y', $_POST['LicenseExp'])->format('Y-m-d'); } If I don't have an IF statement, then by default it's going to UPDATE the database with a 1969-12-31 date on new users. I can't use isset because the form makes the value set (again only on new users). I mean, the code works yes, but I am pretty certain one of you gurus could show me a better way.
  20. Yeah. At some point we'll hire only internal developers.
  21. No. I did not say that, or at least wasn't intending to. I'm no expert, but I'm probably at least a decent coder (or at least let me think I am). I was stating that the developer created an admin page where I could select the STATE first, then see a page of 20 users at a time with numbers (like to go straight to page 8 for example) and a "next page" link. I already created a search function. Currently, it only searches one database at a time. I basically want to search through all the databases in a specific state and pull up a single user at a time to edit/update/change some of their information except of course, their ID. I was looking for advice on how to accomplish this task really, but probably didn't explain it well enough. I was trying to give the full background of how it was built so you would understand why I'm trying to accomplish that. I had no idea I was going to get this kind of a response as I do not understand what to expect on a wide scale database environment. On this I am simply ignorant, but you guys are helping me realize that more than likely (as I have long suspected) that our developer might have been greedy and is charging us for development that didn't necessarily need to be done. @Jacques1, we have both an Android and iPhone application in beta testing that are nearly complete. When I said "version 1.0" I meant those applications. The application accesses the database every time a user opens the application to verify their credentials. Each time they use the application, there is database activity taking place. We have a fully built out website in which users can sign up etc, all of which interacts with the database. Then there is admin side of the website which I am building a better version than the developer, all of which interacts with the database. I really wish I could share more information about what it is we are doing with you Psycho, however, a public forum for discussing our plans isn't the place. If you would like, I can give you my email in a PM and take it offline. Any advice, including getting rid of the developer and how to move forward would be a welcome and refreshing thought for sure. If I could just find a developer than does Android, iOS, and knows Laravel, that could understand our project and what we want to accomplish.... oh man... BTW, I only have my developer that was hired. No other "experts". The developer was supposed to be the expert. Everything has been handled by the developer on the technical side. I have been the one beta testing the application, the website, and trying to steer the UI to where it's good. I am the most knowledgeable technical person in my company. The owner of this company is completely non technical to where he gets frustrated at Outlook because he doesn't know how to use it. LOL. If he had not hired me, he would've already thrown even more money away and this project would never have succeeded. I am not boasting, it's just the sad reality of our situation.
  22. Thank you all for your input. We are a start up company, so I would imagine that nothing is too late, except that our funds are starting to get low and we just want to launch without spending a bunch more $$ on development. I've coded many mySQL and php pages, but most of what I have coded was certainly catering to a small audience and nothing this large. I do not claim to be an expert, but more of a "hack of all trades". I have, no doubt, had some serious questions about our developer for many more reasons beyond this (like complete lack of customer service). Our hope was to get to version 1.0 (which is very close), fire them and hire someone else after launch. @Psycho, this is a large scale application and will have high server demand (or so we hope). We plan on having a million users in our local city alone. We definitely want to scale, not just nation wide, but globally. Users will be downloading and user our iPhone and Android capable applications all of which connect, of course, to the database(s). I'm not certain this will change any of the opinions listed above. Of course, we have been charged for the creation of multiple databases.... But in the meantime, I still need to know how to access and pull all of this information out (like doing a query to search for a specific user or updating one field for a user). Any light shed on this (until such a time when we can fix this mess) would be greatly helpful. I've seen such examples of this on StackOverflow: SELECT * FROM database_2.table_2 JOIN database_1.table_1 ON (database_2.table_2.some_field = database_1.table_1.some_other_field) WHERE database_1.table_1.data_1 LIKE database_2.table_2.data_2 Or You can make multiple calls to mysql_connect(), but if the parameters are the same you need to pass true for the '$new_link' (fourth) parameter, otherwise the same connection is reused. For example: $dbh1 = mysql_connect($hostname, $username, $password); $dbh2 = mysql_connect($hostname, $username, $password, true); mysql_select_db('database1', $dbh1); mysql_select_db('database2', $dbh2); Then to query database 1 pass the first link identifier: mysql_query('select * from tablename', $dbh1); and for database 2 pass the second: mysql_query('select * from tablename', $dbh2); If you do not pass a link identifier then the last connection created is used (in this case the one represented by $dbh2) e.g.: mysql_query('select * from tablename');
  23. So presume for a moment, that I have a set of databases named like the following: The developer says they created multiple databases to prevent crashes and such like our competition often has. Keep in mind, all of these databases in this example are for the State of California, USA. So each database is identical in the layout, tables, field names etc. It's just that the territory is broken up into multiple databases. All of the highly populated states (Like Texas) are broken up like this into multiple databases similar to this. I have an admin webpage with a drop down and I can select "California" and it will show me every user in all of the databases above (listing about 20 per page). Every single user across all of these databases for this state having a unique UserID. In my limited knowledge of mySQL, I am assuming that they are loading each database with a SELECT command into an array and then displaying the information? Or is there SQL that allows access to each of them to pull information at the same time? Any links that I can read up would be helpful as I don't know what terms to search for on Google or what this might be called. I hope my question makes sense to you like it does to me. lol Any help as always is greatly appreciated.
  24. Wow. I changed this line jQuery(function($){ Now it works...
  25. When I went to the page you just linked, the Date field works just fine once you start typing. They probably should have included placeholder="MM/DD/YYYY". I had an account on BlueHost and coded a website there about a year ago. I should have mentioned, the script is from http://digitalbush.com/projects/masked-input-plugin/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.