phorce 131 Posting Whiz in Training Featured Poster

http://www3.uic.edu.ph/images/100x102/1242343.jpg

Doesn't exist, or, you do not have permissions to access it.

Please can you vardump / echo $complete...

Also, what does "file" do? :S

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I don't think it is possible with Arrays (Someone correct me?) I've only ever seen/used counting the elements as they have been inserted.

Can you not use STL vectors?

phorce 131 Posting Whiz in Training Featured Poster

Your first problem is you delcare a constructor (in your .h file) but you don't reference it in the class functions (.cpp)... So put this:

Burger::Burger()
{

}

Your other problem is the fact you don't tell the compiler where the functions are (in which class) you declare an object of "yum" so use it..

double val1 = yum.hamburgerCalc(yum);
double val2 = yum.cheeseburgerCalc(yum);
double val3 = yum.dcheeseburgerCalc(yum);

I don't understand your code. You have a main, then more class functions.. I hope this isn't all in one file.

phorce 131 Posting Whiz in Training Featured Poster

In Dev-C++ (I'm sure it used to be called DevCpp) all are the files inside a project? In other words, it needs to be linked inside a project, rather than just two seperate files (even if they are in the same folder, and you've inluded the file path).. I think that's how DevCpp works, which is why you're getting this error (i guess)!

phorce 131 Posting Whiz in Training Featured Poster

Couldn't you just have a count set to = 0 at the beginning and each time a value get's inserted into the array, it increments by 1? Or, if you just need to know whether someone has entered something - Have a Boolean? Here's an example anyway:

#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {

    int numbers[8];
    int count = 0;

    for(int i=0; (i < 3); i++)
    {
        numbers[i] = i+i+2*i;
        count++;
    }

    cout << count; // prints "3" only 3 elements added to an 8 integer array

}
phorce 131 Posting Whiz in Training Featured Poster

This is weird. What compiler are you using?

Haven't posted an actual thread here, in a while, but, should this really be a code snippet? your not submitting one, just a question -looks over there >>

phorce 131 Posting Whiz in Training Featured Poster

@adhakrishna.p Short hand tags is bad.

phorce 131 Posting Whiz in Training Featured Poster

Hey, so what you need to do is parse in the different "Grades" store these inside an array (or a map, depending on whether you have been through these). You can then iterate through the array and check.. E.g.

#include <iostream>

using namespace std;

int returnGrade(char theGrade)
{
    switch(theGrade)
    {
        case 'A':
          return 90;
        break;

        default: return 0;

    }

}

int main(int argc, char *argv[]) {

    char grades[] = {'A', 'B', 'B', 'B', 'A', 'D'};
    int *grades_numeric = new int;
    int size = sizeof(grades)/sizeof(grades[0]);

    for(int i=0; (i < size); i++)
    {
        grades_numeric[i] = returnGrade(grades[i]);
    }

    cout << grades_numeric[0];

}

Hope this helps a bit :)

phorce 131 Posting Whiz in Training Featured Poster

Polymorphism changes what the output is depending on which object is called.

For example:

An animal can speak, you can have many animals.. "Cat", "Dog" are both animals so they can be inherited from animal HOWEVER, they both speak different so you can use polymorphism to output different speaks() depending on what object is being called.

Let's take the example of Students, you can have "Home" and "International" student's and they can both inherit from Students HOWEVER, their fee's change. Look at this example I worte:

#include <iostream>

using namespace std;

class Fees {

    public:

        Fees() { }

        virtual float feeAmount() { return 0; }

};

class Home : public Fees {

    public:

        float feeAmount() { 
            return 12000;   
        }

};

class International : public Fees {

    public:

        float feeAmount() {
            return 15000;

        }

};
int main(int argc, char *argv[]) {

    Home h;
    International i;

    cout << h.feeAmount() << endl;

    cout << i.feeAmount();

}
phorce 131 Posting Whiz in Training Featured Poster

Hey,

Little confused, do you have to ask exam questions and the user answer OR are you given a .txt file with all their grades?

phorce 131 Posting Whiz in Training Featured Poster

I don't think you quite understand Polymorphism. Can you show the class definitions please? Also, explain what it is you're actually trying to do..

phorce 131 Posting Whiz in Training Featured Poster

PHP works in paraelle / conjunction with HTML so essentially you will use it along side it, not "develop a new site using php".

If you're using a "Hosting" provider, then, they will tend to have PHP/MYSQL installed on their servers, however, if you are using your own computer then you can download apache/php/mysql .. If this is the case, what operating system are you working on?

phorce 131 Posting Whiz in Training Featured Poster

Hey, no problem!

You can var_dump($var) and see what the variable contains :)

phorce 131 Posting Whiz in Training Featured Poster

You sure you're not setting the SESSION['user_id'] from a $_GET['id']?

e.g.

<?php

   $id = $_GET['id'];

   $_SESSION['user_id'] = $id;
OsaMasw commented: great advice +1
phorce 131 Posting Whiz in Training Featured Poster

Yes, look at enrolement. How does your CURRENT University enrol students? Is it good, or can it be improved? If so, how? Can enrolement be completed online, for instance using a form? Can you therefore have QR codes that can somehow read in from your mobile from and activate enrolement around campus?

phorce 131 Posting Whiz in Training Featured Poster

Hey,

I don't know how much support we can give you on this, because we don't know what your interests are, or, what technologies you are into.

Have you done any work with API's? Understanding or using them. These seem to be highly used recently, so maybe base a project around API data?

Are you in a University or College? Maybe have a look around the University/College and see what could be improved in terms of data / information.

Hope this helps

phorce 131 Posting Whiz in Training Featured Poster

@szjna - In Dev-cpp (I think it's the same compiler) then you need to create a new "Project" rather than just having them in the same folder.

phorce 131 Posting Whiz in Training Featured Poster

Yeah, the output is

"This is the way to an A Grade - Grade A for Sure"

However, I don't think you'll be getting an A grade with this code ;)!

@Ancient Dragon is right, you need to pass by reference NOT value. Also, you're assume that there are 8 values within this vector, what happens if there is more? The program will just crash. Use .size() instead of defining the vector size. Also why not just push_back the elements for the vector instead of insert? mhmh!

Good luck :)

phorce 131 Posting Whiz in Training Featured Poster

Want to see Life of Pi!!

phorce 131 Posting Whiz in Training Featured Poster

Hey,

Do you mean the Viterbi Algorithm? :s

phorce 131 Posting Whiz in Training Featured Poster

@diafol Is right, when he says:

store the code as plain text - either in text files or in a DB - or for copying from a page. htmlentities() can probably output safely

You should (in a way) be able to upload the files (.cpp, .php., .htm, ...) But the contents of such a file should be parsed and stored inside a database then it can easily displayed on a webpage and at the request of the user can be downloaded as a file again.

The wrong way (If this is what I assume you're doing) is to allow people to upload .zip files and then download them.. This could lead to a lot of problems from your users.

If your system is for collaborating, sharing code etc.. Then it would be better and more efficent to parse and store inside a database rather than holding a whole bunch of .zip files onto a server. Have you thought about version control? I.e. someone takes the zip folder, makes some changes in ONE of the files and then updates it back to the server.. That's a whole project change, just for probably 1 line in 1 file.. That's not efficently done. :)

Echo89 commented: Thanks! +1
phorce 131 Posting Whiz in Training Featured Poster

@GokuLSSJ4

Post the updated code, which is giving you the error

GokuLSSJ4 commented: here i posted the updated code +0
phorce 131 Posting Whiz in Training Featured Poster

Hey,

Everything appears to work, up to the fact that:

1) You don't ask for the input for the mathemtical operator (+, -, / etc..)

    cin >> symbol;

2) Your conditional if statements are wrong, they should be like:

  if(symbol == '+')
  {
      cout << "Add";
  }

You should consider case switch statements for this program, I think it would make things a lot easier (IMO). Hope this helps :)

GokuLSSJ4 commented: I tried it is still the same +0
phorce 131 Posting Whiz in Training Featured Poster

@xbat

help with code

Really? Did you? I think you're implying that someone does the work for you, rather than hand someone a piece of code.. Please, don't take offence to this but you can't hardly call anyone here (Who, may I add is taking time out of their lives to HELP you) a "Retard" - Learn some respect before you even contemplate PHP/MYSQL.

phorce 131 Posting Whiz in Training Featured Poster

Hey,

So basically, the permissions is a problem with this script and I had problems with the fact that Apache cannot access crontasks (For some reason). I was able to (In terminal) run "crontask /crontask.txt" which would execute the crontask, however, from PHP it would not run it. It's weird, I'll have a look later when I get some time :)!

phorce 131 Posting Whiz in Training Featured Poster

So essentially, a cookie is stored on the person's machine, whereas a SESSION is stored onto the server.

Ok, it depends on the situation in which you are using and both of them will work in most situations, so for me, it's down to the fact I prefer SESSIONS over COOKIES.

I'll answer this question (in my opinion):

but if user hit remember me than cookie get start. this is a good idea or bad idea?

It's a good idea and a bad idea. If you're storing really secure information about the user and the user signs into a machine that many people use then offering this service would be a disadvantage (from the user's prospective).

Sorry if this isn't much help.

phorce 131 Posting Whiz in Training Featured Poster

Hey - Did you run the script? I want feedback ;)

phorce 131 Posting Whiz in Training Featured Poster

Hey, you need to use sessions (http://www.w3schools.com/php/php_sessions.asp) . So for example, if you have a "login" script, you can define these values and then create a script that only restricted members can access

phorce 131 Posting Whiz in Training Featured Poster

Here is one solution to your problem:

<?php

    function checkPreg($string)
    {
        if(preg_match('/^[^\W_]+$/', $string)):
          return true;
        else:
          return false;
        endif;
    }

    $string = "Hello244";

    if(checkPreg($string))
    {
        echo 'Yes, its ok';
    }else{
        echo 'No, its not ok';
    }


?>

Just use regex with the preg_match, you got the right function.

BUT, it might actually be easier just to use the pre-built in functions (for basic numbers and letters...) Here is an example:

<?php

    $string = "asfsf_";

    if(ctype_alnum($string))
    {
        echo "The string contains letters and numbers";
    }else{
        echo "The string contains chatacters that are not allowed"; 
    }
?>
Djmann1013 commented: Thanks +2
phorce 131 Posting Whiz in Training Featured Poster

Hey, throwing this out there.

(I spend my time researching/developing Speech Algorithms so don't code much in PHP anymore) but I read an article that said that PDO removes the risk of SQL injections.. So probabily. There's a lot of debate to whether PDO or MYSQLI is more efficient etc.. :)

phorce 131 Posting Whiz in Training Featured Poster

Welcome :)!

phorce 131 Posting Whiz in Training Featured Poster

plug-in??? You mean library.?

phorce 131 Posting Whiz in Training Featured Poster

Hey, pointers are pointers to memory locations (You want to do something specific to that memory block etc..)

If we're talking about passing arrays to functions, we use pointers:

void Funct(int *element)
{
    cout << element[0];
}

int main(int argc, char *argv[]) {


    int *elements = new int[10];

    elements[0] = 10;

    Funct(elements);

}

If we want to pass in a value that it's memory location can be edited, then we can do this:

void Funct(int &element)
{
    element = 50;
}

int main(int argc, char *argv[]) {

    int element = 0;
    cout << element << endl;
    Funct(element);
    cout << element << endl;
}

// "0" before calling Funct
// "50" after calling Funct

Hope this helps :) Anymore questions, feel free to ask!

phorce 131 Posting Whiz in Training Featured Poster

It should be like this:

'ano (image id)    aphote adteail exactar
   6                    image
   7                    image

'cid (comt id)     user1(userid)   ano (image id)   comments
    1                  10               6               first comment
    2                  9                6               second comments
    3                  10               7               nice image
    4                  1                7               yeah

Are you confused with the structure, or, the code?

In theory you would just select all the details from "comments" based on the "ano" value.

  SELECT * FROM comments WHERE ano='7' // selects all the comments where ano ID is 7
phorce 131 Posting Whiz in Training Featured Poster

@batman189 - I guess so. Give it a try =)

phorce 131 Posting Whiz in Training Featured Poster
//notice the addition of iomanip this gives us access to setw
// Make sure we initialize the array to known values NOT >=1 OR <= 25
// Zero is good for this case.
int array[5][5] = {{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0,0}};
// For each row
for (size_t crow = 0; crow < 5; crow++)
{
    // For each column
    for (size_t ccol = 0; ccol < 5; ccol++)
    {
        int i = getInput(); // getInput() will get the user input and return value as int.
        if (i < 1 || i > 25)
        {
            // Input range error!
        }
        else
        {
            // Look for input.
            for (size_t y = 0; y < crow; y++)
            {
                for (size_t x = 0; x < ccol; x++)
                {
                    if (array[y][x] == i)
                    {
                        // Duplicate input error.
                    }
                }
            }
        }
        // If no errors
        array[crow][ccol] = i;
    }
}

This will not compile. It's not in a function, nor is it in main.. How do you expect for it to compile? This is why you're getting that error.

phorce 131 Posting Whiz in Training Featured Poster

@LastMitch - You aren't from the UK are you? (Just asking because it's "Flooding" atm)!

phorce 131 Posting Whiz in Training Featured Poster

347 lines of code in two hours... wow.

phorce 131 Posting Whiz in Training Featured Poster

Hey, remember to change it to your directory ($cngDir) etc.. If this works, post what you did about the permissions and I'll see if I have some time to write an actual fully-developed script for it :)!

phorce 131 Posting Whiz in Training Featured Poster

I think this code will work:

<?php

        $filename = "../../tmp/crontask.txt";
        $output = shell_exec('crontab -l');
        $something = file_put_contents($filename, $output.'* * * * * NEW_CRON'.PHP_EOL);
        $cngDir = chdir('../../tmp/');
        $exe = exec('crontab crontask.txt');
        var_dump($exe);
 ?>

There is a lot of issues around permissions though, good luck! Let me know how you get on :)!

phorce 131 Posting Whiz in Training Featured Poster

@Goldfinch - Ok, I have a Linux box and I'll connect to it and try and write a script for you to do this. It might not pay off and someone could come up with an answer before me, but, hopefully, it will work.

Goldfinch commented: thank you, that's very kind +1
phorce 131 Posting Whiz in Training Featured Poster

I think the only way to do this is using cronjobs, since the PHP has to be executed. I don't think there is anyway to make a PHP script that runs itself.. I don't get what the purpose of this would be anyway?

phorce 131 Posting Whiz in Training Featured Poster

I don't get it?

What kind of cron job is it? Are you running a specific file on YOUR server that you want other people to be able to have on their server and execute YOUR FILE from their server?

phorce 131 Posting Whiz in Training Featured Poster

@mpc123 - What is '$txt'? I don't understand, it's probably your query that is the fault here, not returning any data.

phorce 131 Posting Whiz in Training Featured Poster

Insead of:

<h2><a href="' . $row['$txt2'] . '/' . $row['$txt2'] . '.php">' . $row['title'] . '</a></h2>
</div>

Try:

<h2><a href="' . $row['txt2'] . '/' . $row['txt2'] . '.php">' . $row['title'] . '</a></h2>
</div>

I don't understand the purpose of '$txt2' etc here, in this context.

phorce 131 Posting Whiz in Training Featured Poster

Why do you study? What can you possibly learn from people answering these questions, therefore, what is the point of this task?

My advice:

LOOK at Exercise 6 etc.. and LEARN!

phorce 131 Posting Whiz in Training Featured Poster

Ok, so I don't know if this is what you are looking for:

#include <iostream>

using namespace std;

template<typename Type>
class Events {

    public:

        virtual void add() {
            Type s;
            s.add();
        }
};

class Coord {

    public:

        void add()
        {
            cout << "Added Coord" << endl;
        }   
};

class Zone {

    public:

        void add()
        {
            cout << "Added Zone" << endl;
        }
};

int main(int argc, char *argv[]) {
    Events<Coord> coord;
    Events<Zone> zone;

    coord.add();
    zone.add();
}



// output:
    Added Coord
    Added Zone

Obviously, your return type would have to be different. I'm really tired so I can't think of another way to implement your question :(!

phorce 131 Posting Whiz in Training Featured Poster

"No matter how many books you read, there are certain things in this world that you never, never understand"

phorce 131 Posting Whiz in Training Featured Poster

@NardCake - No problem :) People for years still don't follow the rules ;)! Anyway, good luck with your project!

phorce 131 Posting Whiz in Training Featured Poster

I learnt to write beautiful equations, that, actually make sense to me..

Proud!!