Thanks for the reply, xrj. I should have been more clear though -- my real problem here is the /products/ part. The "col1" part is just for placeholders. Really the URL looks like, say,


So if I want to exclude anything under the "shirts" or "tea" collections, I can do


Now the coffee collection is fine, but it's not OK if the URL has "/products/" in it. But I'm finding that...


...doesn't work. I believe this has to do with that lookaheads don't move along the string, I'm just not sure where to go from there.

  1. As far as I recall, IF statements don't have their own scope in PHP. What is the URL you are visiting? If you are getting this error, chances are $_GET["img_id"]) isn't set.
  2. You're referencing $img_id on line 18, but you never initialized this variable
  3. You're including the text $img_id in your string, instead of the value stored by the $img_id variable
  4. It also doesn't really make sense to set $sql on line 18 if $_POST['submit'] wasn't set, as you won't need the SQL statement if you're not connecting to the DB through the IF statement on 20. So combine the conditions into one as follows.


if(isset($_POST['submit'] && isset($_GET['img_id']))
    $img_id = $_GET['img_id'] // you probably want to sanitize this too
    $sql="SELECT * FROM tbl_images WHERE img_id={$img_id}"; // note -- must use double quotes here to print var value
    $result=mysqli_query($con,$sql) or die("Error:" .mysqli_error($con));
EvolutionFallen 107 Junior Poster

I'm hoping for some help with a regex that has me stumped. My skill with regex is rather rudimentary.
To start, here are a couple of example URLs, and whether I want to match them or not:

collection/col1 // MATCH
collection/col2 // FAIL
collection/col1/products/pro1 // FAIL

My criteria:

  • One single regex (cannot be multiple expressions)
  • I have a list of "col"s to fail on. For example, I do not want to match if specifically "col2" or "col3" are in the URL
  • Aside from col2 or col3, i can have any col[#] in the URL
  • Even if a valid col# is in the URL, the expression MUST fail if /products/ appears anywhere. The URL structure is such that if /products/ appears anywhere, it will always be after /collections/col#

Here are expressions I've come up with, but I'm missing how to make the expression definitely fail if /products/ is anywhere in it. Is this possible?


// And like 200 other things I tried that I didn't record

Thank you for any assistance.

Like my post perhaps?

I did! Thumbs up on all your 2 replies and on John_191's, either before I replied or right after, don't remember.

Thank you for the replies! Intersection definitely did the trick. Ended up going with

if not (product.color & TARGET_COLOR).empty?

What about if I just needed it to lazy match? Would any? be better? What would that look like?

EvolutionFallen 107 Junior Poster

I'm just starting off with Ruby, but I have a task that landed on my desk that I need a quick answer for, and haven't been able to find a solution online. I appreciate any help I can get.

I need to know if a value in one array appears in another. This should be easy enough with a loop but I'm looking to do it the "Ruby way", if there's such a thing. Here's my current code:

# product.color contains "orange, yellow, red", for example
if product.color.any? { |string| string.include?(TARGET_COLOR) }
    #do stuff

Now if I change the first line to TARGET_COLOR = ["red", "green"], I get an error -- I'm guessing the .include? accepts only strings.
What would be the correct syntax/method to search TARGET_COLOR?

Where's your form code?
PS - you should probably be using mysqli:

Are you sure you mean Photoshop and not Dreamweaver? You can't edit a website in Photoshop, it's an image editor. Dreamweaver is a web development editor: you can open your site resources in it, view them in design view if desired, and edit them there. Though honestly, I find it less professional to use DW.

Photoshop should be used for designing your site, such as layout and graphics. But it's not a replacement for HTML & CSS. It's a way to visualize what you're going to code in HTML & CSS, and extract the graphics you're going to use.

What's the data type for your student_code field?

Are you sending caching headers? You can check in the Net/Network panel of your browser dev tools when you view the site...

Thanks again mattster. I have a couple questions though. I'm using to test the URLs.

  1. If I run this URL:
    I get this:
    As you can see the 944 from the id is repeating twice. I tried %3 instead of %2, that gave me category=category=119&. It looks like %4 gets it right, but I'm not sure how that works.

  2. Will the order of the parameters for this matter? What if id or category are not the first parameters? What if id or category are missing, with only one of them showing?

Thanks mattster! This looks like it might work. I won't be able to implement until Monday, but if I get it working then I will mark this as solved. Also going to try to figure out how it works -- not a regex pro by any stretch of the imagination ^.^;

EvolutionFallen 107 Junior Poster

Hi folks,
I have a situation that's most easily explained via example, I think. So here goes. Let's say I have the following URLs:

  1. /page.asp?id=123
  2. /page.asp?id=123&category=ABC
  3. /page.asp?id=123&category=ABC&var3=X&var4=Y

I need these pages redirected. Currently links 1, and 2 redirect correctly. Option 3 though can have an arbitrary number of other parameters with arbitrary values. What I need to do is, for page.asp, ignore all parameters aside from id and category. Is there a way to do this with rewrite rules? If not, would it be possible to do if I did have the names of the other parameters?

Not sure it helps, but here is what I have so far. unwanted_var_name and value are replacing specific param and value that we're presently using to bulk redirect anything with that parameter... however this isn't ideal:

RewriteCond %{QUERY_STRING} unwanted_var_name=value
RewriteRule .*$ [R,L]


Why not use page=0, page=1, etc. instead of start=8, start=16, etc.?
This way the number of items you show per page can change, which is better user experience if your users want to load more items on a page.

$items_per_page = (!empty($_GET['show'])) ? $_GET['show'] : 8; // user selection or default to 8
$start_at = $_GET['page'] * $items_per_page;
$end_at = $start_at + $items_per_page - 1;

// Then your queries could be
$sql1 = "SELECT field, names FROM your_table WHERE condition LIMIT $start_at, $items_per_page"; // get your data
$sql2 = "SELECT count(*) AS num_results FROM your_table WHERE condition"; // count how many total results are in the table

// Process your queries

// Finally, print your links
if($start_at > 0) echo "PREVIOUS LINK HTML";
echo "You are on page ".$page+1;
if($end_at < $result_of_sql2) echo "NEXT LINK HTML"; // if your last item

This code is to lay out the theory, I haven't tested it.

You can use the onclick attribute as pritaeas suggested, together with the JavaScript confirm() function to give a popup with Yes or No options:

echo "<td><a href=\"delete_members.php?id=".$row['id']."\" onclick="return confirm('Are you sure you wish to delete this item?');">Delete</a></td>";

If the user clicks Yes, the function returns true, and the link is followed. If the user clicks No, the function returns false, and nothing happens.

Thanks! I've actually got this one presently, so I see what you're talking about with the max res. Thanks for the heads-up!

EvolutionFallen 107 Junior Poster


I have a Macbook Pro w/ Retina display (A1502), running Win 7 on bootcamp.
I also have 2 LG 25UM64 monitors. The optimal resolution for these monitors is 2560x1080. However, so far as I can tell I can only hit this resolution if I'm connected through HDMI, for which the MBPro only has one port. The thunderbolt ports won't go past 1920x1080, and I tried an HDMI to USB adapter without any luck.

I'm wondering if there's a way to get this second monitor to go to full resolution. Hoping someone knows how. Thanks!


Thanks bro, I took a class in the basics of html over the summer but before that I had no experience in programming whatsoever. So no I know its not the best, Im learning on the go. But main nav for the menu, got it. Thanks. Hey, what do you mean by self-terminationg DIVs?

For the menu, yes, use links (<a href> elements). Often these are nested inside of unordered lists:

<ul id="nav">
    <li><a href="/a-link.html">Home</a></li>
    <li><a href="/another-link.html">About</a></li>

As for self-closing divs, I was referring to:

<div id="text-align" style="text-align:center;"/>

This really depends on what your DOCTYPE is. In XHTML if you put a /> at the end of a tag it is essentially the same as doing <tag></tag>. This makes little sense for DIVs because they're usually used to contain other elements. In this case the code essentially creates a DIV called text-align which provides center alignment for text, but then immediately closes itself, which accomplishes nothing.

Please don't take this the wrong way, but where are you getting this code from? This code needs some serious help. Opening tags that aren't closed, self-terminating DIVs that serve no purpose, using input buttons for main nav? I've been writing HTML for a while now and I've never seen a <CR> tag. There's so much wrong here, you should really learn HTML before you move on to "cool things".

This would be really hard to do without knowing your platform, database schema, or any of your code.

You may want to store a delimiting character between each set of numbers. This way you can use the explode() function so you don't have to know exactly where one substring ends and another begins. For example, let's say you choose a comma , as your delimiter, your code is:

$output='01/07/2015,21/08/2016,91754.0'; // note the addded commas
$stringParts = array();
$stringParts = explode(',' $output);
// You can now access the parts at $stringParts[0], $stringParts[1], and $stringParts[2].

Awesome, thanks. That's probably what we'll end up doing. The site's on Magento though and there are some other inherent problems in moving that to all HTTPS, so we'll see what happens.

Sorry Dani, I didn't mean to imply you weren't doing so. I was speaking in a general sense, meaning it goes for anyone that isn't doing it.
So how are you doing it? Is it all mod_rewrite and/or 301 redirects?

Good topic. I haven't worked on too many big "from scratch" projects so I'm looking forward to some interesting responses here.
For me, the first item is figuring out what the project is about, and if there's a cost-effective platform out there that I can use as a framework. This way I don't have to reinvent the wheel; oftentimes it's easy for the client to learn to use, and they're happy 'cause they don't have to pay me for a custom CMS. WordPress has often been my weapon of choice. I'm also trying to learn CakePHP.
If the project DOES have to be from scratch, I'd actually say that the database is one of the first things I'll work on. You need to know what kind of information you want to store and relay before you can decide how you want to present it. Plus I think this helps because while you're already building the DB you can insert dummy content for testing later on. If the client already has the schema figured out and has provided you with a site design based on it, awesome.

Once I have the design I prefer to break it down into its HTML structure. I usually do this by hand-coding. This way I'm very familiar with the elements I may need to reference in CSS and JS. Then yes, slice and dice in PS and start figuring out your CSS. Again, I prefer hand-coding.

For the rest I'd say you're pretty spot on ...

I think any site that collects login information should be using SSL. Most people will repeat the same login information (username/email, password, and that specific pairing), between multiple sites. If you request this information from a user, you should be protecting it.

That said, my company's considering to switch over to all SSL presently. I'm curious what methods people are using.

So long as you are providing an ID to your query, you will not retrieve more than one image, since only one image matches that ID. Why do you need the WHERE clause? Can't you just do SELECT * FROM gallery; to get all images, or for example SELECT * FROM gallery LIMIT 0,3; for the first three items?

Also, where is this ID even coming from? It's not in the function's argument list.

Try this for gallery_loader():

// Updated gallery_loader with ability to loop through multiple DB results.
public function gallery_loader()
    $sql="SELECT * FROM gallery WHERE id=1"; // IF YOU LEAVE id=1 you will only retrieve a single image. This code will still work, though.

    $i = 0;
    $slides = array();

        $slides[$i]['ImageSrc'] = "gallery/".$finder['Image_Name'].$finder['Extension'];
        $slides[$i]['Description'] = $finder["Category"];

    return $slides;

Then for imagesDataArray, assuming it is in a PHP file:

<?php $mySlides = gallery_loader(); ?>
var imagesDataArray = [
src: '<?php $mySlides[0]['ImageSrc']; ?>',
description: '<?php $mySlides[0]['Description']; ?>'

You can work looping into this as I did in the gallery_loader() function so you can supply multiple images and descriptions.

EvolutionFallen 107 Junior Poster

Hi all,
I'm wondering if anyone's had experience with the WordPress Importer tool. I'm having trouble importing my WXR file through the tool. It works well for the most part, but when I get to the author assignment section, there are some issues. Under Assign Authors I only see Import author: (), with nothing in the parentheses. Once I submit the page, the next page says

Failed to create new user for . Their posts will be attributed to the current user. Cannot create a user with an empty login name.

I don't know why there's a blank space after "for", and why it would say "empty login name." I checked the XML file and it appears to have the right fields populated. I'm hoping someone has experience with this and can offer some advice.

Use jquery's .css() to get the current value of a style property for an element. Similarly, adjusting a style with .css() will apply it to the element as an inline style.

silverdust commented: Great! Thanks Evolution! +0

@Ajay, the id of the <input> and the <a> being the same shouldn't be an issue. If I'm understanding OP correctly, the <a> is supposed to replace the <input>, so there will not be duplication.

@OP: The value attribute is not valid in an anchor tag, though I don't think that's your main issue here. If you could show more code from the form, that might help.