cmps 26 Light Poster

yup it works now ;) it was a plugin for ubuntu on firefox, and on windows I guess I have installed the AdBlock plugin, so I will disable it later :)
Thank you +1

cmps 26 Light Poster

Here's the crash while enjoying daniweb and studying Computer Organization :)) Screenshot_from_2013-01-12_18:46:15

cmps 26 Light Poster

Dear Daniweb, I am facing a problem with daniweb forum, it keeps crashing randomly (only when I am browsing the website, if I am not on the website tab or not moving the mouse, nothing happens).
I am using firefox mozilla
OS: UBUNTU and WIN7 (same computer partition: ubuntu 14 / windows7)
I don't know if this problem is common with other people but it started like 2 weeks ago. Is the problem with my laptop or the browser ?
Only the browser crashes on this website and the firefox asks me if I want to restore session or start new Session.

If this problem was fixed, sorry Google, but Daniweb will be my next browser homepage :))))
Thank you all ;)

cmps 26 Light Poster

Ancient Dragon is totally true, and parallel processing makes the throughput even faster (Computers with multiple processors). But everything depends on the OS and the program running (Programmers can distribut tasks of there programs on different processors to make execution faster). A single processor cannot execute multiple instructions in exactly the same time, but if you want to know more about how to benefit the maximum of a single processor check the Pipelining
Good Luck in your exam :)

cmps 26 Light Poster

Dear Wailintun, this is knonwn for the Slider or S3Slider, try to google them and you will easily find the free source code for it. It's not difficult, try to understand it before the copy paste ;)

cmps 26 Light Poster

Tell us more what you have tried or what you know about database, which one you are using?
But before to start doing everything directly on the computer, and since you are not very sure about the inforamtion you are going to insert in the DB, try to draw the tables and make the connections on a paper so you can easily create the tables in your DB

tux4life commented: Good suggestion :-) +13
cmps 26 Light Poster

Dear labibah, I will consider that you are not using "admin" as username, because this is in the first if which doesn't contain the echo for the menu.php link.

else {
      $db= connect_db();
      $sql= "SELECT id,judge_name,category_code,cellphone FROM judges WHERE email='$email'";

    //  $db= connect_db();
      $rs = mysql_query( $sql);

      /*TRY TO ECHO THE NUMBER OF ROWS FOUND, MAYBE THE LOGIN IS NOT SUCCESSFUL AS YOU ARE THINKING*/
      echo mysql_num_rows($rs);

      if (mysql_num_rows($rs) >0 ) {
        $arr= mysql_fetch_assoc($rs) ;



    // test the pin

    $pin = substr($arr['cellphone'],-4);

    /*ECHO THE PIN AND PSWD, MAYBE THERE IS AN UNEXPECTED LOGICAL ERROR*/
    echo "Are they equal: " . $pin . " == " . $pswd;

    if ($pin==$pswd) {

      $_SESSION['gVars']=$arr;
      $arr['status']="success";

    // check, if the scoreboard ready for this judge
      test_scoringboard($arr['category_code'], $arr['id']) ;
      echo "<a href='a/menu.php'></a>";
    }
    else {
      $arr['status']="error";    

    }
  }
  else {
    $arr['status']="error";   
  }
}

Please check my comments and the two echo debuggin that I've added in your code
Good Luck

cmps 26 Light Poster

Dear bassznapper, you can learn this kind of coding by reading the documentation in Smarty or any other php template sys. Personally I don't like this kind of (not real programming).
If you learn a php template system you will not be able to learn or understand any programming language.
To learn PHP, you can buy PHP for dummies or google some tutorials, and of course we will help you in every step by feeling free to ask questions here on the forum :))

Good Luck ...

cmps 26 Light Poster

Did you check if the description field in databse is set to Text and not varchar ?

cmps 26 Light Poster

Dear 'garyjohnson', I think you are talking about something like this:
The user enters:
hello this is
amir
bwb

When echoing this, it will be displayed on one line only:
hello this isamirbwb

to fix this, you should use the function nl2br();

echo nl2br($description);

Hope this respond to your question.
NB: Same thing if you want to retrieve this from the database, save as $description, but echo it using nl2br()

Good Luck :)

cmps 26 Light Poster

Dear Ilda, I don't really understand, you need help in what data can be added to the database or how to create a database from zero ?
Please be more specific, Thank you :)

NB: You have to put some self effort and of course we will help you :)
Good Luck

cmps 26 Light Poster

You are Welcome :)

cmps 26 Light Poster

Dear anandschiru, I googled it:
http://jsfiddle.net/cUUCW/

Modify it, but replacing the text which another radio form
Good Luck :)

cmps 26 Light Poster

Dear 'bradly', you forgot to float the div, this will work:

<div id="Mid_Content">
<div id="Left_Content" style="float:left;">
<h2>Best Rates </h2>
<p>
2012 has been a great year for cheap mortgage deals. The Bank of England rate is at an all time low and mortgage lenders having to compete for your business, mortgage rates have been consistently low. Approaching the right mortgage provider for your circumstances is essential to getting the best rate. </p><p>
</p><p>
At We-Remortgage our mortgage advisers are highly experienced professionals, they have the knowledge and expertise to help you choose the right deal with latest applicants receiving rates as low as 2.68%!
</p><p>
Complete our 30 second form and start saving!
</p><p>
</p></div>
<div id="Mid_point_Content" style="float:left; width:33%;">asdasd</div>
<div id="Right_Content" style="float:right; width:33%">Form</div>

</div>

Good Luck :)

cmps 26 Light Poster

After double checking, you have the div id="main" which is the left part to have a width of 550px;
So the table should be 550px unless you force it the be wider.
You are padding 22px (left+right) in each rectangle 'td', and you have 8 'td' per row 'tr'
so 8x22 = 176px on padding + 10px on margin-left for the div main, and for the first 2 rows, you used the <p> which has a 10px padding on each side so 20x8=160px
so in total you have 346px only on padding and margin.
I think it's a lot!!

So to solve this.
add this css at the end of of the style tag

#main table p {
    padding: 0;
}

and the problem is solved :)

cmps 26 Light Poster

Dear vizz, check this link for the full ways to convert integer to string in php
http://stackoverflow.com/questions/1035634/converting-an-integer-to-a-string-in-php

cmps 26 Light Poster

Dear SPeed, try to remove the padding-left: 11px; or padding-right: 11px; for the td this will fix the size.

cmps 26 Light Poster

Dear Ronald, this is my first year of computer science, in my own experience of 2 years as a PHP developer and 1 year of JAVA:
If you know how to use PHP as an OOP (Classes) this will skip a big part of learning JAVA.
However there are some differences in declaring variables and functions and some other declarations and getting and importing information ...
Since I have accomplished the first year in learning and practicing JAVA, I can tell you that JAVA is more detailed and direct (you have to specify each function and variable if it's an integer or string or etc...). But personally, I didn't find any difficulties in learning JAVA, since almost every chapter I was able to link it to a chapter in PHP. Only the way of writting differ.
Brief, I recommend you to start and within less than 3 years of practicing java (REAL PRACTICE AND DISCOVERING) you will be ready for any position.

Good Luck

cmps 26 Light Poster

Dear 'Fiorentino01^', there are 2 ways to do this:

  • Write the full path
    Ex: <a href="http://www.domain.com/web-site/2/home.html">go to Home</a> (This will be placed in the page index.html) and same thing with home.html

  • Write the path starting from the location of the file you are coding
    Ex: you are coding the page index.html, just write <a href="../2/home.html">go to Home</a>

../ is to go to the upper folder (Parent directory)

Here's a good tutorial for HTML paths
http://www.coffeecup.com/help/articles/absolute-vs-relative-pathslinks/

Good Luck

cmps 26 Light Poster

Dear Aniketayachit, I just googled your question, and here's what I found:
http://stackoverflow.com/questions/6524196/java-get-pixel-array-from-image

cmps 26 Light Poster

Dear "Chinmay",

"Don't delete or edit posts, articles because this will affect the original wordpress too since both are connected to the same database." NOW? WHAT SHOULD I DO SIR?

I actually mean that if you modify an article or delete from the Test wordpress blog (not the original one), this will be also applied on the original blog since the source of information/data is the same.

So the point is just to be aware not to publish a RANDOM ARTICLE for testing because it will appear on the original WP blog.

However, modifying, adding, deleting codes in the Test WP blog will not affect the original WP blog.

Hope I was clear :) for any other information please feel free to ask :)

cmps 26 Light Poster

Dear Chinmay, if you want to modify the code or test new codes on wordpress, you can copy the folder that contain all the wordpress files and paste it anywhere you want in public_html folder .. name it something that no one can guess it (you can protect it with password from an option in the cpanel).
So when you do those steps .. you will have the same live activities running on your test wordpress blog. You can now change, add or remove any part of the website code without changing the original wordpress blog code.
NB: Don't delete or edit posts, articles because this will affect the original wordpress too since both are connected to the same database.

cmps 26 Light Poster

Dear junji, I googled some bubble logos Google, personally I found 2 things that may not look good in this logo.
Lot of small bubbles: try to make them bigger - Decrese the number of bubbles
Not realistic and color: Bubbles doesn't look realistic, I don't think realistic bubbles will be clear, what you've illustrated is the best you can do for a bubble in this case. But try to color them in green.

Good Luck

cmps 26 Light Poster

Without putting some self effort we can't help you, and from this question, it looks like you are not serious in learning how to code.

cmps 26 Light Poster

Dear "Proglearner", Frist of all here's a link to the best HTML web tutorial:
(IMAGE TAG)
http://www.w3schools.com/html/html_images.asp

After reading this I think you will be able to more understand what is the src and how to use it.
I'll try to explain it in my own words:
<img src="images/test.jpg">
This is how we display an image in an html page.
<img> => image
src => source

THe src attribute will take the .html file directory as the main/default directory.
For example here src="images/test.jpg"
This means that in the same directory where the HTML file is located, there is a directory named 'images' which contain the file 'test.jpg'

Hope this was helpful, Good Luck ;)

cmps 26 Light Poster

Dear "jonow", why don't you just use the MVC frameworks ?
All what you are talking about are included in those frameworks ...
Wordpress (Not the best example) for example uses the MVC structure, and if you notice the link looks like this domain.com/class/function/value

You can use .htaccess to modify the URL, but presonally I don't recommend you to use it, since I think that you will face some problems in the future when trying to modify some code or develop more pages.

Good Luck

cmps 26 Light Poster

You are welcome :)

cmps 26 Light Poster

The prob is that the text should be on the left and the input in the middle ?
if yes, here's the code:
try it:

<div style="height:4em; width:100%;">
    <div style="height:100%; width:40%; float:left; line-height:3em;">
        <label for="">Nume de utilizator: *</label>
    </div>    
    <div style="width:100%;" align="left" style="float:right;">   
        <input onfocus="change(1)" value="" maxlength="16" id="user" name="user" style="height:3em" class="bar curved5" type="text">
    </div>
</div>
cmps 26 Light Poster

Dear cristian.stilpeanu.3, may you try this:

<div align="center" style="height:3em">
    <label for="">Nume de utilizator: *</label>
    <input class="bar curved5" name="user" type="text" id="user" maxlength="16" value="" onFocus="change(1)" class="validate[required,custom[noSpecialCharacters],length[5,16]]" />
</div>
cmps 26 Light Poster

Dear 'garyjohnson', since you posted this topic in the webdesign html css section, I will concider that you are not using the dynamic programming language PHP.
Using html css you just have to make another HTML page let's say the album is in file
named: albumName.html
Copy and paste this page again and name it albumName2.html
and make a link to this page by adding
<a href="albumName2.html">Next Page</a>
in the first page at any place you choose.
Now change the source of the images so they link to the 8 remaining.
If you are using PHP & MySQL let me know because here you will be using the pagination with the LIMIT option in MySQL.
Hope this is clear, for any other inforamtion feel free to ask.

cmps 26 Light Poster

Hello, is the problem with closing parenthesis, or other, maybe logical errors ?

cmps 26 Light Poster

Hello again 'viveksraman', the problem is that you are doing a while loop in which the first condition is false, in other words
while($row = mysql_fetch_assoc($retr))
is the same as
while(false) which will not read the content and will directly jump to the last close curly brkt

while($row = mysql_fetch_assoc($retr))
is only used if you are sure you have more than 1 row as a result of you query "SELECt ..."

since here there is no result, mysql_num_rows($retr) = 0;
$row = mysql_fetch_assoc($retr) is $row = false
therefor while(false) and the body is not executed

I want to repeat one thing, in checking username and password, in most cases we don't use while, cuz username are unique, but it's not a problem if you use it :)
to fix your code

SOLUTION OF YOU CODE:
1 - Back to your code, remove the else that is not executing and will never.
2 (First Method) - And you can add a boolean variable like found = false; before the while loop.
Inside the while loop write found = true;
and after exiting the while loop, write this condition

if(!found)
    echo $un . " not found";

2 (Second Method) - you can simply add this after the exiting the while loop:

if(mysql_num_rows($retr) == 0)
    echo $un . " not found";

Hope I was clear in my explanation :)
Good Luck

cmps 26 Light Poster

I just noticed that you want the option, Password doesn't match. OK
Just replace this in my previous code:
I recommend you to try both codes cuz you may use the first code block in your future ;)

mysql_select_db($database , $connection) or die(mysql_error());
$query = mysql_query("SELECT uname,password FROM user WHERE uname = '$un'");
$row = mysql_fetch_assoc($query);
$num_rows = mysql_num_rows($query);

//I considered the user is unique, if not change '== 1' to '> 0'
if($num_rows == 1){
    if($ps != $row['password']){
        echo "Password doesn't match";
    }else
    {
        echo "Welcome " . $row['uname'];
    }
}else
{
    echo $un." not found";
}

Good Luck
PS: THE CODE IS WRITTEN DIRECTLY HERE AND NOT TESTED

cmps 26 Light Poster

Hello 'viveksraman'.

You have to debug this by echoing before and after the conditional statements, and by adding the "or die(mysql_error());" after a function (check later in my code).

Or try to put this $row = mysql_fetch_assoc($retr); just before the while.

Anyway you can add this to your code
$row_num = mysql_num_rows($retr);
this will return the number of rows found in the database, if it's 0 than nothing found, if you want the username to be unique then the variable should be equal to one and NOT greater than one!!

Here's how I write your idea:

$connection = mysql_pconnect("localhost","root","password") or die(mysql_error());
$database = "amirbwb";

$un = $_GET['usname'];
$ps = $_GET['passwd'];

mysql_select_db($database , $connection) or die(mysql_error());
$query = mysql_query("SELECT uname,password FROM user WHERE uname = '$un' AND password = '$ps'");
$row = mysql_fetch_assoc($query);
$num_rows = mysql_num_rows($query);

//I considered the user is unique, if not change '== 1' to '> 0'
if($num_rows == 1){
    echo "Hello " . $row['uname'];
}else
{
    echo $un." not found";
}

PS: THE CODE IS WRITTEN DIRECTLY HERE AND NOT TESTED

cmps 26 Light Poster

Hello you can use the printf();

float num = 1.23456;
System.out.printf("the float number is: %.1f",num);

%f prints the full float number
%.1f prints 1 decimal
%.2f prints 2 decimal
%.3f prints 3 decimal
etc ....

cmps 26 Light Poster

Dear Amiyar, the code i wrote fetch for both id and not only the first one ...
Maybe you mean you want to do this:

 SELECT shipping_us FROM tbl_product WHERE prod_id=526 OR  prod_id=527

?

cmps 26 Light Poster

Hello ... I think all of these are O(n)
O(n) is when you have 1 for loop or while loop
if you for loop inside a for loop u will get a O(n^2)
and every time you put for loop inside another you will increment the power number
ex:

O(n)for(){} 
O(n^2)for(){for(){}} 
O(n^3) for(){for(){for(){}}} 
O(n^4) for(){for(){for(){for(){}}}}

if you have 2 for loops but not one inside the other, you will get O(2n) which is concidered as O(n).
Examples

O(3n) for(){} for(){} for(){}
O(2n) for(){} for(){}

The above examples are concidered O(n)
Formula: O(#n) = O(n)

cmps 26 Light Poster
$sql="name, price from table1";
echo "<tr><td>Name</td><td>>Price</td></tr>";
if ($result=mysql_query($sql)) {
while ($row=mysql_fetch_assoc($result)) {
echo "<td>".$row['name']."</td>";
echo "<td>".$row['price']."</td></tr>";}}

Try this:

Dunno the if condition what it does but anyway:

while ($row=mysql_fetch_assoc($result)) {
     if($name == $row['name']){
         echo ", ".$row['price'];
     }else{
        echo "<br/>";
        echo $row['name'] . ", ";
        echo $row['price'];
    }
    $name = $row['name'];
}

Good Luck

cmps 26 Light Poster

Dear Amiyar ... What is happening to you is very logical.
Lets debug what you are doing:

 echo $s_country;
    $sql2="SELECT prod_id FROM tbl_order_item WHERE order_id='$order_id'";
    $res=mysql_query($sql2) or die(mysql_error());
    $i=0;
    $j="";
    while($rs=mysql_fetch_array($res)){
        $j .= $rs['prod_id'];
        $i++;
    }

No syntax error ... but a logical error exists.
in the while loop you are doing this:
in the first loop j= 526;
in the second loop you are doing this "append to j 527" so j = 526527;

So j is no more the target id you want to fetch from database.
so what you want to do here is to put to put the code

if(trim($s_country)=='US' || trim($s_country=='United States' )){
    $sql3 = "SELECT shipping_us FROM tbl_product WHERE prod_id=".$j;
    $res=mysql_query($sql3) or die(mysql_error());
    $shipping_cost1=mysql_fetch_object($res);
}

inside the while loop:

echo $s_country;
        $sql2="SELECT prod_id FROM tbl_order_item WHERE order_id='$order_id'";
        $res=mysql_query($sql2) or die(mysql_error());
        $i=0;
        $j="";
        while($rs=mysql_fetch_array($res)){
            $j = $rs['prod_id']; //I removed the dot cuz i don't want to append
            if(trim($s_country)=='US' || trim($s_country=='United States' )){
                $sql3 = "SELECT shipping_us FROM tbl_product WHERE prod_id=".$j;
                $res=mysql_query($sql3) or die(mysql_error());
                $shipping_cost1=mysql_fetch_object($res);

                /*YOUR CODE GOES HERE*/
                echo theCalculation;
            }
            $i++;
        }

Hope you understand the logical error.
Good Luck

cmps 26 Light Poster

Where did you defined this variable 'operationsPrioriteToDoListModel' ?
May you provide us with the full code?

Thank you

cmps 26 Light Poster

So the advantage of using a constructor over a setter is that a constructor can initialize more than a variable, which is what a setter does?

Yes you can say that :)
I'am sure that you will learn with time the hidden advantages of constructors,
good luck

cmps 26 Light Poster

Creating a website and buying a domain name are two totally different things.
If you want to create a website, you have to know how to code in HTML CSS (Minimum), and if you are planning for a more dynamic website you have to know PHP & MySQL.

Concerning the domain name, if you want free hosting, your domain name will look like this www.devid.*********.com
********* is a name generated by the website during your registration, and probably it will ask you for the random word available so you can select one (Personally I don't like that, and it's not serious, but useful if you are testing the life of a website and how everything works ...)
And as '<MICHAEL>' said, www.000webhost.com is good for free hosting.

If you want a more serious website, buy a domain name with hosting, it will cost you about 3-6$/month depending on which web hosting company you are buying from.
Some recommended companies are: Bluehost.com and GoDaddy.com

Good Luck

<M/> commented: Good info For Dummies :) +5
cmps 26 Light Poster

Hello 'Violet_82', we can sometimes get rid of the constructor, the example you looked at may not be the best to judge if constructors are important or not. Look at this example, it may makes more sense:

Person.java

public class Person{
    private firstName;
    private lastName;
    private age;

    Person(String firstName,String lastName,int age){
        this.firstName = firstName; //this. is used to point to the variable defined at the top and not the parameter of the constructor
        this.lastName = lastName;
        this.age = age;
    }

    public void setFirstName(String firstName){
        this.firstName = firstName;
    }

    ....
    ....
    ....
}

Here's now how we use this:

Person aBoy = new Person("Hello","World",19);

isn't it more practicle that each time calling the setters ?
NB: the code is not tested, but hope you got the idea ... Good Luck

cmps 26 Light Poster

Hello 'meowmonkey', not sure if that what you want ... Print a rectangle of y lines and x item on every line
Anw here's the code:

int Y = 4;
int X = 12;

for(int y=0; y < Y; y++){
    for(int x=0; x < X; x++){
        System.out.print("#");
    }
    System.out.println();
}
cmps 26 Light Poster

Hello I ma trying to practice on Data structure using java. I solved a lot of problems but this one looks interesting but I need some help understanding what I really have to do ...

write a program that simulates the operation of a busy airport that has only 2 runways to handle all takeoffs and landings. you may assume that each takeoff or landing takes 15 minutes to complete. one runway request is made during each five-minute interval, and the likelihood of a landing request is the same as for a takeoff request. priority is given to planes requesting a landing. if a request cannot be honored, it is added to a takeoff or a landing queue. your program should simulate 120 minutes of activity at the airport. each request for runway clearance should be time-stamped and added tto the appropriate queue. the outputs of your program should include the final queue contents, the number of landings and takeoffs completed, and the average number of minutes spent in each queue.

I just didn't understand what I have to do with the time and the queue and the 2 runways ...
May someone explain to me what I am supposed to do?
I don't want the solution code just explanation ...
Thank you :)

cmps 26 Light Poster

Hey Taywin, actually I read this example, and fixed my code. The problem was that I didn't close the formatter

formatter.close();

but anyway the other way is also a nice one thank you :)

cmps 26 Light Poster

Hello!!!

mmm am learning OOP in Java ... and now I'm facing a prob in reading/writing .txt file
here's my code:

import java.util.Scanner;
import java.util.Formatter;
import java.io.File;
import java.io.FileNotFoundException;

public class Tester {
    public static void main(String[] args)
    {
        Scanner scan = null;
        Formatter formatter = null;
        File fileI;
        File fileO;

        fileI = new File("/home/amir/workspace/ForExam1/src/Class1/input.txt");
        fileO = new File("/home/amir/workspace/ForExam1/src/Class1/output.txt");

        try {
            scan = new Scanner(fileI);
            formatter = new Formatter(fileO);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        int first = scan.nextInt();

        formatter.format("%d", first);
    }
}

and here the input.txt file:

123

The code is generating the "output.txt" file put it's empty, I SOP the 'first' variable which has the value of '123' and it worked ... but the code is not writing the value of 'first' in the output.txt ...

Anyidea how to fix this code??.

Thank you, Regards

cmps 26 Light Poster

aha okay .. i think that things are clear now ... I will watch the series
Thank you!!

cmps 26 Light Poster

aha very interesting !! thank you
Can I make a robot starting from Arduino ? like this one Click Here
??

cmps 26 Light Poster

Heyyy!!!

I saw yesterday some projects for computer scientists, they connected the computer to a light that turn on/off on a submit button click from a webpage (locahost) ...
It's not all, there is a team who created a trafffic light sensssorrr!!!! the lights switch automatically depending on the move of the hand ....
I asked lot of people from where can i start ... but no one answered me ... So hope DANIWEB could be a hero =D

Q: what are the languages used?
From where can i start ?

I know java (first year) and web dev{html,css,php,js etc...} (but I don't think they are the key here)

Thank you,
Best Regards