KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
With my marvelous MS Paint skills, I've made a couple of rough images illustrating what I mean: The black question mark boxes highlight the empty space you have in the vote box.
-
In the future, please post code in either or tags. I took the liberty of doing it for you this time.
-
Didn't have time for a fleshed out example, so I highlighted the most important part. A WHERE clause should be obvious to all but newbies.
-
I think you can make a few tweaks: Index page: 1. Make the tutorial titles bold. 2. Swap the tutorial author info block from the tutorial title/preview block. Since your site is in English, which reads left-to-right, the most pertinent info should be first. In this case, the tutorials are why people are visiting, so make it first on each row. 3. Instead of a generic 'View More' link at the bottom, maybe some pagination? --- With the tutorials themselves: 1. Again, swap the position of the author info box and vote box with the tutorial itself. 2. Widen the tutorial box. It's so tight that just about every line of code wraps. 3. Remove the wrap from the code boxes anyway. For code, I'd rather it scrolled, like with Stack Overflow. 4. You have a ton of wasted space in the vote box. Streamline. 5. You don't need two big 'G' images on the tutorial (one in the vote box, one on the tutorial itself). Leave one, but remove the other. --- All that said, very impressive. Just remember that the stars of the site are the tutorials. Do what you can to highlight them.
-
If statement stopping page from working?
KevinM1 replied to liamloveslearning's topic in PHP Coding Help
-
editing site content - where is content located?
KevinM1 replied to jfenley's topic in PHP Coding Help
Like others have said, Wordpress is actually a PHP script itself. Also, when you edit content in Wordpress, what's really happening is the following: You click on something that tells the system what content you wish to edit. This site interaction sends a HTTP request to the Apache web server, which invokes the proper PHP script. The PHP script parses the HTTP request, and queries the database with the request data. The PHP script then takes that database data and renders it to the screen, along with the rest of the site (images, HTML, CSS). What you edit is database data in a web form. When you click 'Save' or 'Submit', the process repeats, this time with the data being saved to the database rather than received from it. So, needless to say, yes, we understand your problem. Unfortunately for you, like xyph said, PHP Freaks exists to help coders. Since you're lacking even the basic fundamentals of how the web itself works, we cannot help you. Your best bet is to hire a professional before you mess up your own system. -
Have you actually instantiated your object? As in: $Popmonger = new Popmonger();
-
Is running two queries msot efficient? No, it's less efficient, but unless you're pulling a lot of data, you probably don't need to worry about it too much. And, again, I provided you the information you need to combine queries in my post above, anyway, in case you discover that two queries create too much of a bottleneck for your system.
-
You are not returning a query. You are running UPDATE queries. Since you are using an "or die()" condition on the query calls (instead of properly handling them) you would ONLY EVER return from this function IF BOTH QUERIES successfully ran. So, you don't need to return anything. If there are errors the "or die()" statements will prevent any further execution of the script. So, let the function run, if the function completes, then you know both queries ran. I didn't realize that. I thought you always had to return something. Am I completely wrong about this? How do you know when to return data and when not to? You return data when you need to have the results of the function in your main code.
-
PHP has exceptions and try/catch blocks, if that's what you're looking for. http://php.net/manual/en/language.exceptions.php
-
<?php if(isset($_POST['submit'])) { $postCode = $_POST['post_code']; } ?> <form action="keep.php?" method="post"> Enter Your Postcode:<input type="text" name="post_code" maxlength=4/> <input type="submit" name="submit" value="Enter" /> </form> <?php if(isset($postCode) && !empty($postCode)) { echo "Your Postcode: $postCode"; } ?> You should really get yourself a decent book to learn the fundamentals. I used the previous version of this one back in the day: http://www.amazon.com/PHP-Web-Visual-QuickStart-Guide/dp/0321733452/ref=sr_1_3?ie=UTF8&qid=1309388723&sr=8-3
-
Can you show your code? Ideally, POST should be used when posting data to your system (database, files, email, etc.). GET should be used when retrieving or getting data from your system. On the surface, they both look to do the same thing, but I believe in a semantic web, where the tools we use denote meaning in the using of them. POST and GET have different intents. Use them according to those intents and things get easier.
-
editing site content - where is content located?
KevinM1 replied to jfenley's topic in PHP Coding Help
Chances are, the content is stored in a database, and not within files/folders. -
But, yes, if you want to update everything in one query, you can simply use dot notation: "UPDATE table1, table2 SET table1.column = someValue, table2.column = someOtherValue" http://dev.mysql.com/doc/refman/5.0/en/update.html
-
What's stopping you from simply running two queries?
-
You shouldn't process your form unless data has been submitted. Also, well-formed PHP scripts do their processing first, then display results. So, you should roughly do: <?php if(isset($_POST['submit'])) { // process POST data } ?> <!-- show HTML form. Note that there's no else-clause - we want the form to be displayed regardless of whether or not data has been submitted --> Within that framework, you can display form results wherever you want, so long as they exist.
-
You want: if(($descText == '') || ($descText == ' ') || ($descText == null)){ $descText = $altText; } Note only one '=' for assignment, '==' for equals comparison. You should also look into empty.
-
calling array in a function which were previously set
KevinM1 replied to freelance84's topic in PHP Coding Help
Which is a horrible way to pass in any parameter to any function, and definitely shouldn't be recommended. Simply put, if you use 'global' in any manner, you're doing it wrong. @OP - you have two legitimate options when passing a parameter into a function - by value, and by reference. Pass by value is what PHP uses by default (except with objects). Essentially, it creates a copy of the value you pass into the function. The value outside of the scope of the function is not affected unless it is assigned the return value of the function. Example: function addFive($value) { return $value + 5; } $num = 6; addFive($num); echo $num; // <-- will still be 6 since we didn't capture the return value. The COPY of $num was 11, briefly, but is destroyed upon function end since it's not returned $num = addFive($num); echo $num; // <-- will be 11 The other option is pass by reference, which sends the reference of the value to the function. This results in out-of-scope changes since you're doing more than simply sending a copy to the function. Example: function addFive(&$value) // <-- the '&' denotes reference { $value += 5; } $num = 6; addFive($num); echo $num; // <-- 11 The problem with dealing with references is that it creates side effects. They make it easy to write confusing functions that can have multiple simultaneous results. Use them with caution. More info: http://php.net/manual/en/language.references.pass.php http://www.php.net/manual/en/language.references.php -
carlito.way00: Like I said in your previous topic, place any code you post within or tags. I have done it for you the last two times, but this is the last warning.
-
There's no perfect 1-to-1 conversion from ASP to PHP. You say you already have a PHP form which can send emails. Why can't you simply modify that form to fit your needs? That's an easier way to approach the problem than trying to convert languages.
-
To be honest, I'm not entirely sure what your problem actually is. Are you trying to add a new row to the database, and it's merely updating an existing row? Are you trying to update an existing row, and it's creating a new row? Is your pagination working correctly for existing entries?
-
What query are you using to send your data to the database?
-
In the future, please place code within or tags.
-
Very boring. It's alright structurally, although it looks like you simply took your own site layout and changed the color. Black websites, when done well, can look amazing. That said, it's very easy to make a black site look like it's coming from someone trying too hard to be edgy or cool. This layout falls into that category. Look at the following list of dark websites for inspiration: http://webdesignledger.com/inspiration/50-inspiring-dark-web-designs
-
Yes. In PHP 5 objects are automatically passed by reference.