Jump to content

maxxd

Gurus
  • Posts

    1,718
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by maxxd

  1. You need JavaScript to do this. The extra files you allude to are probably LightBox, FancyBox, or Pretty Picture plugins. You'll need to download the files, upload them to your server, include them in your HTML, and then tag the images according to the docs for plugin you choose.
  2. Where are you setting $customernumber? Make sure you have error display turned on and see if the code is throwing any errors. You may also want to simply echo out $path and make sure you're looking where you think you're looking. Other thing, please be sure to use the code button [ <> ] in the text editor when posting code. It makes things easier to read.
  3. The username variable is not being passed by the sending page. Basically, however you get to this script is the issue. If the link on the sending page is "http://mysite.com/mypage.php", then it needs to be "http://mysite.com/mypage.php?username=myusername". If you're sending from a form, you'll need to make sure the form method is 'get' and there's a field in the form named 'username'.
  4. IMO, skip MysqlI and look into PDO - it's easier to use with prepared statements and parameter binding. The queries you've written are wide open to SQL injection. Using prepared statements will mitigate that risk.
  5. @requinix - good points all, and thank you for the in-depth explanation!
  6. I'll have to do some digging into regex - as I should have said, I'm terrible at them. I can't even read your string . Good point about double spaces, but wouldn't using array_filter() remove any empty elements? And exploding on a space would keep the periods at the end of words because it's before the space (or double space). Also, what non-word characters would have to be exploded upon? Interesting discussion about a topic I know woefully little about (let me know if this is now veering way off topic and I should open this in the miscellaneous section), so thanks much for expounding and explaining!
  7. I'm certainly not the best at regular expressions, but wouldn't it be easier to explode the sentence on ' ' and loop through the resulting array? $words = explode(' ', $sentence); for($i=0; $i<count($words); $i++){ if($i%2 == 0){ $words[$i] = 'MOD'; } } $sentence = implode(' ', $words); print("<p>{$sentence}</p>"); Or am I overlooking something obvious?
  8. Your links are incorrect to the actual javascript files - wowslider.js is not found on your server. Make sure you uploaded the files into the correct directory - www_root/old/steamsource/engine1/wowslider.js is where the page is looking for the script right now.
  9. Just to throw in here, I agree that starting with a procedural style does lessen the learning curve for the language as a whole. Once you're truly and thoroughly comfortable with php's functions, stylistic conventions, and quirks, you can set your eyes on OOP. The nice thing, as I'm sure you've already seen, is that php itself is becoming more and more object-oriented at the source, so you'll come across some to quite a bit of it even as you're learning procedural php and that should make the transition a little easier once you get to that point. As for OOP being overkill, I think it can be on occasion. That being said, I do find it easier (now, anyway) to code with objects in all of my projects. I work with WordPress every day and all of my custom code involves objects and classes; sure, the patterns may not be as robust as they would were I maintaining or creating a full-fledged framework or larger integrated system, but I do find it easier to think in terms of objects and classes. So now, any project I start from scratch is written OOP-style from the outset, then refactored as I go on for pattern adherence and ease of use and maintenance. Again, this is now - it took a lot of time for that shift in thinking to happen, and it was gradual and is still ongoing. That's really the biggest thing. You'll never completely learn php (or anything, really), so to answer your question - yes, you should include OOP in your learning schedule. You just don't have to include it yet - there's plenty of time, and plenty to learn.
  10. Plenty of suggestions right here.
  11. For storing the completed task list, I'd create a secondary table (completedTasks, maybe) and store the user ID and task ID. Only store a record if the task is complete - that way a simple join in your query will let you know know what's been finished and what's not. If you want, you could include a status column so that you could later allow the user to track percentage done, etc. As for the rest of your question, let us see your code as it stands now. It's difficult to offer advice and help if we don't know the starting point.
  12. If you only want to display the first index in your array, you don't need a loop at all. just print $events[0]. I get the feeling there's more to the code that we're not seeing, so it does make it a bit difficult to do anything other than throw something at the wall to see if it sticks...
  13. Turns out the #secondary aside was behind another div, which was blocking the mouse event. Yup, tired....
  14. Hey y'all. I'm either having a major brain fart or my eyes are entirely too tired today. I've got the following (this is obviously excerpted), and the :hover event on the #secondary aside is not firing in the HTML itself. In Firebug, selecting the :hover state for the #secondary aside behaves as expected. It just doesn't if I actually hover the mouse over the aside. Can anybody see what it is that I'm missing here? <style> #secondary:hover img, .entry-content .featured_image:hover img { opacity: .3; } #secondary:hover .testimonial, .entry-content .featured_image:hover .testimonial { opacity: 1; } .testimonial { position: absolute; top: 50%; left: 50%; -ms-transform: translateY(-50%) translateX(-50%); -webkit-transform: translateY(-50%) translateX(-50%); transform: translateY(-50%) translateX(-50%); width: 90%; font-weight: 700; font-family: 'Source Serif Pro', 'Georgia', 'Times New Roman', serif; color: #ffffff; opacity: 0; -webkit-transition: all 500ms ease-in-out; -moz-transition: all 500ms ease-in-out; -o-transition: all 500ms ease-in-out; transition: all 500ms ease-in-out; } </style> ... <aside id="secondary" class="right" role="complementary"> <div class="bg"><img src="http://mysite.com/path/to/existing/picture.jpg"></div> <div class="testimonial">"This is a testimonial" - a person</div> </aside>
  15. Try changing divobj.innerHTML = PremAmount.toFixed(2); to divobj.value = PremAmount.toFixed(2);
  16. In JavaScript, '+' is the concatenation operator. So, if your number is internally a string, ' + 1' will append the string '1' to the current value, thus turning '1' into '11'. As Muddy_Funster suggests, using parseInt() on the current value will make sure that JS sees the value as an integer and adding 1 will actually add 1 to the total.
  17. You've also got some problems beyond the sessions stuff as well. First off, the mysql_* functions are deprecated and scheduled for removal in the very near future. Check out PDO or mysqli classes. Secondly, you've got some issues here: $query = mysql_query("select * from members where password='$password' AND username='$username'", $connection); $result=mysql_query($sql); You're querying the database twice, and the variable $sql is undefined. You should be getting errors - do you have error reporting and display turned on? In addition to that, selecting all records, then running mysql_num_rows() on the result is inefficient - try this instead: SELECT COUNT(*) AS num_rows FROM members WHERE password = '{$password}' AND username='{$username}'; You can then check $result['num_rows'] after you run the query. One last thing - I don't see where you're encrypting your passwords before storing them in the database. You're not just storing plaintext passwords, are you?
  18. It's not that the code looked clunky, by any means. It's the base logic behind the data flow that I'm questioning. By calling to the database to get NOW(), you've used network and system resources to get the date; this is something very easily obtainable either from php or within the query itself, both of which negate the need for the first query which cuts down on network and system resources. It's sort of akin to using a JOIN in sql as opposed to running a sub-query on every loop through the result set of a parent query. Or, better yet, you wouldn't run a query to get all the user ID's from a table, then run an individual query for each user ID to get the user's name, right? And don't forget - as Psycho said - the point of this board is for everyone to learn. If you have a question, ask away - you'll probably learn something from the answer, and there's a good chance the people giving the answer will learn something, either by answering the question or from another user's answer (QUARTER() function, I'm looking at you). It's a win-win situation!
  19. @Landslyde, I gotta admit I couldn't agree more with Pyscho on this one. The way you've got it set up now is wasteful, resource-wise, and unnecessarily complex. When I typed out my answer, I'd read your question incorrectly in that I thought you had set the $year variable earlier in php - I chalk that up to lack of sleep. Psycho's query with Barand's suggestion of using the QUARTER() function is going to offer you the most flexibility and least unnecessary maintenance. As well as offering the fastest return time; as I said in my response, using substr() isn't the best idea, especially if you're not pulling the date from user input to inject into the query later.
  20. At the top of your code, add the following: if(!empty($_POST)){ print("<pre>".print_r($_POST,true)."</pre>"); }else{ print("<p>\$_POST is empty</p>"); } Just to make sure your post variables are being set like you think they are. The code looks like it should work (of course, I could be overlooking something obvious - I have a new puppy and am a bit sleep deprived), so making sure everything in post is set and indexed as expected should help a bit.
  21. There are a couple different ways, right off the top of my head. The easiest would be to convert the $year variable that you set earlier into a DateTime object, then pull the year right from that. No fuss, no muss. You could always use substr(), but I do think the first option is going to be easier.
  22. Another benefit to using interfaces is that you can type hint to the interface, like so: interface iMyInterface{ function sayHello(); } class TestOne implements iMyInterface{ function sayHello(){ return '<p>Good day!</p>'; } } class testTwo implements iMyInterface{ function sayHello(){ return "<p>'sup?</p>"; } } class EverybodyPolite{ public static function greet(iMyInterface $greeting){ print($greeting->sayHello()); } } $p1 = new TestOne(); $p2 = new TestTwo(); EverybodyPolite::greet($p1); EverybodyPolite::greet($p2); While you can drop the type hint from the public static greet() method, having it there increases readability of the code and the possibilities that the code will function as expected because you know that the object passed in to the calling method functions (at it's base) in a defined way.
  23. maxxd

    php c

    You're not using variable in your while() loop at all. Also, you don't assign a value to $i, which should produce a division by zero error on every iteration of the loop. It's way too early for me to do math, but figure out what value to assign to $i, and make k and i variables in your while loop like so: while($k){ if($k%$i == 0){ echo 0; } if($k == $i){ echo 1; } }
  24. Explain 'not working'. The cookie isn't being set at all, the value isn't being read from elsewhere, the value is not what you expected to see, what? And are you trying to set a cookie, or a session variable? It seems like you don't know, and there are differences between the two that can dictate which is the proper choice.
  25. You want a switch statement. Basically: switch($var1){ case 1: $var2 = 'a'; break; case 2: $var2 = 'b'; break; case 3: $var2 = 'c'; break; }
×
×
  • 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.