Jump to content
xisto Community

pyost

Members
  • Content Count

    1,210
  • Joined

  • Last visited

Everything posted by pyost

  1. I don't think looking at other apps' source code is useful when starting with a new language. Sure, there might be some good examples, but the queries in such scripts tend to be rather complicated, therefore making it hard to understand. Only when you acquire an average level of SQL knowledge should you look at various pieces of code.
  2. For some simple/average web sites, the SQL syntax isn't complicated at all. Its advantage is that you can really understand what a query does just by reading it out loud. For example, SELECT * FROM `something` WHERE `i` = 1 would mean "Select everything (all fields) from the table `something` if that field's value for `i` is one." Anyway, the resource I have used the most is http://www.tizag.com/. They have absolutely great starting tutorials for several languages, so you couldn't make the the number resource for many other things, too.
  3. You can see the on the forum home page, just below the shoutbox. You have applied for the Web Hosting Package #1. If you want to upgrade your account (for more space and bandwidth), you will need 30 credits. When you acquire that amount and decide to upgrade your account, create a topic in the Upgrade Request forum. You will have to use the Upgrade Request Form. Only the first and the last link aren't valid (this will be fixed eventually). That's because the certificate is by the Xisto Corporation (https://xisto.com/), which is not the URL of your web site. Nothing to worry about. If it all works fine, then there is no problem. Start using Firefox, and you won't have this message No, images do not increase your credit count. The same goes for text inside the QUOTE, CODE, HTML and other similar tags. Any moderator or administrator. This is probably a consequence of numerous forum upgrades. The directory isn't functional, so there is no need to visit it. Resetting the cPanel password costs 10 credits - if you lose it, you will have to pay in order to get a new one. You can, however, change the password manually in cPanel itself.
  4. This is the second part of my Pascal tutorial for beginners. Here is what the complete tutorial contains, and it might get expanded (some parts are not written yet): Part One Introduction What do you need to start? The program layout (organisation) and syntax Variables And what if there is an error? "Hello World" Input & Output Examples Swapping numbers Reading and writing multiple variables Part Two Conditions The IF condition The CASE condition Loops The FOR loop The WHILE loop The REPEAT loop Examples Checking whether a number is positive or negative Writing the first positive N numbers Calculating the sum of positive numbers Conditions Conditions, as the name itself says, are parts of the code that take some condition into consideration. The easiest answer to the question "why?" would be "to make the program non-linear". Obviously, if you are creating a program, it has to do something useful, which usually means it would have to do various things. But how can you achieve that if you write line after line of code which always gets executed in the same why? That's where conditions come in handy - you can execute different parts of code depending on various things. The IF condition The IF condition is a piece of code that is highly likely to be used in every single application. It can also be displayed as IF - THEN - ELSE, because that is exactly how it works. The program gets a variable/condition, which can be either true or false. If it is TRUE, the program moves to "then". Otherwise, it moves to "else". The code is pretty much the same. if (condition) then doSomething else doSomethingElse; As already mentioned, condition can be both variable and condition. It might be a bit confusing because of the names, but the explanation will help a lot. If we want to use a variable, it must be of boolean type. This type can have only two values - true and false. Using it would look like this: var cond: boolean;begin cond := true; if (cond) then writeln('True') // This one get's executed else writeln('False'); cond := false; if (cond) then writeln('True') else writeln('False'); // This one get's executedend. Simple as that. As for conditions, they also return true and false, but have a different form - two variables being compared. So, we could have:a < b a <= b a > b a >= b a = b In Pascal, the equal sign (=) isn't used for assigning values, but for comparing them. (Remember, := is for assigning) var a, b: integer;begin a := 15; b := 22; if (a < b) then writeln('a < b') // This one get's executed else writeln('a >= b');end. One thing to be careful are the commands after THEN and ELSE. You will notice that we don't have a semi-colon after the THEN line, but we do after the ELSE line. This is because semi-colon ends the whole IF condition, and not just a part of it. If you, however, didn't want the ELSE part, you could omit it and enter the semi-colon after THEN commands. This is a completely valid option. Furthermore, THEN and ELSE don't have to contain only one command - it can also be a block of commands, by using begin..end. Again, if you have both THEN and ELSE, there mustn't be a semi-colon after then begin..end You can always combine several boolean variables and/or conditions in order to achieve a more complex level of the IF statement. However, we will deal with this in one of the following parts. This time I just wanted to explain how the system works. The CASE condition It might be a bit wrong to call CASE a condition, but it can be put in the same group as IF, since it allows the use of different command blocks for different values. Unlike IF, where we have either TRUE or FALSE, in CASE we choose a variable and then set commands for the values we choose. Alternatively, it could be replaced with a number of IF commands, where every one would be IF (variable == something) then ...;. Of course, instead of doing so, we can use case. To start with, here are a few rules. Since each case must be limited, there has to be semi-colon at the end. A consequence of this is that we can't use a semi-colon the end the CASE condition, but have to use end;. Furthermore, besides the wanted number of cases, we can also have (but it is not obligatory) and ELSE case, which matches all the values we haven't mentioned. The following is the CASE syntax incorporate into an example var number: integer;begin number := 3 case number of // number is a variable, case..of is the syntax 1: writeln('Number one'); 2: writeln('Number two'); 3: writeln('Number three'); // this one gets executed else writeln('Not one nor two nor three'); number := 21 case number of // number is a variable, case..of is the syntax 1: writeln('Number one'); 2: writeln('Number two'); 3: writeln('Number three'); else writeln('Not one nor two nor three'); // this one gets executedend. The variable doesn't have to be a number - it can be a string, a character, and even a boolean (though it doesn't make any sense to use CASE). And once again, you can use begin..end for groups of commands. Loops If you wanted to do the same thing several times in a row, copying it over and over again wouldn't be a good thing. What's more, what if you don't really know how many times that code should be run (if this number is entered by the user)? That's why you need Loops, another type of statements that is used "on a daily basis". Loops are statements that enclose a command or a block of commands and repeat them certain number of times. This number can either be defined in the code itself, or a variable can be used. The FOR loop I consider the FOR loop to be the simplest of those that will be explained in the part of the tutorial. It is because it can be replaced by both WHILE and REPEAT, which give more control. However, it is good to start with this one in order to understand how loops work. The important thing about FOR is that it works with integer numbers. You have to have a variable which will serve as a counter, since the FOR loop takes a certain interval into consideration. A good "translation" of the loop would be "For each number in the interval [number_one, number_two] do a command/block of commands." Number_one must ALWAYS be assigned to a variable, because it will change after each "round". Number_two can either be a number or a variable containing a number. Number_one will change until it reaches number_two, when the loop will end. If number_one is smaller than number_two (so you want it to increment), you will use TO in the loop. Otherwise, you will use DOWNTO. Here is an example the writes out all the number from 5 to 10, and then from 10 to 5. program forExample;var counter: integer;begin for counter := 5 to 10 do writeln(counter); for counter := 10 downto 5 do writeln(counter); readln;end. As you can see, first we assign the starting number to a variable, which can then be used throughout the loop. The second number is followed by the reserved word DO, after which we enter the command(s) we want to be executed. If there are more commands, they must be enclosed in begin..end. Using a non-integer number in the FOR loop will produce an error, and telling the program to go from 5 up to 3, or 3 down to 5, will cause the loop not to execute at all, because there are no numbers in the interval. (this might come in handy sooner or later). The WHILE loop The WHILE loop is somewhat connected to the IF condition. It runs a command/block of commands IF and AS LONG a certain condition is true. The syntax is WHILE condition DO. One important thing about the while loop is that you MUST, at some point, alter the variables so the condition becomes false. Otherwise, you would get an infite loop and would have to press CTRL+BREAK to stop the execution of the program. Here's an example with a FOR and a WHILE loop, both doing the same thing. program whileExample;var counter: integer;begin for counter := 5 to 10 do writeln(counter); counter := 5 while (counter <= 10) do begin writeln(counter); counter := counter + 1; end; readln;end. Before the WHILE loop, we had to assing a value to the counter variable in order to write the proper value on the first "round". Also, notice how we increment the counter every time. If we didn't do so, the condition would always be true. The REPEAT loop REPEAT is pretty much the same as WHILE, except it checks the condition at the end of the loop, and runs the loop as long as the condition returns FALSE. The syntax is REPEAT commands UNTIL condition. This "until" tells you that the loop will and as soon as condition becomes true. Furthermore, because of a starting and an ending word in its syntax (REPEAT/UNTIL), this loop doesn't need begin..end for multiple commands. Unlike the WHILE loop, which might not get executed at all (if the condition is false at the beginning), the REPEAT loop will always run at least once. This is useful if you want to use the thing you read inside the loop in the condition. With WHILE, you wouldn't have a value on the first, because it would be read inside the loop. Because of this, we might not always be able to convert a FOR loop into a REPEAT one - when the interval in FOR is non-existent, and it doesn't run at all. And be careful not to create an infinite loop Examples Checking whether a number is positive or negative The user enters a number (doesn't have to be an integer), and the program must check whether the number is positive or negative. If it is zero, a special message should be written. program posNum;var number: real;begin readln(number); if (number = 0) then writeln('The number is zero') else if (number > 0) then writeln('The number is positive') else writeln('The number is negative'); readln;end. After reading the number, we first check whether it is zero. If it is, we write the appropriate message. If it is not, we start the other IF condition, which is inside the ELSE part. It just check if the number is positive or negative. You might wonder why there isn't a begin..end around the second IF condition. That's because IF is one command, and THEN and ELSE are just a part of it. The last readln is there to stop the window from closing immediately after writing the message. Writing the first positive N numbers The user enters a positive integer number N (N>0). Our task is to print out all the numbers from one to N. program writeNums;var counter: integer; number: integer;begin readln(number); for counter := 1 to number do writeln(counter); readln;end. So, the user wants us to write all the numbers up to number? No problem, we will just write one by one for all number from 1 to number The code says it all. Calculating the sum of positive numbers The user starts entering positive (real) numbers, hitting enter after each one, and the program adds all those numbers to a sum. It should do so until the user enters a zero, and write the sum after that. program sum;var number: real; sum: real;begin sum := 0; repeat readln(number); sum:=sum+number; until (number = 0); writeln(sum); readln;end. As already mentioned, it is always good to assign a start value to the variable, because we don't know what it contains in the beginning. After that, the program REPEATs reading numbers and adding them to the sum UNTIL it read a number which is zero. Even though we do add the zero to the sum after we read it, it doesn't bothers us much, does it? We could have used a WHILE loop, but that wouldn't suit us, because we wouldn't have had a number to check. Loops and conditions are probably the two most important branches of programming, and it doesn't matter which language we are talking about. Without understanding these two and mastering them to a sufficiently high level, you cannot expect to make serious applications.
  5. I believe it is a matter of your location. I can easily access your web site through both URIs. I don't think this is something to be worried about, since at least 90% of people can (probably) access your web site with no problems whatsoever.And please, do try to make your topic titles more descriptive.
  6. And that's where you've made your first mistake, if you ask me. It's well-known that phpBB is highly unreliable and utterly easy to hack. If you don't want the same thing to happen again, I advise you to switch to SMF or some other free forum software.
  7. The easiest way to resolve this problem is by visiting the Forgot Password link. If you, for some reason, don't have access to the mail you used when registering, no one can help you. And be careful when creating web sites, you must keep an eye on security
  8. For the DIV you want to be hidden completely right away, use display: none in your CSS file. As for the expand/collapse like, I guess you could use something like this: <a href=..... id=operation>Collapse</a>Then, in the code that expands and collapses the DIV you should add: document.getElementById("operation").innerHTML = "Expand";This way you will change the text to "Expand" after collapsing the DIV, and the opposite when expanding it
  9. Try adding single quotes around $username, because it is a string:$query = "SELECT `zbits` FROM `players` WHERE `username`='$username'";I am not sure if this is necessary, but as far as I can see, that is the only thing I would do in a different way.
  10. Sorry, but I can't help you with that I am no SQL expert, since I've been using it only on smaller web sites that don't need fast queries. It can be done, that's sure - but I can't do it
  11. Of course they have, it's Google. Not to mention that this topic is rather old
  12. Some time ago I decided to convert my current web site (done in Joomla! CMS) to WordPress. Mostly because it is less bulky when compared to Joomla! CMS and has exactly the functions I need, unlike Joomla, where I found numerous options which I didn't need. Of course, as every professional web master (yes, I like to see myself as pro ), I wasn't completely satisfied with the way WordPress delivers content, and so I decided to modify its code in order to make it perfect. Unfortunately, as it always is, I encountered many problems, and spent even more hours trying to find a solution. That's why I decided to compile this list of useful modifications - or at least I found them useful. Before I deliver the list, here are some warning/information notes: All these modifications have been tried out on WordPress 2.1.3 The blog I am working on uses SEF URIs, so some modifications may be of no use to people not using custom permalinks. I expect you know at least something about WordPress, since I will be using WP-specific terms without explaining them. Always make a backup of the files you are editing If something doesn't work, or messes up your blog, I am not to blame What you see at the moment isn't the final list. I will be adding things every time I figure out something new. Removing the annoying category base ("category/") Be careful when using this modification, as it will break your post pages (links), and it isn't so easy to fix. Check the part starting with a row of dashes for an explanation. As we all know, by default, WordPress uses "ugly" URIs, with a lot of question marks and ampersands (&). That's why people usually decide to use search engine friendly URIs by changing the permalink structure. However, there is one thing that can't be removed, and that is the category base. Of course, there is a simple explanation for this - if you give WordPress /news/, how can it know whether this is a page or a category? That's why it uses /category_base/news/ for categories, and just /news/ for pages. This category base can be anything you like, but it can't be empty, as this will result in using the default, /category/. However, someone (like me) might run a blog that has no pages named the same way as categories. So why would he/she have to deal with the same problem? On the Internet there are several solutions to this problem, and some suggest entering just /. in to the "category base" box. From my experience, this does not work. But there is a solution that works, and it requires some file editing The only file you will have to edit is /wp-includes/rewrite.php, since it deals with all the rewrite rules. So, open the file and find the line saying $this->category_structure = $this->front . 'category/';Replace it with $this->category_structure = $this->front . '/';Now all you have to do is go to the administration panel and update the permalink structure in order for the changes to take effect - the rewrite.php is used only when you update the structure, because the result ends up being saved in the database. Also, be sure that the category base field on the permalink page is empty. You might wonder why we have done this, when WordPress recognizes a category even without the prefix (when it's not modified). That's true, you can use /news/ to display a category (if there isn't a page called the same), but what happens when you want to go to the next page? /news/page/2/ won't work! By modifying the rewrite file, we have overcome this problem. ------------ Now that we have removed the category base, practicaly anything is a category link. So, if your structure is /%category%/%post_id%/, /news/13/ won't be a post, but a category page for 13. which is a subcategory for news! Our only option is to change the way rewritten URIs are being parsed, and for that we will need to alter /wp-includes/classes.php. We will be editing the WP class which contains an array called query_vars. It has many keys, but you will need to alter only several, depending on your permalink structure. I will show you how I solved the problem with my structure, and you can figure out approximately what I've done. First of all, we will need to find this part if ( isset($error) ) $this->query_vars['error'] = $error;After it we should insert the code for altering the query. In my case, /news/13/ is treated as a category path consisting of category names, but it's actually a post number. That's why I will be messing with query_vars['category_name'] and query_vars['p']. At the moment, ['category_name'] contains "news/13" (notice how there are no slashes at the beginning/end) and ['p'] is empty (this should be an integer). Now we will do some simple string operations in order to extract the post ID from category_name. As I already said, I can do so because I know the permalink structure, and that's why this solution won't work for others. Anyway, this is the code I needed: $length = strlen($this->query_vars['category_name']); // we need the length for the counter$category = $this->query_vars['category_name']; // we don't want to destroy the original, in case it is not a post$ending = ''; // this will be the ID, and now it's empty$length--;$ch = $category{$length}; // reading the last character of category_namewhile ( is_numeric($ch) ) // while this character is a digit, we add it to the ID ($ending) and read the next character $ending = $ch . $ending; $length--; $ch = $category{$length};}if ( ($ending != '') && (is_numeric($ending)) && ($ch == '/') ) { // if this really is a post $ending won't be empty, it will be a number, and the next character will be a slash $this->query_vars['category_name'] = ''; // we aren't looking at a category, right? $this->query_vars['p'] = (int) $ending; // the post ID needs to be an integer!}I haven't checked if this messes up subcategories, but I'm sure it does if the subcategory's name is a number Oh, and if you don't know which keys does this array have, and therefore don't know what to change for your permalink structure, insert the following code anywhere in your template and it will display all the keys with their current values. $test = $wp_query->query_vars;foreach ($test as $key => $value) echo $key.' -> '.$value.'<br />'; Changing the pagination style to suit your language As I mentioned in the previous paragraph, WordPress uses /page/x/ for paginated results, when x is some number. I didn't find this solution suitable, as I wanted my blog to be completely in my language. I somehow needed to change the /page/ part to something else, but how? You might have guessed - we need to edit the /wp-includes/rewrite.php file again, but /wp-includes/link-tempate.php, too. Let's deal with the rewrite file first. Find the following line $pageregex = 'page/?([0-9]{1,})/?;And replace it with $pageregex = 'something/?([0-9]{1,})/?; This "something" can be anything you like. Just like in the previous modification, you will have to update the permalink structure in order for the changes to take effect. The pagination is now working perfectly, but if you are using Wordpress template tags for display the next/previous page link, they will be delivering the old structure, because these functions don't care what the rewrite rules say. So on to editing the /wp-includes/link-tempate.php file. Find the following lines $page_modstring = "page/"; $page_modregex = "page/?";Obviously, you need to do this $page_modstring = "something/"; $page_modregex = "something/?"; Also you need to replace this $qstr = str_replace('page/1/', '', $qstr); // for mod_rewrite styleWith this $qstr = str_replace('something/1/', '', $qstr); // for mod_rewrite style And now you have a WordPress blog with link in you own language
  13. Just one friendly advice. If you really want to do some hard-core customizing, don't. Even though WordPress has a rather simple syntax, there will always be something to mess with your idea. Something so small, yet so annoying, just because you can't find a way to fix it. It might even be easire to create your own Content Management System or WebLog (a.k.a. Blog). I am saying this from personl experience, since I'm dealing with such problems right now
  14. Beautiful. Just beautiful. I like the way you handled this task, even though it seems almost impossible, or at least very hard. If Xisto had a reputation system, yours would hit the ceiling just about now Why not take the directory one step further, and check the member group along with the hosting request? It might, however, cause problems when you encounter a moderator/administrators, since it wouldn't state Group: [Hosted], but Group: [Moderator] or Group: [Administrator]. Think about it a bit Also, my site appeared twice. Why? Because there were two application I know this is hard to avoid without losing the dynamic site of the directory, but displaying one site per user name is obviously a better way.
  15. Just what unimatrix said. I've used PC tablets several times, but never owned one. However, everyone is always fascinated with Wacom tables, so they can't be bad. Unfortunately, they are a bit (too) expensive, but a tablet is not a thing you should save on. It has to be precise and easily used, otherwise there is no point in owning one, is there?
  16. I have a feeling that this can be done with one long query, but I prefer splitting everything into smaller chunks Assuming that you are already connected to the database, and you want to display all the sales, I will from an two-dimension array like this: $sales[id][column] id is just a counter, so we can display all the data, and column can be sales_id, product_id, fromuser or touser. Keep in mind the I will make everything lowercase, so you might have to customize the script in case it is case-sensitive (obviously, I don't know whether that can happen). So here we go. $sales = array(); // creating a blank array$query = "SELECT * FROM `sales_details` ORDER BY `sales_id` ASC"; // setting up a query to get all the sales$result = mysql_query($query); // running the query$i = 0; // we will be needing a counter;while ( $row = mysql_fetch_array($result) ) { // we process the sales one by one$sales[i] = array();$sales[i]['sales_id'] = $row['sales_id'];$product = $row['product_id'];$query = "SELECT `productname` FROM `sales_products` WHERE `product_id` = $product"; // let's get the product$product_result = mysql_query($query);$sales[i]['product_id'] = mysql_result($product_result,0,'productname');$user = $row['fromuser'];$query = "SELECT `name` FROM `sales_users` WHERE `user_id` = $user"; // let's get one user$user_result = mysql_query($query);$sales[i]['fromuser'] = mysql_result($user_result,0,'user_id');$user = $row['touser'];$query = "SELECT `name` FROM `sales_users` WHERE `user_id` = $user"; // let's get the other user$user_result = mysql_query($query);$sales[i]['touser'] = mysql_result($user_result,0,'user_id');$i++}foreach ($sales as $one_item) {// here you can print out everything you need, since it's all stored in $one_item[]} Now, I am not particularly good with arrays, so a part of this code might be completely invalid, but it's up to you to try it out. I hope it works
  17. As far as I can see from your source code, inside the <body> tag you have one DIV, and then one TABLE. The simplest solution would be to remove the DIV container (as it is not necessary this way), and add align="center" to the TABLE tag. This will center the main table in all browsers. However, web developers/designers usually don't like this solution as it is, how I like to call it, "outdated". You can do exactly the same thing with the DIV container, and it's quite simple - you probably just didn't try this combination. The only thing you need to change is the CSS. In the body properties, include text-align: center (aligns the whole page in Internet Explorer), and in the #outer properties use margin: 0 auto 0 auto and text-align: left. The first one centers the DIV, and the second one is used to nullify the effect text-align: center (from the BODY) would have on the text inside the DIV. @faulty.lee I don't think "center" is a valid XHTML tag It's even more "outdated" than the align="center" solution I mentioned
  18. But that's the main advantage of CSS! There are numerous things that can't be done with the use of pure HTML which the "complicated" symbioses of XHTML and CSS can Unfortunately, there are a few things that aren't easy to accomplish with CSS, whereas unpopular HTML tags do it easily. Just yesterday I was trying to add several lines of text next to an image, but aligned with it's bottom. Using align="bottom" with the image would do just fine if it were only one line of text. As I could put CSS vertical-align to use (at least I didn't know how to), I had to think of another solution. Finally, I came up with two - one without CSS, and one with. The solution without CSS included a two-cell table, where one cell would have valign="bottom". I ended up with some bulky code, but it worked in all browser. However, since my client insisted on a tableless design, I had to go with the other solution, which require a considerable amount of tweaking. I put the image (with fixed height) in a DIV container which was assigned a height in pixels (the container, not the image). I also gave the container position: relative, so I could use absolute positioning in it. After doing so, I placed another DIV inside the container, and assigned it a width, position: absolute, bottom: 0px and left: 133px. And there you are: a DIV that contains text always aligned to the bottom of the image As you can see (almost) everything can be done with CSS, though not always in a nice-looking way - but it sure does altering a site's design easier
  19. I am not so far away either :)OK, I am Congratulations on your promotion, xbox
  20. Wait right there. Just because the new site design is so good doesn't mean you should start using phpBB right away. It is best to wait until phpBB 3 is out, as it is supposed to be much more secure and versatile than the previous versions.
  21. As for the PHP part of the code, you need to retrieve the data from the database. Here's how it would roughly look: $user = $_GET['user'];$query = "SELECT * FROM `table` WHERE `user` = '$user'";$result = mysql_query($query);$row = mysql_fetch_array($result); Of course, there would have to be some validation because of security, but it would end up looking like this. First we get the username, set up the query, and then run it. Then, we move all the data to an array ($row). In order to use it, you will ned $row['column'], where column is the column name in the database.
  22. The same thing happened to me when I tried to sign in using Internet Explorer (don't ask why, spur of the moment) - just an infinite loading loop. When I tried the same thing with Firefox, it worked. So I guess you could try Opera as the last option
  23. I didn't try this program myself, but I'm not sure how usable it is. Text to speech is one thing, but speech to text is a completely different one. Don't we all remember (I hope we do) what happened to Vista Speech Recognition System? If not, take a look at this video. It will show you perfectly well how even a giant like Microsoft can't deal with it properly Yet again, I might be wrong, and this program might be a future must-have.
  24. Noooo, definitely avoid Hotmail! It's spam filter is awful, every page takes ages to load (even if you have a faster connection), little AJAX implementation (or none, I can't seem to recall seeing it being used anywhere) - the service isn't professional enough when compared to its owner. It might have a lot of storage space, but currently (in my opinion) there is no mail service that can be as good as GMail.
  25. Very neat blending, and the colours are pretty OK for a web site However, you definitely won't be able to use the image in this form - its size is over 200kB! You will either have to reduce it's size (which is not a practical solution), or save it as a JPG file. You will lose some quality, but also reduce the loading time of your web page, which is a really really important factor when trying to attract visitors
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.