
scootstah
Staff Alumni-
Posts
3,858 -
Joined
-
Last visited
-
Days Won
29
Everything posted by scootstah
-
Yeah, that's what I figured. You're only looping over one result in the while loop each time, so there will only ever be one table row. In order for this to work you either need to move the logic to the for loop or change the queries so that you are getting all of the rows at once. Honestly, you need to go through that whole chunk of code and re-write it. You have a lot of queries inside loops inside loops inside loops.
-
Honestly, I still have no idea what you're trying to do. Try explaining your question better, and posting code that's actually relevant.
-
Yes, and run them through mysql_real_escape_string to prevent SQL injection.
-
This is one of those cases where using eval is entirely unacceptable. Don't do that.
-
Sure, but why would you want duplicate data?
-
What do you mean the form isn't "disappearing"?
-
That's not what I meant. Put this echo 'Rows returned: ' . mysql_num_rows($retd) . '<br />'; after this $SQL = " SELECT * FROM list "; $SQL = $SQL . " WHERE code = '$pieces[$i]' "; $retd = mysql_db_query($db, $SQL, $cid); And then post the output.
-
Not sure I agree here. If your application is OOP I think it's perfectly fine to have a few procedural functions. If you have more than a couple functions that all handle something specific (like a bunch of cookie functions) then I think maybe they'd have a better home in a class. But on the other hand if you have a handful of functions that have nothing to do with each other, I think that's okay. I think it's a far worse idea to create a class that has only one static method to avoid creating a procedural function. I always favor OOP but I still have a handful of functions that I don't feel have any place in classes... at least not by themselves. Also, this.
-
How many rows are returned with that query each time?
-
Eh, it's not uncommon for very basic, very generalized functionality to be implemented as static classes. It's not necessarily the right way to do things, but it's a popular way of doing things. So popular that C# has a built-in mechanism for it: That's not a very fair comparison though. Isn't C# like hardcore OOP? It's not as hardcore as, say, Ruby. All of what PHP has for OOP is applicable. Right, but my point was that everything is an object in C#. Correct me if I'm wrong but you can't have a procedural function in C# like you can in PHP. In PHP you can just create a regular ol' function outside of a class. Can you do that in C#? If not, then a class full of static methods makes sense because it's the only way to achieve such a thing.
-
I get 642484800. What do you get?
-
That code is a nightmare. I suspect your problem is here: $SQL = " SELECT * FROM list "; $SQL = $SQL . " WHERE code = '$pieces[$i]' "; $retd = mysql_db_query($db, $SQL, $cid); if (!$retd) { echo( mysql_error()); } else { // define the number of columns per row $cols = 5; // start the counter $counter = 0; while ($row = mysql_fetch_array($retd)) { $code = $row["code"]; $name = $row["name"]; /*if ($counter % $cols == 0) { if ($counter > 0) { echo '</tr>'; } echo '<tr>'; }*/ if ($counter % $cols == 0) { if ($counter > 0) { echo '</tr>'; } echo '<tr>'; } echo("<td width=150 align=center>"); echo ("<a href=../products/info.php?scode=$code><img src=pictures/$code.gif border=0 alt=Item $name</a>"); echo ("<br><a href=../products/info.php?scode=$code><span class=fs13>$name</span></a>"); echo("</td>"); //increment the counter $counter++; } } I didn't dig too deeply but I would venture a guess that you are only returning one row at a time. You need to clean up this code a lot. Running queries in nested loops like that is a bad, bad thing. You can most likely gather the same data in a single query.
-
With the link I provided, there is no "load of vhost writes". It is a wild card vhost. It rewrites the subdomain to a corresponding subdirectory. So if the URL was http://hackalive.example.com it would map traffic to /var/www/hackalive. Only one vhost need be configured for that to happen.
-
I find it hard to believe that that is the code on your link; because there's no error with that snippet. It should be creating a new row every 5th iteration but your live example creates one on every iteration, which is not possible given the above snippet. I've tested it again and it works without issue for me. You need to give us the exact code for the link you have provided.
-
Eh, it's not uncommon for very basic, very generalized functionality to be implemented as static classes. It's not necessarily the right way to do things, but it's a popular way of doing things. So popular that C# has a built-in mechanism for it: That's not a very fair comparison though. Isn't C# like hardcore OOP? Hmm, I think I remember reading an antipattern similar to this. Wherein multiple (unrelated) classes unnecessarily extend a base class. I may be wrong, though. I may also be misinterpreting your suggestion. Nonetheless, thank you for your contribution. It's all appreciated. It doesn't necessarily have to be extended, but it's a good way to go if you're using some sort of dependency injection. Hmm, but isn't dependency injection used for injecting objects, not functions, or an object who's sole purpose is to hold methods? Yes, but Andy-H's idea was that you make a "client" class for these functions and a bunch other, which you could inject with DI and it would be available to your other objects.
-
You can most definitely patent software. However, it isn't terribly common and at least in the US is a load of BS... but that's a different story. From what I understand of it (which isn't a whole lot) you can only patent the process or function of the software, but you can't actually patent the code it runs on.
-
Hmm, I think I remember reading an antipattern similar to this. Wherein multiple (unrelated) classes unnecessarily extend a base class. I may be wrong, though. I may also be misinterpreting your suggestion. Nonetheless, thank you for your contribution. It's all appreciated. It doesn't necessarily have to be extended, but it's a good way to go if you're using some sort of dependency injection.
-
Someone could easily remove any license/copyright and tweak the code. That doesn't make it any more legal to do so. If someone blatantly stole your code and you wanted to take action against them, usually all you have to do is prove that you in fact created the works. The problem is that someone can take your code, modify it a little and then legally call it their own, since it is different. Unfortunately you can't patent code. Like AyKay said it's tricky stuff... if you want concrete advice get in touch with a lawyer.
-
It doesn't change the existing URL's to new pretty URL's, it just points the pretty URL to the existing URL. As for the CSS, you'll need a flag that allows real files to be exempt from the re-write. I bet your CSS URL is being re-written to the pretty URL and thus it doesn't exist. Try this: Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index/([0-9]+)\.html$ index.php?page_id=$1 [L] This will exclude directories and files from being re-written.
-
It doesn't look like there is a problem. What do you mean it "does not rewrite the URL"? What happens when you go to index/1.html?
-
You shouldn't store all of that in a session. What you can do, though, is save the user's ID to a session. Then whenever you want to look up the user's information you can just fetch it from the database, since you know their ID.
-
It's one way at least.
-
So someone is typing out 120+ user's info and then inputting it? Are they importing it from a CSV or XML or something? What are you doing with it after they input it?