Jump to content

rbrown

Members
  • Posts

    124
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rbrown's Achievements

Member

Member (2/5)

0

Reputation

  1. It is like ginerjm explained... you aren't closing your table rows. Look at the html source after you run the script. Plus I would use a count instead. Your: if ($i % 3==0) should be if ($i % 3 === 0) and only used if you are trying to get 3 columns then a new row, which I don't think you want, since you have a table within a table. Try this: $Count = 0; //set outside while loop if ($productCount != $Count) { $dyn_table .=" <tr> <td> $dynamicList </td> </tr>"; } else { $dyn_table .= " <tr> <td> $dynamicList </td>"; } Plus you should get into the habit of indenting your code (makes it easier to read. And more likely for people to help... This is a mess. Go get Netbeans or an Ide.) and start using mysqli instead of mysql.
  2. You really shouldn''t be using global variables in your classes. read this link: http://forums.phpfreaks.com/topic/205920-why-should-you-not-use-global-variable/ I use a singleton pattern for db connections. That way you only have one instance running instead of a bunch of them. On a smaller sites won't matter, but on a larger site, having a bunch of instances open for each user will quickly start choking the server. When you have a state-dependant class you should not use a singleton pattern. The rule is... If you can use a variable to hold an instance of the class and reuse the same variable for a different class on the same page without breaking anything then use a singleton pattern.
  3. It has been since the late 70's, early 80' that I programmed basic.., so I'm trying get the cobwebs out... Happens when you get old... (57) In basic, the int() command rounds a number down to the nearest integer less than or equal to the number So after it does this: (LSLATVER/PITCHVER-.08) it rounds it down So this is how it should work. $length = 1802; $pitch = 50; echo floor(($length-10)/($pitch-.08)); You need to force the operator precedence using "floor" otherwise you will get wrong results. Or do the substraction outside first. The next thing you are missing in your php function is, that on lines 372 and 382 in the basic program is doing this: if the PITCHHOR or PITCHVER is greater than 72 (on both lines) then it is adding 1 to the var on that line then going back to and doing the full line (colon is used as a separator between the statements or instructions in a single line) PITCHHOR=(LSLATHOR/(NRSLATVER+1)):LSLATHOR=PITCHHOR*(NRSLATVER+1) Or PITCHVER=(LSLATVER/(NRSLATHOR+1)):LSLATVER=PITCHVER*(NRSLATHOR+1) so after Line 564 it changes the values based on the input. That is why some of your answers are off depending on what values you input.
  4. Off hand I would say you are posting to an .html file... Is your .htaccess allowing you parse php in an html file? Should have an add type line in there
  5. Some advertising companies once you become an affiliate, allow you to add the code to your site usually it is javascript or it can be an api connection to their servers where the store the user info and you can decide if you want pop over / pop unders or whatever type advertising displays they offer. Back in the day I used phpadsnew (now is openx http://docs.openx.com/ad_server/) and ran my own ads server because I had over 68 domains and 12 servers and 400 client websites I was maintaining and it was too much to keep track of everything and at the time you could setup keyword based advertising campains across all the "networks" you had set up on the servers. Plus you could do video, pop over, pop under, one time, every x amount of page hits. etc... And control the feeds to each site in one interface. There is also http://orbitscripts.com that has an ad server. I haven't used it but it has a ton of features. So depending on what you want to do... if I only had a few sites I would just sign up with an ad server company like Adsense, Adbrite or any of the others out there and let them handle all the ads. And you can choose what type of ad delivery you want. Check what formats they supply. If you are doing your own ads then just grab a ad rotator script out there go to hot scipts or google and look for one with the pop over feature or features you want...
  6. Before you waste time getting this to work... 1) Use $_POST instead of $_GET Filter and check your POST variables too... so when they delete the pic they don't take the whole database too. And don't use Superglobals in your code: Do something like this instead... if (filter_input(INPUT_POST, 'list_direction', FILTER_SANITIZE_STRING) === NULL) { $posted['list_direction'] = ''; } else { $posted['list_direction'] = filter_input(INPUT_POST, 'list_direction', FILTER_SANITIZE_STRING); } if (filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT) === NULL) { $posted['id'] = ''; } else { $posted['id'] = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT); } 2) don't use mysql it is depreciated use mysqli or pdo 3) Use a different database / coding approch for storing and getting your images... Having column names as each image will get out of hand. Especially if you decide to add more pictures per user or page. Set a user or whatever you decide, then associate the pic based on the user Id Then you can use a POST to see if the delete button has been pushed with a hidden "id" value Remember we filtered our POST and set to $posted (or whatever you want to name it) if ($posted['del'] == 'true') { $sql = "DELETE FROM info WHERE pic_id = '$posted['id']'"; $result = $database->query($sql); etc...
  7. Most lottery sites use this type format 12/3/2012 03-05-15-18-23-36 When you download their past numbers. So using an good editor or speadsheeet program you can setup an array like this: $past_numbers = array( '9/17/2009' => '16-19-23-26-36-38', '9/21/2009' => '10-13-14-19-26-30', '9/24/2009' => '03-04-22-25-36-39'); Then foreach ($past_numbers as $key => $value) { //$key is the date. $value are the numbers //echo $value.'<br>'; $add = explode('-', $value); $array[] = $add['0']; // first number $array[] = $add['1']; // second number $array[] = $add['2']; // third number $array[] = $add['3']; // fourth number $array[] = $add['4']; // fifth number $array[] = $add['5']; // Sixth number } foreach ($past_numbers as $key => $value) { //echo "<br>'$key' => '$value',"; // Test to see the past numbers array output } echo "<hr>"; $votecounts = array_count_values($array); //arsort($votecounts); // will flip the list //print_r($votecounts); foreach ($votecounts as $choice => $count) { echo "<br>Number $choice was picked $count times."; $count_it[$choice] = $count; } Or you can put the past numbers in a database I left the "test" comments and added others in there to help you learn and for you to play with if you want... So you can see what it does when you uncomment the lines. The above was used for Sweet Millions... 6 number no bonus... If you want the bonus then just use the same foreach loop though the array again but only have this in the foreach: $array[] = $add['6']; And it will give the list of just the bonus numbers. Or you can set the array to $array_bonus['6'] or whatever then change the $votecounts line $votecounts_bonus and loop through it again. Have fun playing with it...
  8. First, (he/she) didn't fully read my question, Second, I had poked around the internet. Third, I was hoping since you guys are supposed to be the "bastions of tolerance for newbie PHP developer" You could enlighten me on a good php wrapper so I wouldn't have to reinvent the wheel. Not tell me to use a framework... Then (he/she) started it with the "A typical case of Not Invented Here Syndrome " Which I thought was rude since I was looking for a mysqli wrapper and not wanting to use a full blown framework. Wait... I forgot this is: "one of the last bastions of tolerance for newbie PHP developers, and has maintained that attitude of tolerance for the last decade." And (he/she) came back with the "3 months to code 6 months to debug..." Without even asking what I was doing to begin with... But... what was I thinking... this is: "one of the last bastions of tolerance for newbie PHP developers, and has maintained that attitude of tolerance for the last decade." But it sounds like (according to you two...) if you need to anything, you must use a framework... Irregardless of what you are trying to accomplish... This article sums it up for me there are others, but they pretty much say the same thing... http://checkedexception.blogspot.com/2010/04/why-you-should-not-use-web-framework.html It depends on what you are doing... Then you pick the tools... And FYI I use a pull-based or component-based framework, (so I can return results from multiple controllers as needed) which as far as I know, at the time, there was only one for php, Prado (Yii - started in 2008 is too but based on Prado) I wrote this software 2005, there wasn't enough support Prado and I didn't want to use java. Plus I was switching from Win / Cold Fusion / Oracle to UNIX / PHP / MySQL. (I had enough of the Allaire to Macromedia change then heard through the grapevine (I was a CF beta tester for MM) that Adobe was taking over. And after paying an arm and a leg to buy the NT, CF and Oracle server licences since 1999.) And as far as my "composer" program I actually wrote that way before composer came out, I just added the anti hacker, anti scraper and any filename extension features, because I don't want to babysit the clients servers and some of my clients use api's that charge per web request and that gets expensive when someone scrapes their site. And I will apologize for my choice of words.... I should have said "a few rude" instead of "many rude". There are many nice people on this site. But as the saying goes... it only takes one bad apple... I used to be on here helping people, not just asking questions... So it's not that I'm attracting rude people, I have seen it. So for the record... Since you are a Administrator...You can delete my account... Or will you need a framework first?
  9. Well if you were a better programmer, it wouldn't take you 3 months to write a mysqli wrapper and 6 months to debug it. Probably why you're not the "boss" and I am. FYI... it's already done and tested. Plus if you were a better programmer, you would know that there is a time to use framework and times not to use a framework. It depends on what the project is. Like when you build a house, would you use a framing hammer or a sledgehammer to drive nails? I'm guessing, you would choose the latter. The point is, use the required tools for the job. Don't over kill it or over think it. Then it won't take you 9 months to finish a simple one page project. And while I'm at it, why are there so many rude people on the this forum? That is the main reason why I have stayed away from here. I was hoping they had gotten weeded out. Guess not... so it will be another year or more before I come back. If answering questions without shoving your opinions down their throat and getting sarcastic if they don't agree with you, is is too much for you to handle, then don't answer any questions. Also have someone fix the link "Forum Guidelins" it's "Forum Guidelines" And while you are at it, go to that page and read the do's and don'ts. Pay attention to the first rules listed in both of those paragraphs.
  10. No it's a case of not wanting to add more crap than is needed to do the job.
  11. I'm not using Composer, I wrote my own Composer type program. I started writing my own mysqli wrapper. Then I can add other stuff if I want too. the closest one I found to what I'm looking for is on github: bennettstone/simple-mysqli There are some programming errors in the class. But it gave me a few ideas on how I'm going to do mine.
  12. Interesting... Didn't know about it. From what little reading I did so far, maybe a little overkill for what I need... Might have some use... have to do some more reading... Plus I already wrote a Composer type program for my programs. Went through and wrote a program over a year ago that finds whatever the programs needs to run based on the license key or whatever function is being called and installs it regardless of whatever the end-user has named the dir structure. And does it on the first time called. And then only after that, if you change the dir structure or call another function, class, module, css, jquery, javascript, etc... not found. (Kind of a anti hacker feature, like with an exploit for Wordpress 99% percent of the sites out there have the same dir structure. Being able to rename everything makes it harder for the hacker to figure out if it running the software first, and then having to try to and figure out what they named the dirs.) And it has a ton of other functions like emailing the admin on change so if someone got in and changed the code, it would tell you. And if it can't connect to the checking / upload server or if the checking / upload server hasn't heard from the server it will notify you. Has automatic anti-scraper functions, caching, full automatic seo and tag cloud and automatic 404 pages that will return information from the site and data from the internet based on whatever they tried to get at. Plus you can run the software as any extension: ,asp, cfm, html, php, jsp etc... regardless of the type of server it is sitting on without using any apache rewrite codes. I'll probably end up just writing what I want. Was hoping I could save some time... Testing and making it hacker / idiot proof takes a long time... Thanks, Bob
  13. Instead of typing: new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } Just use: $whatever = new DB(); Or Be able to handle array updates instead of typing it all out each time: $update = array( 'name' => 'Not spanky', 'email' => 'spanky@email.com' ); $update_where = array( 'user_id' => 44, 'name' => 'spanky' ); $whatever->update( 'UsersTable', $update, $update_where, 1 ); And have all the other commands shortcut like this. Basically I'm looking for a class so I don't have to keep writing the same code over and over again. connection, insert, update, etc... handle array inputs, error handling, multiple database connections, freeing memory, closing the connection, etc...
  14. I have found a few online but after using them, either they have some issues (more than I want to fix) or tons of extra stuff in there like filtering which I like to do before I call the db, or they have both procedure and OO in the same class and most have no docblocks. So if I want to do something else I have to go back to the class and look for what I want. I don't want to reinvent the wheel if I don't have to, and write my own. So does anyone know where there is a good oop only mysqli class with docblocks out there? Thanks, Bob
  15. One thing isn't a lot of things... "All of the things you listed that you tried were wrong. Irrelevant to my post. Requinix had already posted the correct way so there's no point in me re-stating it." If there was no point in re-stating it, and since you didn't bother to fully read the post to begin with, then why butt in? And since he gave me the correct answer he could have said don't do it that way because... This forum has changed a quite a bit since I started using it... So I'll be looking for a new home to ask questions and help other people... Have fun here... with your attitude... eventually you'll be by yourself.
×
×
  • 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.