rotten69 20 Posting Whiz

Hmmm, the question is why do you want to initialize your variables with empty values?

How about trying this?

1- Separate your PHP file just for the sake of understanding what's going on in your scripts and different pages.
2- Putting the name of PHP file in the action attribute in the form. E.g <form action="validation.php" method="POST">

3- Try this:

<?php
    // define variables and initialize with empty values
    $fname = $_POST["fname"];

    $lname = $_POST["lname"];

    $pass = $_POST["pass"];

    $errorMsg= "Missing ";


    if (empty($fname) ) {
       echo $errorMsg + "First name";

    }else if (empty($lname) ){
        echo $errorMsg + "Last name";

    }else if (empty($pass) ) {
        echo $errorMsg + "Password";

    }else{
        echo "Success";
    }
 ?>

Save the above code in a new file called validation.php

rotten69 20 Posting Whiz

My suggestion for the book that you should be reading (if you only want to learn Java from the basics and gradually advancing to higher levels) is Thinking in Java by Bruce Eckel. It is really helpful n useful.

rotten69 20 Posting Whiz

@Jim.. it lasted for 29 yrs. Wow. That's really a long time.

@ScarWars9 ... Good luck and let us know how you go and what it's like.

rotten69 20 Posting Whiz

I was told it's not a good practice to store images in a database because they take lots of space in the database?

What is the best solution to that?

rotten69 20 Posting Whiz

I think you'd go with inheritance to solve the problem. Think of it this way, for example, you're implementing a vehicle and different types of it. You'd have a vehicle class that has the main functionality which is shared by different types such as trucks, cars and so on. In truck and car classes you'd have functions that are just specific to them.

In your example, you'd have the main management industrial tool class which implements functions that will be shared by other classes like electric, hydraulic and mechanic.

in the case of your program catching the error, you'd check for the appropriate errors such as checking the input if it is a number, string or others depending on what the program is expecting. If the program fails in getting the right input, then it throws or deals with the error.

I hope that makes sense and helps you a bit.

rotten69 20 Posting Whiz

For operting systems other than windows including Mac OS and Linux, I would go with Monodevelop.

rotten69 20 Posting Whiz

Hmmmmm,If you want to get the avaerage of the inputs that you're getting from your users.
1- Loop through the inputs and store them in one variable by using += operator or variable = variable + array[index] / array.Length.

I reckon you should catch exceptions like FormatException and other ones. your program crashes I enter a string in there.

Try this.

        int input;
        Console.WriteLine("Enter the number of expriments you want to make:");
        input = int.Parse(Console.ReadLine());
        int[] index = new int[input];
        if (input > 2 && input < 6)
        {
            int temp = 0;
            int avg = 0;

            for (int counter = 0; counter < index.Length; counter++)
            {

                Console.WriteLine("Enter number" + counter + ":");
                index[counter] = int.Parse(Console.ReadLine());

                temp += index[counter];
            }

            avg = temp / index.Length;
            Console.WriteLine("Average:" + avg  + "\nwe have :" +temp + " experiments");
        }
        else
        {
            Console.WriteLine("Your input is not valid.");
        }
rotten69 20 Posting Whiz

Hey everyone,

I'm wondering why my reputation points don't go up when people give my posts in thier threads a vote-up.

Cheers,

rotten69 20 Posting Whiz

it is a good idea to use var when declaring variables. E.g var number. The reason being is that your variables will be easy to trace and and it is a good practice.

I guess you're trying to add the value to the textbox you've got there, right?

Try this

 document.divfrm.div.innerHTML=d;
 document.divfrm.div.innerHTML=sp;
rotten69 20 Posting Whiz

Oh, I know why this is not evlauting because of the space I got in the button name

<button> day</button> != <button>day</button>

it looks exactly the same but the space needs to explicitly speicified in the condition.

rotten69 20 Posting Whiz

The snippet below should solve the problem you had with accessing the array $list [count($value)] which doesn't make sense to me. If you're trying to add the value of count to the array because your previous line stores the number of elements in an array to the index. The way you'd normally do it is $list [] .=count($value) the result you will get is this:
Array ( [0] => 3 [1] => 3 ) However, this won't tell you much about the data stored in the array.

Try this and let us know how you go.

$parent=0;
function getMenu($menu, $parent){

    $list=array();
    foreach ($menu as $key=>$value){

        if($value['parent_id']==$parent){

            $counter = count($value); // count the number of elements in an array
            $list[] = $value;
            echo $counter; 

            echo "<br>";
         }

     }

        return $list;

}

cheers;

rotten69 20 Posting Whiz

I'm thinking of making a simple calculator that does temperture conversion.

rotten69 20 Posting Whiz

Hmmm, Enable the error reporting function so you will be shown if there are any errors.

error_reporting(E_ALL);

You've got the class name as sandwich and construct as operation (change the name of the function to sandwich). In OOP, you need to have the constructor name corresponding to the class name. You may make a function called operation and then it gets called in the constructor.

I hope this helps!

rotten69 20 Posting Whiz

To answer your question, here is an example. I hope the example I'm giving will help you.

<?php


$name = "Dani";

if($name== "Dani"){
    echo $name;         => this will output Dani
    $name .= " Web";    => this will concatenate the string " Web" to the "Dani"
}

echo $name;    => this will output "Dani Web"


?>
rotten69 20 Posting Whiz

Apparently, you don't have a function called session_is_registered.In the case that it is defined in another file in the same directory, then add this line in the top of the page

include("YourFileName.php");

I hope this helps.

rotten69 20 Posting Whiz

Like simplypixie said, You won't be able to run PHP code within HTML files (e.g index.html) so the files have to be with the extension of .php (e.g index.php). The reason being is that you're telling the browser to interpert PHP code within HTML which doesn't make sense to the borswer. It will render it as a simple text. However, if you do it the other way around, it will render html code within your php file without any issue.

I hope this helps you a little. If you post your code here so we can have a look and tell you if it is broken or not.

@blocblue: why is that incorrect?

simplypixie commented: Much better explanation than mine :-) +7
rotten69 20 Posting Whiz

Hi everyone,

I'm sure there are people who are using highCharts framework. I'm having a trouble passing the values to jquery code from PHP json. Your help is so appreciated.

This is my php section

<?php
        header('Cache-Control: no-cache, must-revalidate');
        header('Expires: Mon, 01 Jan 2013 00:00:00 GMT');

        // The JSON standard MIME header.
        header('Content-type: text/json');



        include('mysql_connector.php');
        $port = new MySqlDatabase();
        $port->connect('root','','theants');


        $query = "select * from userss";
        $result = mysql_query($query);


        $array = mysql_fetch_assoc($result);
        $jsonData = json_encode($array);

        echo $jsonData;

?>

This is my jquery section

$.getJSON('ajax.php', function(jsonData){

                                    $.each(jsonData, function(key, value){

                                        chart = new Highcharts.Chart({
                                            chart: {
                                                renderTo: 'container',
                                                type: 'pie'
                                            },
                                            title: {
                                                text: 'User Ages'
                                            },
                                            xAxis: {
                                                categories: ['0-9', '10-19', '20-29', '30-39', '40-49', '50-59', '60-69', '70-79'],
                                                title: {
                                                    text: 'Age group'
                                                }
                                            },

                                            tooltip: {
                                                formatter: function() {
                                                    return ''+
                                                        this.series.name +': '+ this.y +' user(s)';
                                                }
                                            },
                                            plotOptions: {
                                                bar: {
                                                    dataLabels: {
                                                        enabled: true
                                                    }
                                                }
                                            },
                                            legend: {
                                                layout: 'vertical',
                                                align: 'right',
                                                verticalAlign: 'top',
                                                x: -100,
                                                y: 100,
                                                floating: true,
                                                borderWidth: 1,
                                                backgroundColor: '#FFFFFF',
                                                shadow: true
                                            },

                                            series: [{
                                                name: 'No. of Users',
                                                data: []
                                            }]
                                        });


                                    });
                            }

            );

I just want to get the values from the function "function(key,value)" and I am not concerned about the key. Quick example/examples will do for now.

rotten69 20 Posting Whiz

Yeah, respect to all who contributed in this thread. Although, I think it is so annoying that every time I post something, I get the message alerting me if I want to share my post on other websites. Consider giving your users options if they want to disable the feature or not.

rotten69 20 Posting Whiz

The required attribute is used to indicate that particular field is required and needs to be filled in. Think of it as an input validator.It has got nothing to do with language translation at all.

I hope this helps.

rotten69 20 Posting Whiz

You don't ever use the word OR. Use this symbol || which means or. This symbol && means AND.

if($row['banned'] == 1 or $row['banned']== 2) {

}

What is the message you get when you run your code? Try putting values you're trying to check within single/double qoutes.

rotten69 20 Posting Whiz

I know Java can be sometimes confusing when you're trying to learn something new about it. I think there is a problem with defining the array. However, Have a look the Java Tuturial website which explains one dimension and multi-dimension arrays.The link is here

Scroll down to the section mentioned below.

class MultiDimArrayDemo {
    public static void main(String[] args) {
        String[][] names = {
            {"Mr. ", "Mrs. ", "Ms. "},
            {"Smith", "Jones"}
        };
        // Mr. Smith
        System.out.println(names[0][0] + names[1][0]);
        // Ms. Jones
        System.out.println(names[0][2] + names[1][1]);
    }
}

Just if you post any piece of code next time, PLEASE ensure that you use the Code tags. Therefore, your post will be much easier to follow. Thanks.

rotten69 20 Posting Whiz

You guys have got brilliant ideas and lots of ways that anyone can use to practise their Java knowledge. But what we are lacking/missing is that we don't have enough instructions on how you'd approach such an idea like making an email client or a game. Due to beginners' knowledge or amount of practice in Java programming, they may think it is a kinda difficult task to do.

What would be fantastic is to see someone who has got the time to take us through a simple idea.

cheers,

rotten69 20 Posting Whiz

some good suggestions involving networking!

I can redirect you to a tutorial on networking. Check out this link It may be useful for what you need to do or even to get started with network programming.

rotten69 20 Posting Whiz

Here is what you need. It has the doctype declared and also the document elements declared. IF you take all that and paste into a notepad and save the document as index.html, then try running it in a browser. You will definitely not see anything other than the title for the page which is "title for your page goes here". Adding something like <p> This is a paragraph</p> within the body tags.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

  <head>

   <title>Title for your page goes here</title>

  </head>


  <body>



  </body>

</html>
rotten69 20 Posting Whiz

Like James mentioned in the first post, suggest cool ideas for Java learners and show them what they can do by programming in Java. I gotta be honest with you here. I have heard this statement a lot 'You can do everything in Java'. Right. I get it. But what do you actually mean by everything? What if I'm interested in breaking into computers. Will learning Java help me achieve that? That is when I started learning it at uni. I had so many questions for my lecturer. It was kinda hard to ask your lecturer every single question you could think of.

I got an idea for java projects. Make a simple calculator.. You will require to write a few methods (subtraction, addition, division and multiplication) as well as to do some checking on inputs. For example, if something is divided by ZERO, then what happens? In fact, it can't be divided by zero and should return an error.

it is entirely up to you whether you want to design a GUI for the calculator or not. Try making it look a little fancy. Let it display time if you want or even surprise users by displaying a WoW message if they calculate a number greater than 5000.

If you face any problem with the projects suggested in this thread, PLEASE open a new thread with a name like below:

Java projects for learners - "Calculator"

For this example, I used the project name calculator. However, you will need …

rotten69 20 Posting Whiz

Hi James, I'm strongly and kindly suggesting for Java operators to open a sticky thread for beginner to intermediate projects. Just allowing learners who just start learning Java, to have a look and feel of what they can do by programming in java.

Guidelines are pretty simple. An operator, of course will expectedly post more than one project over the time and a walk-through as well to explain how things can be solved for a particular project. The guidelines that I can suggest at the moment are as follows:

  • Numbering the project so this can help users if they want to ask/refer to a particular project.
  • Anything off topic can not be posted.
  • Active discussion between users that what we'd like to see. Also Get the java community on this website active.

Have a look at the website I posted up in my first article. That should give you an idea of what should be done in the java forum.

rotten69 20 Posting Whiz

Try this website. That guy does java programming tutorials and does some on networking and chat app. This might be useful for your project.

By the way, I like the idea you've got.

rotten69 20 Posting Whiz

Hi everyone,

I consider myself as a java beginner because I haven't been involved in a lot of projects. I'm opening this thread to raise awareness that we don't have java projects thread primarily for beginners and it could help advanced java programmers in terms of practising their java knowledge. I would like any operators in this forum to consider this idea. I am sure it will help people who haven't practisied what they have learnt. Any users likes the sound of the idea and wants to see it in this forum, please have your say here. Therefore, operators can know that there are some people interested in the idea.

I had a look at the python forum and they have got something to help python beginners increase their knowledge and get their hands on practical projects. I had a thought of going back to learning python but then I thought it is worth sticking to the languages I know because I want to use them. And, If I had to learn python again, that shouldn't be a major issue.

Thanks for reading this and please do have your opinion on the idea. I would really love to hear from you people.

Stuugie commented: Great Idea +2
JamesCherrill commented: Excellent idea, I will implement it. +14
rotten69 20 Posting Whiz

Ok. The steps are as follows:
1- Open any text editor and make a file and call page or whatever name .php so this will be page.php

2-Take the snippet below and paste in there.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
   <title> I am checking the values for the options chosen in the form </title>
</head>

<body>


         <form name="myForm" action="check.php" method="POST">

             Choose one of these values: &nbsp; 
                 <input type="submit" name="go" value="Go 1" /> &nbsp;
                 <input type="submit" name="go" value="Go 2" /> 

              <?php echo " <p style='background-color:red; width: 5%;'>" .@$_GET['text'] ."</p> "; ?> 


         </form>


</body>
</html>

3- Make another file and call it this name check.php if you want to change the name of the file, then you will have to change the name in the action attribute as well.

4- Take the snippet below and paste it in there

<?php

    $go = $_POST["go"];


        // here we're checking if there is a value for the variable "go" AND the value equals to "Go 1"

        if( (isset($go)) AND ($go1 == "Go 1") ){    
            header("Location:checking.php?text=Go 1 is on");

        }else if(  (isset($go)) AND ($go1 == "Go 2") ){ 
        // here we're checking if there is a value for the variable "go" AND the value equals to "Go 2"

            header("Location:checking.php?text=Go 2 is on");
        } 
?>

Please mark this thread as solved if your problem is fixed. And also, Don't forget to give me a rep on the …

rotten69 20 Posting Whiz

Or you can use this HTML code as well

<input type="hidden" value="" />

I think that is the same as using CSS to hide it.

If this solves your problem, then mark the thread as solved and don't let it be pending.

rotten69 20 Posting Whiz

There are a lot of programs that you can use to make websites. If you're aiming at making a number of web pages and would like to organise them, then you may need to look at IDEs such as Eclipse for web development, NetBeans or Komodo. Personally, I have been using Eclipse for php, html and css and a little bit of Javascript then wanted to learn how to use javascript widely. and, I had to download Komodo which has been the best so far for javascript auto-completion. And Eclipse for web development is good for php. Also, if you want something really simple, Try using Notepad++ for free.

If you have any more questions, don't hestitate to ask. And, I hope this helps you.

ndeniche commented: Komodo, where have you been my whole life? +10
rotten69 20 Posting Whiz

How would you like us to help you? I'm sorry to say this, but I don't think anyone of us will have the time to go through what you've produced or someone has produced for you... If you're really after some help with the lines you've posted, then you need to be specific about the issues you're facing with the code. Because we don't know what you're trying to achieve.

Good luck

rotten69 20 Posting Whiz

Hey everyone,

I tried testing this code if it is true or not. But,apparently, it is indeed true. So, it is not like referencing an element in array and changing its value. Can someone explain it why this is exceptional with numbers, please?

var a = 3.14; // Declare and initialize a variable
var b = a; // Copy the variable's value to a new variable
a = 4; // Modify the value of the original variable
alert(b) // Displays 3.14; the copy has not changed

Why is this happening? and it is so different from the code below:

var a = [1,2,3]; // Initialize a variable to refer to an array
var b = a; // Copy that reference into a new variable
a[0] = 99; // Modify the array using the original reference
alert(b); // Display the changed array [99,2,3] using the new reference
rotten69 20 Posting Whiz

I think a simple Javascript code will get you a solution that you want. Hint: give it an id and use getElementById in Javascript if you want to solve the problem by using Javascript.

Well, since the task's is a piece of cake, You can also achieve what you want in CSS 1,2 or 3.

<h1 [U]class="title"[/U] >The Title</h1>

In your CSS,

.title:hover { color: BLUE; }

I hope this helps you.

rotten69 20 Posting Whiz

I created a foreign key on a table just using this statement. When I wanted to drop it, phpMyAdmin didn't allow me to do so. Would anyone suggest a nice way of getting away with it?

ALTER TABLE `likes` ADD CONSTRAINT (fk_user_id) FOREIGN KEY REFERENCES `users` (user_id);

This line worked fine and created an index instead of creating a foreign key. And, I wanted to drop it and create a foreign key. Unfortunately, it didn't want to be dropped.

The message I got from phpMyAdmin is below:

SQL query:

ALTER TABLE `likes` DROP INDEX `fk_user_id`

MySQL said: Documentation
#1553 - Cannot drop index 'fk_user_id': needed in a foreign key constraint

Cheers,

rotten69 20 Posting Whiz

Is that even a question? and Are we supposed to do the coding for you?

PLEASE POST your question and the code that you have a problem with so we can HELP YOU.

Thanks.

rotten69 20 Posting Whiz

Here you've got a lot of sites to start with. Once you get the logic down, things will come smoothly. Firstly, You should do a research about the differences between POST and GET functions and what they do. They can make a big difference in your application as in the data being hidden or shown in a URL address.

Good luck.

rotten69 20 Posting Whiz

Yes, I forgot to say something. Like Cleo123 said, I do emphasize on the point that you should always look up functions on the PHP website and see how they work. If you can't find a good explanation, then you've got the forum or google.

rotten69 20 Posting Whiz

You may also have a look at LINQ to SQL if you plan on making a big game. LINQ to SQL is a very elegant way of retrieving data from a database. You'd only need to interact with database objects rather than using SQL queries.

Try these sites: 1- Intro to C#
2-Microsoft's website(should be your reference site for functions/ APIs..)

Good luck.

rotten69 20 Posting Whiz

Start with w3schools. Once you get the basics, then hit PHP academy (my favorite)
PHP academy


Good luck!