-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
It looks like there's a setting panel somewhere that allows you to set the height and width of the logo image? (I'm basing this off the calls to it_get_setting() using 'logo_width' and 'logo_height'). If this isn't actually what's happening, you should be able to override the sizing of the image via CSS like this: #site-logo, #site-logo-hd{ width:150px !important; height:150px !important; }
-
Thank you - you're absolutely right!
-
Do you have error reporting turned on? It looks like you're attempting to assign values in $_POST to variables before you're actually checking to see if the form has been submitted. That could be throwing you off.
-
If I'm reading your question correctly, you're going to want to look into the GROUP BY clause. Something along the lines of SELECT a.city_name ,SUM(b.citizens) AS numCitizens FROM table1 a LEFT JOIN table2 b ON a.cityID = b.cityID GROUP BY numCitizens No guarantee this will work if you copy and paste it (I'm only on my second up of coffee this morning), but it should get you moving in the right direction. Also, note that this assumes a foreign key of cityID in both table1 and table2 which you use to make the join.
-
Also note that PHP will index both the $_GET and $_POST arrays by the HTML 'name' attribute. So, if you have <input type='text' name='a_text_box' id='my_name_is_earl' value='yuuuuuup' /> You would access that field using $_POST['a_text_box'], and it would print 'yuuuuuup'. However, attempting to access $_POST['my_name_is_earl'] will return an error, as that index does not exist in $_POST after submitting your form.
-
If this is the exact output from print_r($_POST), then there's an issue. The index is not 'fruitid', it's 'select'. When you view the HMTL source of your page, does the hidden field show the correct fruit id value? Try giving your select element a name attribute, and run 'print_r($_POST,true);' again and see what it has to say.
-
Has anyone created graphs on php based on functions?
maxxd replied to moose-en-a-gant's topic in PHP Coding Help
HighCharts is a very good JavaScript library for doing exactly this. It's not PHP, I know, but it could be worth looking into. -
It would be very good to know what exactly isn't working, but in the meantime you need to set up error checking on your queries. Don't just blindly assume that the query executed properly. Turn on error reporting and set up some checks on those queries - I'll bet that'll tell you pretty much exactly what's going wrong.
-
If you've got the shadow set up as a separate div or span in your navigation, wright67uk is correct about just turning the display off. If it's set up as a style on, say, a list item element, you'll have to turn it off property by property at the lowest screen width you want to display it. As an extraordinarily simple example, #nav li{ font-size:1.25em; text-shadow:2px 2px rgba(0,0,0,.4); } @media screen and(max-width:640px){ #nav li{ text-shadow:none; } } So, when the screen is under 640 pixels wide, there won't be a text-shadow in the #nav menu list items. Above 640 pixels, the line item has text shadows.
-
same exact code works on one page, not the other, am I blind?
maxxd replied to moose-en-a-gant's topic in PHP Coding Help
And make sure you have error reporting turned on during development: error_reporting(-1); ini_set('display_errors',true); -
Cannot redeclare class - Location where it was declared unclear ..
maxxd replied to rhand's topic in PHP Coding Help
I don't know if it's applicable to your situation (or why it's happening, honestly) but recently I've come across a couple situations where using get_template_directory() or get_template_directory_uri() from a child theme will return the parent theme's directory. Which, obviously, breaks a lot of things. I wrote the following method into one of my functions classes to get around it: private function getTemplateDirectory(){ $curTheme = \wp_get_theme(); return str_replace(strtolower($curTheme->get('Template')),strtolower($curTheme->get('Name')),\get_template_directory_uri()); } Not sure if it helps, just thought I'd throw that out there. -
Your prepared statement is correct - you don't need to put the quotes around the question marks. Single vs. double quotes is a deceptively large conversation... When are where to use either or both is largely a question of taste, though there are some hard and fast rules to remember. For the base of it, remember that you can't mix and match the two, but you can nest them. So, if your string assignment starts with a single quote, it has to end with a single quote. That string can include double quotes without problem, but any single quotes in that string will need to be escaped. The same goes with nesting double quotes inside double quotes. Also, php will parse most variables contained within a string using double quotes, but will not when using single quotes. Hopefully this will make some sense... $string = 'This starts with a "single quote" and ends with it, too...'; //this is fine $string = 'This starts with a 'single quote' and will cause your script to barf'; //nope $string = "This starts with a 'double quote' and ends with it, too..."; //also fine $string = "Look! more "barfing scripts"!"; //still nope $string = 'Starting with a single quote means I\'ll have to escape any other single quotes inside this string.'; //note the backslash before the single quote - that's necessary $string = "Same thing with \"double quotes\""; //again, escaping... $variable = "Hidee ho, matey!"; $string = '$variable will not parse...'; //contains the string $variable will not parse... $string = "$variable will parse..."; //contains the string Hidee ho, matey! will parse... As for the question about $link, yes, you can use the same connection multiple times. If you need to run several different queries, you should use the same connection object and pass the different query strings to that connection object. If you're concerned about multiple instances of your database connection object being created and used, you can look at using a Singleton pattern for the the connection object, which theoretically will enforce there being at most one instantiated object of the class at a time. Now, you could have an issue if $stmt gets overwritten before you're done using the original value. For that, you just need to format your code and approach logic trips carefully. Make sure you've gotten all the use you need out of the original $stmt query before you write a different value to that variable. Some folks will argue that using the same variable names leads to confusion within a script, and I agree with that, most of the time. However, other times it makes perfect sense to do so, so just think about what you're doing, and document your code like it was your second job.
-
First and foremost, you'll want to turn on error checking at the top of your script error_reporting(-1); ini_set('display_errors',true); Secondly, and I don't know if this is a forum-related thing or not, but the lack of indentation in the code makes it difficult to read and follow what's actually happening. I thought for a second you had an improperly nested if-else loop, but I missed an opening bracket earlier in the code. Also - just as a side-note - mac_gyver is absolutely correct about the issue with the repetition in the code. You're typing way too much, but that's a thing for later. Right now, turn on error reporting and see what that has to say.
-
Thanks for the link, ignace - I'll give that a read this weekend!
- 4 replies
-
- git
- sourcetree
-
(and 1 more)
Tagged with:
-
That's pretty much what I figured, but I always like to check with people who know better when I have the opportunity. Thanks so much!
- 4 replies
-
- git
- sourcetree
-
(and 1 more)
Tagged with:
-
Hey y'all - I have a quick question. [edit - As I type, it's becoming a not-so-quick question. Sorry about that, but I'd very much appreciate any input.] At work (we're on osX) we've recently switched to using Bitbucket with SourceTree for our version control system. I've got many project directories, already populated with working files. They're under SVN control, but honestly our SVN repo is a bit of a mess and I'm hoping to start over. My process for creating GIT repositories for each of these project directories using SourceTree is as follows: In the bookmarks window that pops up when I launch SourceTree, I click '+ New Repository' > 'Create Local Repository', then I use finder to navigate to the populated project directory and select it. I click 'Create Remote Repository', then click 'Create' to create the local repo. After filling out the remote repository owner and description, and marking it private, I click 'Create'. Then, in the browser window for the newly created repository that appears when I double click on the bookmark, I stage all the files in the local project directory and commit them. I then push that to the remote master branch. My question is this - is using the SourceTree 'Create Local Repository' option as described above equivalent to using the terminal window and 'git init' in the project directory? Everything seems to be working correctly (I've successfully committed and pushed files to the remote repositories), but I've only been using this setup for 2 days and haven't done any real heavy lifting with it yet - no branching or merging or anything of the sort. I have successfully cloned one of the repos on a secondary system, but haven't had a chance to make changes on that secondary system and commit then push them to make sure everything is actually working correctly. It certainly seems like all is well, and I have done more thorough testing on my home system, but that's a Windows box and the Windows version of SourceTree is quite different from the Macintosh version. Really, I decided to go with ST because I just don't like the command line and the price was right (free), and I'm trying to learn it as I go. I just don't want to be five or six months down the line and have to make a major change to a project only to discover that I messed up something very simple with the repository initialization and nothing's working like it should... Hopefully this is a dumb question and I'm just being paranoid, but I'd very much appreciate any input anyone with SourceTree experience has and is willing to offer.
- 4 replies
-
- git
- sourcetree
-
(and 1 more)
Tagged with:
-
Also, as long as you're using MySQLi, why not do it right and use prepared statements to avoid the SQL injection possibilities your script currently has? You're already a bit ahead of the game by using mysqli_* instead of mysql_*, so why not go all the way?
-
First and foremost, add_action() and add_filter() are WordPress hook functions - they're specialized global functions that allow the developer to inject a custom function into the core functionality at specific points. So, in your case, at the point that the WordPress core calls after_switch_themes, it will call the user-defined function after_switch_theme_example(). This, by the way, a simplified explanation... Keep in mind as you're learning: WordPress - from a modern programming point of view - it's really not very well written. The reliance on global variables and functions, and some of the ways in which what classes there are are used is just backwards and old-fashioned. From an end-user point of view, it's great - it allows you to do a lot of things for very little effort. However, it can become rather frustrating quickly as you develop for it. And as far as PHP books and tutorials go, there's a literal ton of them out there but you need to be a little careful because a lot of them are old and PHP has changed a lot in the last several years. If you see a lot of $_REQUEST variables, the keyword global, or any kind of hashing using md5, just assume it's out of date and won't be of much practical help to you. I don't know of any good beginner tutorials or books right off the top of my head, but hopefully someone can kick in with an example or two for you.
-
I need to know why rank is been update for the username that has been set
maxxd replied to Renato's topic in PHP Coding Help
You're not using the $sql_user variable in your update queries, you've got it as a string. So, change the following lines: $data1 = mysqli_query($connection, "UPDATE member SET rank= '1' WHERE username='sql_user'") or die (mysql_error($connection)); $data2 = mysqli_query($connection, "UPDATE member SET rank= '2' WHERE username ='sql_user'") or die (mysql_error($connection)); to $data1 = mysqli_query($connection, "UPDATE member SET rank= '1' WHERE username='$sql_user'") or die (mysql_error($connection)); $data2 = mysqli_query($connection, "UPDATE member SET rank= '2' WHERE username ='$sql_user'") or die (mysql_error($connection)); That's the first thing I see right off the bat... -
Yes, yes it is... @codexpower - the biggest thing is that WordPress is huge, and asking for tutorials on how to <airquotes>program for it</airquotes> really isn't the way to go. If you've got a specific issue with a theme or plugin you're currently using that you want to fix or improve upon, start by working on just that issue. Basically, give yourself a project and set yourself a goal, then use PHP.net, the WP codex, and the many tutorials on the web to work towards that goal. When you get stuck, then ask a specific question here. We're all more than willing to help, but we need to know what we're helping with, you know?
-
There's many, many tutorials on writing WP plugins. https://www.google.com/#q=creating+wordpress+plugins http://codex.wordpress.org/Writing_a_Plugin There's also more than a few books on the topic - this one is not bad for beginners. Check out some of the links, give a few things a try, and ask any questions you may have - good luck and enjoy the trip!
-
You're still using a style sheet with Barand's suggestion. The only thing the code he presented is doing is creating a dynamic class name depending on the day's schedule. Parse the code and read the helpful comments - if there's a booking on that day, the code checks to see if there are free time slots. If so, it applies the 'partial' class tag, because the day is partially booked. If there are no free time slots on that day, it applies the 'full' class tag, because the day is fully booked. In your style sheet, create the .day{}, .partial{}, and .full{} class style definitions and you should be good to go. There's not a lot to understand with this part of it.
-
OK - so you're not storing serialized data in a table field, but serializing it before you try to convert it to CSV? 'Cause now I'm a bit confused, I think...
-
Use JQuery - it'll make your life much, much easier.
-
I'd be interested to know why it won't work. What you describe with the 5 or 6 table set-up all joined on UserID is exactly how a relational database should work - hence the 'relational' in the name. If a DATETIME field is conflicting with what you're doing, then honestly you're handling that data incorrectly. Serialized data crammed into a VARCHAR or TEXT field may seem like it works when it's set up, but it will almost always come back to bite you in the butt later on.