KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
When attempting to interpolate an array value in a double quoted string, you need to stick it in curly braces. Example: echo "top.location.href = \"{$_GET['url']}\";";
-
You need to check to see if the voucher code exists before using it: if (isset($_GET['vouchercode'])) { $_SESSION['vouchercode'] = $_GET['vouchercode']; // <-- you should validate and sanitize this before using it, but that's another topic // continue with voucher code stuff } // continue with non-voucher dependent code
-
RE: commenting, you should write doc blocks before the definition of each function, including main. Write it along the lines of PHPDoc (http://www.phpdoc.org/), or whatever C++ devs usually use. That will take care of about 90% of it right there.
-
Sanitizing, how's the best way of doing it?
KevinM1 replied to Matt Ridge's topic in PHP Coding Help
Locking this thread because you don't know what you're talking about, and this discussion has run its course. -
This. Tables should only be used for tabular data, not for layout. You also need a doctype to ensure that the site looks correct in all browsers. A simple: <!doctype html> would suffice. Also, as was said above, you should use sprites for your images. Google 'CSS image sprites' for tutorials on that. I'm not a fan of colored backgrounds with text. Unless it's a white or black background, I find it to be distracting. The animated .gif of the American flag looks hokey. That kind of thing hasn't been in style for ~7 years or so. A static image of a red, white, and blue ribbon would suffice. For your 'Flags' page, why are some larger than others? And why do some have captions while others do not?
-
RE: The form - looks okay to me, as you've taken into account the possibility of the user having disabled JavaScript. Regarding the rest of the site: Colors are a lot better than they were, but some of the same issues remain (e.g., serif fonts, boring/plain/small images, etc.). I'd make your main navigation larger. It's the smallest element on the page, which belies its importance. Page-by-page: About Us: Much better. Decrease the margin between the title and the content a bit. Also, make the top of the boxes on the left match the top of the text on the right. Finally, do more with your 'Email Us' link. Write out the full address, like: Email: address@domain.com And make the email address an actual hyperlink. You should also remove one of the 'About Us'/'Contact Us' links from your main navigation. You shouldn't have two links going to the same exact information. Vehicles: Solid. Nothing jumps out at first glance. Services: The heading of "Eurostar St Pancras / Ebbsfleet / Ashford" needs to be moved away from the left border of the content area. It also needs some separation from the text below it. Finally, try using the boxes on the other pages (like Vehicles) for the bottom three boxes here. The current boxes on this page don't mix with the rest.
-
I'm so, so, so sorry. Not as sorry as me.
-
I'm currently making a new WP theme for a client. It's my first time working with WP in any capacity. I'm left wishing I didn't pop my WP cherry. It sucks, and 'The Loop' is moronic.
-
Please don't bump threads that have been dead for [b]~8 years[/b]. Locked.
-
Go here: http://www.php.net/quickref.php Bookmark it.
-
Have you tried replacing the short tags (<? ?>), which aren't always supported, with proper PHP tags (<?php ?>)?
-
The main navigation is nice and simple. The big image in the middle of the page is horrible. Too big, too busy, too cramped. Suggestions: You only need the phone that's in portrait mode to get the point across. Ditch the other one. You also need to create separation between the phone and the text in the image. Right now they're essentially touching. You also need to find a way to incorporate the QR code more organically. --- For the secondary navigation, see how it would look if it was higher up in the page. Try shrinking down your main image and moving the left-hand menu up. The 'C' in 'Cran' is cut off in the footer. Also, the 'Questions' bubble blocks out your copyright.
-
What you need is a version control system. Look into Git or Subversion.
-
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349906.0
-
Using PHP OOP concept connecting to MySQL database
KevinM1 replied to raaks's topic in PHP Coding Help
Better still to use dependency injection, so you don't blow scope all to hell. -
how to get single vars from a mysql_fetch_array()
KevinM1 replied to son.of.the.morning's topic in PHP Coding Help
You can't access sequential records without a loop, AFAIK. The fetch functions only return one row at a time. Calling a fetch function repeatedly moves its internal pointer to the next row, which is why it's used in a loop. For what you want to do, using a loop is the best way to go about it. -
how to get single vars from a mysql_fetch_array()
KevinM1 replied to son.of.the.morning's topic in PHP Coding Help
You mean something like this: $query = "SELECT * FROM blog_posts ORDER BY id DESC LIMIT 5"; $results = mysql_query($query); while($row = mysql_fetch_assoc($results)) { echo $row['title']; } ? I ask because that's pretty much the universal pattern for retrieving and doing something with multiple rows of data. -
how to get single vars from a mysql_fetch_array()
KevinM1 replied to son.of.the.morning's topic in PHP Coding Help
If you'd rather access your row data by column name, use either mysql_fetch_assoc, or use the MYSQL_ASSOC flag in mysql_fetch_array. -
PHP Is Eating My Little Green Buddha - Foreach Loop Help Needed
KevinM1 replied to schizoman's topic in PHP Coding Help
As for why the first example doesn't work, it likely has to do with the way foreach works internally. It's probably getting messed up due to where its internal iterator pointer is in the collection. That said, you're not doing anything useful with your canned example anyway since you're directly accessing the array elements. If you're going to do that, you don't need a foreach. -
PHP Is Eating My Little Green Buddha - Foreach Loop Help Needed
KevinM1 replied to schizoman's topic in PHP Coding Help
$pqPhrases is NOT the same thing as $pqPhrase.... -
Sanitizing, how's the best way of doing it?
KevinM1 replied to Matt Ridge's topic in PHP Coding Help
Sorry to bring this up again, but I've been busy in real life. I asked for examples of how it is used, I would of figured that people who use these functions all the time would say, when posting, use it like x, when editing use it like x, when showing data use it like x. There were about 5 pages of that. And those circumstances are context-dependent. Or do you think that a cardboard box company has the same data requirements as a bank? You had a link to a tutorial site which said more or less what we did, with a variety of code examples. Good luck. PHP is considered one of the easier languages to learn. Moreover, the problems of validation and sanitizing are universal. If you're going to be writing code for the web, you'll run into the same thing, handled in similar ways, regardless of language. -
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349798.0
-
Looking for feedback on our new layout and design
KevinM1 replied to jasonc's topic in Website Critique
Sounds like a OOP rewrite is in order if the back end had to be scrapped a couple times.... -
Yes, it's definitely possible. Since we, here at PHP Freaks, like to teach best practices, this is going to be a fairly long message. You're doing some things that will only cause headaches for you down the road. Things that are better to correct now, when you're a beginner, rather than later. Don't mix PHP and HTML when you don't need to. One of the greatest 'problems' with PHP is that it allows one to embed their script code within their HTML code. The way to write good PHP scripts is to do all of your data processing first, then store the results in variables. You can then easily output them with a small amount of simple PHP. The same goes for JavaScript and CSS. Don't write JavaScript code or CSS directly in tags. CSS should be kept to external files. JS libraries should be referenced in the <head> while custom JS code for a particular page written in a <script> tag at the bottom of the page. I write mine after </body> but before </html>. By keeping code separate, you do the following: Make it easier to write. Make it easier to edit without running the risk of screwing something else up. Make it easy to swap out entire parts, if necessary. Make it easy to debug as your code won't be nested in code of other languages. Make it easy to zone in on the problem area, and send that relevant block of code to others (read: us) for help. --- Okay, now on to your problem, try something like: <?php $query = "SELECT * FROM movie_info ORDER BY title ASC"; $movies = mysql_query($query); ?> <!-- HTML code up to your form --> <form action="" method="post"> <select> <?php while($row = mysql_fetch_assoc($movies)) { echo "<option value='{$row['id']}'>{$row['title']}</option>"; } ?> </select> </form>