phorce 131

Have you made sure that the file is being included?

phorce 131

You have not declared the method prototype correctly in your class.

static std::map<std::pair<u32, u32>, CreateSessInfo> m_mSessionId2CCRNum2DefaultBearerId;

Shoudl be:

static std::map<std::pair<u32, u32>, CreateSessInfo> m_mSessionId2CCRNum2DefaultBearerId()
    // Logic here

    return map; 


Then you can access it as:


Here, I did a similar example: no logic is there, but, I hope it gives you an understanding of where you went wrong.


Just realised what you were attempting, so, @NathanOliver answer is more accurate.

rubberman commented: Good - give credit where credit is due! :-) +12

phorce 131

First off, your question is quite confusing. I can't gather what it is what you're trying to do, let me try with a different example, see if it makes sense to what I think they are wanting you to do.

Let's assume that you have a Person, each person therefore, has a: Name, age, nationality.. Defined below:

class Person

            // default

        Person(std::string name, int age, std::string nation)
            this->theName = name;
            this->theNation = nation;
            this->age = age;


        std::string theName; 
        std::string theNation;
        int age;

So, far we have created the base class. We now introduce inheritence, let's say that you now have a "Student", well a "Student" shares all the characteristics as a person and therefore you can inherit from this:

class Student : public Person {


       Student() { } // default 

       Student(std::string theName, int theAge, std::string nation, int num)
          : Person(theName, theAge, nation)
          // now we can do this:
          this->theNum = num;



       int theNum;


Therefore, when we are creating objects, we no longer have to look at the "Person" class.. We can just do the following:

Student s("Phorce", 10, "British", "00001");

If we had a method in the "Person" called getName we could do the following:

std::string returnName()
    return this->theName;

We can access it by std::cout << s.returnName() note how we did not define this in the Student class?

This can relate to your problem, you can try and figure it out. I'm not too ...

phorce 131

Because not many people have access to this library, please could you specify some expected input and outputs?

Also, what is the data type of MInput?

phorce 131

I believe, from what I can see is that the validation requires a . followed by between two or three characters (\.[a-z]{2,3}) so email addresses like: would valid true, whereas email addresses containing a . with only one character, would throw up an error.

There are some pre-built functions: which would filter this information for you.

Hope this answers your question, slightly.

phorce 131

What do you mean by "Pin"?

phorce 131


If you're happy for me to do so. I don't mind looking over your database, to see where you went wrong. Also, it might be a good idea to take a look at your script. If you would allow access to the server for around half an hour, that would be great. You can make a seperate user account up if you don't want the admin details. Please post back; if you're sending details, make sure they are in a PM. I am around for most of the night tonight (UK time) so I'll take a look.

phorce 131

Have not coded PHP in so long..


ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);

$con = mysql_connect("localhost","372***", "********");
if (!$con)
  die('NEIN!' . mysql_error());
//Connect to DB
//(Possible offender below)
$res = mysql_query("SHOW DATABASES");

while ($row = mysql_fetch_assoc($res)) {
    echo $row['372***'] . "\n";
mysql_select_db(372***, $con)
or die("Lost");

echo "<table border='1'>
<th>Employee Name</th>
<th>Employee Address</th>

$result = mysql_query("SELECT * FROM b8_14160309_simple*** LIMIT 1") or die (mysql_error());

$row = mysql_fetch_array($result); // I think you commented out the $result


This should now not display any errors. Post back

phorce 131

Right, ok. mhm. This is really weird.

First off, attempt to do the following:

// After $result, comment the rest put this
$row = mysql_fetch_row($result);

var_dump($row[0]); // What does this give?

phorce 131

Please post, what the field names actually say?

phorce 131

I can barely see that, have another one? I'm pretty sure it says 'emp_names' and not 'emp_name' am I right?

phorce 131

Inside your table,

Are the rows emp_name / emp_address or are they named something else? Please print screen the table

phorce 131

Can you post some more code? I.e. where do you make a connection to the database? If you post back within the next 15 mins, I'll take a look - Or just write one for you to test myself!

phorce 131

Its saying there are no records inside the are there records in the table? Or the query returns NULL I would check the table. Try and screen print it to verify there are records in the table.


phorce 131


$result = mysql_query("SELECT * FROM b8_14160309_simpleDB3 LIMIT 1") or die ("Something is wrong here", mysql_error());

OR try:

   echo "Theres something wrong here";

phorce 131

Could you not do something like:

$action = $_GET['action']; // assume that action.php?action=edit

switch ($action) {

        case "Edit":
            echo "EDIT STUFF HERE";

        case "update":

            echo "Update here";

        echo "Default";

phorce 131

On a side note: The link that @iwavetostars mentioned is a really good read; I actually want that book as a reference.

phorce 131

Pick a project that is interesting to you. I.e. At my University, I've just been assigned to do some research based work with the Leap Motion sensors (I don't know if you've come across those) and instead of using C++ (What I am familiar with) I've chosen to use Python. Have I gone and research and read through 100's of books and documentation regarding it? No. I've sat down, used my brain and realised the things that I picked up in C++ are very similar to those in Python and Googled what I needed.

phorce 131

Let me just ask you: Is there really any point in sitting down and learning Python, when you already know C/C++? Let's look at this logically, from gaining knowlege in C/C++ you should have an understanding of syntax and how programming logic works. So, would you benefit from sitting down and actually reading: if x is 10: blah blah - Probably not! Learning the basic structure, is ok. But from there, you should pick a project to do and start from there - Thus meaning you gain quick knowlege and your understanding improves.

phorce 131

Why do you want to do this? I don't get the point??

phorce 131

Just a very quick question.. Why would you need/want to convert this to an .exe - Why not give them the source code?

Have you tried: ?

phorce 131

Would it not just be easier to use:

$email_a = '';
$email_b = 'bogus';

if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
    echo "This ($email_a) email address is considered valid.";

PHP already has this built-in!!

But, what you have used is a function, to call this function you would use:

   die("you have not used a correct email address");

// or 

$email = $_POST['email'];
if(!validate_email($email)) {
   die("you have not used a correct email address");

Hope this helps :)

phorce 131

@cam - No, this has to be outside of the class definition.
You're delcaring a static reference, the class has to know where it is initialised.

phorce 131

Like @prit said, are you sure you have the right port? Are you sure this port is open? I Persume that you're using local machines (i.e. not a server) for this?

phorce 131

It is all well and good to concentrate on "coding" type security preventions, but, what are you doing in terms of server-side? I.e. "Hackers" or people who want to generally cause a havoc to your website might not generally go down the route of XSS or trying to find vunerabilities inside your code.

What if, for example they managed to get onto your server? Since, all your files, and mysql databases are stored on your server - They don't even need to look for vunerabilities within your code.

What if, they managed to DDoS/DoS your site? Corrupt your database files etc.. I wouldn't just look at coding techniques in terms of security - Make sure your server is 100% secure.


phorce 131

C++ is a massive language, that requires years and years of experties in order to do the smallest of tasks. Let me give you a simple example: Let's say I want to develop an algorithm for an FFT (Fast Fourier Transform) pretty common in signal processing.

In Python I would:

from cmath import exp, pi

def fft(x):
    N = len(x)
    if N <= 1: return x
    even = fft(x[0::2])
    odd =  fft(x[1::2])
    return [even[k] + exp(-2j*pi*k/N)*odd[k] for k in xrange(N/2)] + \
           [even[k] - exp(-2j*pi*k/N)*odd[k] for k in xrange(N/2)]

print fft([1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0])

Whereas in C++

#include <complex>
#include <iostream>
#include <valarray>

const double PI = 3.141592653589793238460;

typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

// Cooley–Tukey FFT (in-place)
void fft(CArray& x)
    const size_t N = x.size();
    if (N <= 1) return;

    // divide
    CArray even = x[std::slice(0, N/2, 2)];
    CArray  odd = x[std::slice(1, N/2, 2)];

    // conquer

    // combine
    for (size_t k = 0; k < N/2; ++k)
        Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;

// inverse fft (in-place)
void ifft(CArray& x)
    // conjugate the complex numbers
    x = x.apply(std::conj);

    // forward fft
    fft( x );

    // conjugate the complex numbers again
    x = x.apply(std::conj);

    // scale the numbers
    x /= x.size();

int main()
    const Complex test[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
    CArray data(test, ...

phorce 131

This is not going to make much of an impact but: I personally don't think books of programming are a good option. (Ok, in terms of software methodologies: Agile, sofware concents such as lifecycles) but in terms of coding I do not.. Here's why:

1) You learn THEIR coding styles, and THEIR coding techniques on how to do something. Sure, as a reference it's great but you tend to pick up their habbits and their habbits might not be the best way to go.

2) Books become out-dated, very, very quickly. You might be reading references to something that has been published 5 years ago and therefore the particular method becomes depciated. This means that you'll get fustrated with code. For example: Let's say I wanted to learn PHP, and, I picked up a copy of Larry Ullmans book.. It has an example that clearly states that mysql_* is the best option to use.. I then learn that mysql_* functions are now depeciated, so, i've written his solution and yet again, I'm on Google, I'm on forums only to learn that PDO/MYSQLI_* are the new standards.. Do I purchase more books?

If you take forum communities, websites and online referencing to many many things out there in terms of physical programming then you get to pick up multiple techniques. Usually you will see a problem and different members also contribute with their own standards. Languages such as C++ have an array of methods in which you can solve particular problems ...

phorce 131

@Anima Gives you some great recommendations, with regards to Python. Python is easy to learn and is becoming a lot more popular in commercial sense. Some programmers that have been developing for many, many years are taking up Python now because it offers such a high commercial gain; even if the job isn't in Python.

phorce 131

@down-voter - Please could you explain why this post has been downvoted?

phorce 131

Because I'm learning Python at the moment, I'm going to give you a start.. Something like this:

import string
import random 

def FlipCoin(): 

    coin = ['heads', 'tails'];

    return random.choice(coin);

def main():

    heads = 0;
    tails = 0;

    for x in range(0, 100):
        print FlipCoin();


I'm sure that you can finish this off. :)