Jump to content

rbrown

Members
  • Posts

    124
  • Joined

  • Last visited

Everything posted by rbrown

  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.
  16. Jessica, what do you mean by that exactly? I have noticed from reading a lot of posts that you "answer" that you seem to be more condescending than helpful. I thought the point of the forums is to help people not belittle them. Granted there are people who ask for help without trying to figure it out first. Also if you are going to answer, at least read the whole post first and try to understand it before posting. Case in point, I had listed some of what I had tried in the second foreach. If you know everything, then spread the knowledge. And explain why you should do it this way rather than another way. If not, then stop running up you post count. Or could it be, you actually have hit your head on the desk too many times?
  17. Beauty... it works... Also while I was waiting tried this and this works too... $i = 0; foreach ($xml->nation as $nation) { echo "<hr>".$nation['name']."<hr>"; foreach ($xml->nation[$i]->region as $region) { //echo'url: '.$region['url'].'<br>'; echo $region['name'].'<br>'; } $i++; }
  18. I did... " Tried setting it like this: $xml->$nation->region as $region $xml->$nation['name']->region as $region $xml->nation[name]->region as $region $nation2 = $nation['name']; $xml->$nation2->region as $region $xml->{$nation2}->region as $region $xml->{'$nation2'}->region as $region $xml->nation[]->region as $region $xml->nation()->region as $region " Just left out all the rest of the code so you could see the different ways I tried setting the second foreach.
  19. FYI... make sure your provider doesn't dump sessions after x amount of time. I had this problem where end users were complaining that they weren't logged in long enough to have to log back in again. So I had change the script to use a time stamp in the db and it would check the time stamp every time they did something on the site and if it was "in range" would let them continue, otherwise they would be forwarded to the login page. you don't need all that code... Set the time stamp $current_time = time(); then get "stored time" from db if(($current_time - $stored_time) >= 900) { go to login page }
  20. trying this: foreach ($xml->nation as $nation) { echo "nation:".$nation['name']."<hr>"; foreach ($xml->nation->region as $region) { echo $region['name'].'<br>'; } } With this: <regions> <nation url="canada" name="Canada"> <region url="abbotsford" name="Abbotsford"/> <region url="barrie" name="Barrie"/> etc... </nation> <nation url="uk" name="United Kingdom"> <region url="aberdeen" name="Aberdeen"/> <region url="barnsley" name="Barnsley"/> etc... </nation> etc... </regions> What I get is all the same regions in the first nation element. =============== Canada abbotsford barrie etc... United Kingdom abbotsford barrie etc... =============== Should be... =============== Canada abbotsford barrie etc... United Kingdom Aberdeen Barnsley etc... =============== Need to change the second foreach to pull the regions under nation. Tried setting it like this: $xml->$nation->region as $region $xml->$nation['name']->region as $region $xml->nation[name]->region as $region $nation2 = $nation['name']; $xml->$nation2->region as $region $xml->{$nation2}->region as $region $xml->{'$nation2'}->region as $region $xml->nation[]->region as $region $xml->nation()->region as $region And tried a few other things... Can't hit the right combination and I know I know what to do, but I can't seem to pull it out of my brain right now... It has been a while since I played with xml. Searched google and found somethings but the layout of the XML was different or they were using id's in the xml to index the loop. and when I tried the child loops couldn't get it to output the value only the url and name. Thanks...
  21. Or add a "add to friends list" request the person wanting the gift.
  22. you need to have each person have an ID then have a table with the ID | Gift (Optional add Wanted | Got) fields Then search by ID to display gifts. have a check box on submit will delete the gift from the list or if you use the options mark it as bought. Only problem I see is: Getting the correct person (I know of 5 people with the my name in my local area) without giving up too much personal information... way around this is no search capabilities. they have to enter the persons email address. That would stop someone from doing a search and pulling all your data or having idiots messing with the site and say they bought something for them when they didn't.
  23. 1) The error is you need to define the variable first... 2) When you do a google search, the search term must have + for the spaces if the words have spaces. Do a search on google for various terms with spaces and quotes and with outspaces and quotes and look at the url you will see how you need to format the search results. FYI if you try and run this or a scrape off a server they WILL block your server... They check requests by IP address and number of requests... You will get a bot block screen. Been there done that...
  24. yeah... after doing some more poking around I see it's either jquery or ajax... Was trying to avoid having to use / learn it. Reading about css3 and html5 and the different options and then trying to put it all together with my script (you can type any url and it will give you a search result. with no 404 error) which is driven off one page with no database and no apache rewrites was tricky enough. I got it to output the browser window size and it works pretty slick, except you need to refresh the screen to see change after you resize the browser. This wouldn't be a problem because most people don't resize their browsers while surfing. But I can't get it to a php var (from what I have found so far) unless I use jquery or ajax. So I guess it time to start reading... Thanks, Bob
  25. rewriting one of my search engine sites (using Bing API) to use html5 and now I'm at the templating part and I want to check the browser window size before I output the php. The site is written so it does a lot of preproceesing before it out puts the page. Like: builds all the meta tags. strips all the coding and gets the keywords based number of times the word is used. then it will output them from high to low or low to high or random mix, will change case and add additional words and allow you to set the total number of keywords displayed and of the addtional are pre post or mixed into the total. builds a tag cloud. has template switching so you can preset christmas, easter, etc... templates and it will switch them based on the day range set. has ads switching for amazon or ebay where it will change the ads based on the search term. I have it so it works displays perfectly from a browser, to a tablet, to a phone... except for the ad sizes are too big. So I need to switch the the ads size based on the browser size. So anyway.... what I'm trying to do and I'm not a javascript wizard, is get the browser window size so I can change the ad size... so if the window size is smaller than X it will display a smaller ad. Like with css3 where you can switch the css with the @media handheld, only screen and (max-width: 767px) setting. I found this, but I'm not sure how to get it to a php var. I would run this while it is getting the rest of the page set then have it switch the php code for the ads. Like... if($width > etc... <script type="text/javascript"> function getWidth() { xWidth = null; if(window.screen != null) xWidth = window.screen.availWidth; if(window.innerWidth != null) xWidth = window.innerWidth; if(document.body != null) xWidth = document.body.clientWidth; return xWidth; } function getHeight() { xHeight = null; if(window.screen != null) xHeight = window.screen.availHeight; if(window.innerHeight != null) xHeight = window.innerHeight; if(document.body != null) xHeight = document.body.clientHeight; return xHeight; } </script> So how would I get and set the "getWidth()" to a php var? Or do you have any other suggestions on reinventing the wheel? Thanks, Bob
×
×
  • 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.