I'm actually not sure why it needs the question mark (?) at the end, when I didn't include it, I kept getting a blank page with the message "No input file specified."

I'm using a code snippet from the Invision Power Board forum software on my own site to, sort of, connect the two. I have a "member bar" that I wanna put on every page in my website that has a login link, profile link, etc. I've already done this, the only problem is that on the pages I want to implement it on, I have to put a ? after the ".php". So I need a mod_rewrite condition that turns

http://www.mysite.com/index.php into http://www.mysite.com/index.php?

http://www.mysite.com/html/about.php into http://www.mysite.com/html/about.php?

I know this is probably very simple, but I've tried to learn regular expressions and it gives me a headache every time I try haha.

Also, an aside question: for the index page, instead of doing http://www.mysite.com/index.php?, would http://www.mysite.com/? work as well?

I'm assuming that you are querying your database and looping through the recordset with a while() loop. Within your while() loop, you wanna start building a string, which will be your final URL. So you should start with something like this:

    $link = mysql_connect(/*arguments here*/);

    $query = sprintf("select * from table");

    $result = mysql_query($query, $link);

    $final_url = "http://www.mysite.com/result.php?loggedin=true&links=";

    if ($result) {
      while($row = mysql_fetch_array($result)) {
        // do something with the $row
      }

    }
    else {
      echo mysql_error();
    }

So you have the beginning of your url, as $final_url, and then you just start concatenating the table values to it, with your _newline_ string added at the end of the loop. So I think you'll wanna end up with something like this:

    $link = mysql_connect(/*arguments here*/);

    $query = sprintf("select * from table");

    $result = mysql_query($query, $link);

    $final_url = "http://www.mysite.com/result.php?loggedin=true&links=";

    if ($result) {
      while($row = mysql_fetch_array($result)) {
        $final_url .= $row['Name'] . "-" . $row['Times'];
        $final_url .= "_newline_";
      }

    }
    else {
      echo mysql_error();
    }

    header("Location: $final_url");

_newline_ will print after the last record in the URL, but that can be fixed, or left there, I don't think it's too big of a deal.

In theory, this should work, I hope :)

joshl_1995 commented: Thank you so much for the help. +0

[QUOTE=gerard4143;1418940]If your using GNU's compiler then the compile should be

g++ source.cpp -o executable_name

The errors your receiving indicate that you have two main functions...GNU reduces the main function to _start.[/QUOTE]

Well I have something called a Makefile that puts everything together:

[CODE]
train: train.o stree.o
g++ -Wall -g -o train train.o stree.o

train.o: train.cpp stree.h
g++ -Wall -g -c train.cpp

stree.o: stree.cpp stree.h
g++ -Wall -g -c stree.cpp

clean:
rm -f train train.exe stree.o train.o
[/CODE]

and this is supposed to generate the .exe as train.exe. So I just assume all I need to do is type "g++ train".
And as far as having two mains, I just checked, and I'm pretty sure I only have one :/ it compiles okay, and runs okay, which wouldn't make sense if I had two mains. Here is the file with main() in it:
[CODE]

include <iostream>
include <string>
include <stdlib.h>
include "stree.h"

using namespace std;

int main() {
string command, city1, city2;
Stree stree;

while (cin >> command) {
    if (command == "insert")
    {
        cin >> city1;
        cin >> city2;
        stree.insert(city1, city2);
    }
    if (command == "remove")
    {
        cin >> city1;
        stree.remove(city1);
    }
    if (command == "print")
    {
        cin >> city1;
        stree.print(city1);
    }
    if (command == "distance")
    {
        cin >> city1;
        cin >> city2;
        stree.distance(city1, city2);
    }
    }
return 0;

}
[/CODE]

[QUOTE=daviddoria;1418512]You should step through the code with a debugger and determine exactly which line the segfault happens on. This will give you (and us) a better starting point.[/QUOTE]

Well I would, except I get some weird errors. I use g++, so I go to type in "g++ train", train being the program name, and i get a bunch of mumbo-jumbo:

[ICODE]
train: In function _start': (.text+0x0): multiple definition of_start'
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crt1.o:(.text+0x0): first defined here
train:(.rodata+0x0): multiple definition of _fp_hw' /usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crt1.o:(.rodata+0x0): first defined here train: In function_fini':
/glibc-tmp-b75955b10861dacaae44bdced9fc4b9c/glibc-2.7/build-glibc-2.7/csu/crti.S:41: multiple definition of _fini' /usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crti.o:/glibc-tmp-b75955b10861dacaae44bdced9fc4b9c/glibc-2.7/build-glibc-2.7/csu/crti.S:41: first defined here train:(.rodata+0x4): multiple definition of_IO_stdin_used'
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crt1.o:(.rodata.cst4+0x0): first defined here
train: In function __data_start': (.data+0x0): multiple definition ofdata_start'
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crt1.o:(.data+0x0): first defined here
train: In function __data_start': (.data+0x4): multiple definition of
dso_handle'
/usr/lib/gcc/i486-slackware-linux/4.2.4/crtbegin.o:(.data+0x0): first defined here
train: In function _init': /glibc-tmp-b75955b10861dacaae44bdced9fc4b9c/glibc-2.7/build-glibc-2.7/csu/crti.S:15: multiple definition of_init'
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../crti.o:/glibc-tmp-b75955b10861dacaae44bdced9fc4b9c/glibc-2.7/build-glibc-2.7/csu/crti.S:15: first defined here
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../i486-slackware-linux/bin/ld: error in train(.eh_frame); no .eh_frame_hdr table will be created.
collect2: ld returned 1 exit status
[/ICODE]

Hi everyone,

So I have a binary tree class, Stree, that holds names of cities and pointers to other cities. Running the program and typing "insert Memphis Atlanta" inserts a node with Memphis, and inserts a node with Atlanta as Memphis's left child. Typing "insert Memphis Tampa" inserts a node with Tampa as Memphis's right child. Typing "insert" with two cities not already in the tree should generate an error, but when I try it, i get a seg fault.

The insert function runs a recursive function, searchInsert, that finds the city and sets a pointer to that city, target:
[CODE]
void Stree::searchInsert(string city1, bool &found, Node& target, Node root) {
//base case
if (root != NULL) {
searchInsert(city1, found, target, root->m_left);
if (root->city == city1) {
target = root;
found = true;
cout << "found city " << city1 << " at (" << root << ")" << endl;
}
searchInsert(city1, found, target, root->m_right);
}
}
[/CODE]

Coming out of the recursion, insert proceeds to insert the new city somewhere:
[CODE]
//if the city has no current destinations
if (target->m_left == NULL) {
target->m_left = new Node(city2);
cout << "inserted " << city2 << " at (" << target->m_left << ")" << endl;
}
//if the city has 1 destination
else if (target->m_right == NULL) {
target->m_right = new Node(city2);
cout << "inserted " << city2 << " at (" << target->m_right << ")" << endl;
}
//if the city already has 2 destinations
else {
cerr << "Error: ...

[QUOTE=Fbody;1416184]It's because you are declaring the class [B]after[/B] you are trying to use it. As a result, the compiler doesn't know anything about the Node class yet. Rearrange your class' declaration so that Node is declared [B]before[/B] you use it.

It's just like anything else, you can't use it until you tell the compiler what it is.[/QUOTE]

Well that fixed it. Thanks! :)

Hi everyone,

So I tried making my program here, and I got an error that I can't figure out. I have a class for a Binary Tree, "Stree", with a few methods defined publicly, and a "Node" class defined privately, within "Stree". These methods use "Nodes" as parameters. Now when my main cpp file calls in stree.h, on each line that contains a method, it says "Node has not been declared". The errors are below:

g++ -Wall -g -c train.cpp
In file included from train.cpp:8:
stree.h:22: error: 'Node' has not been declared
stree.h:22: error: 'Node' has not been declared
stree.h:23: error: 'Node' has not been declared
stree.h:23: error: 'Node' has not been declared
stree.h:25: error: 'Node' has not been declared
stree.h:25: error: 'Node' has not been declared
stree.h:26: error: 'Node' has not been declared
stree.h:27: error: 'Node' has not been declared

Here is the code for stree.h:
[CODE]

ifndef STREE_H
define STREE_H
include <string>

using namespace std;

class Stree
{
public:
Stree();
~Stree();
void remove(string);
void insert(string, string);
void print(string);
bool isEmpty();
void distance(string, string);

    void searchInsert(string, string, bool, Node*, Node*);
    void searchPrint(string, Node*, bool, Node*);
    //void searchRemove(string, Node*, Node*);
    void searchStart(string, Node*, Node*);
    void searchDistance(string, int, int, Node*);
    void removeSubs(Node*);
private:
    class Node
    {
        public:
    Node();
            Node(string);
        string city;
            Node *m_left;
        Node *m_right;
    };
    Node *m_head;

};

endif

[/CODE]

Could somebody tell me why it doesn't see "Node" as declared, even when it's in the same class as the methods?
Thanks!

Hey everyone,

So in a few of my programs, when I have the user enter input, which then gets stored in a list, there seems to be some error. I use a while loop to allow for continuous input, like
[CODE]
while (!cin.eof()) {
cin >> value;
list.insert(value);
}
[/CODE]
so that when they hit CTRL-D, the loop terminates and the list has all of its values.

When someone enters the following values: 1 2 3 4 5
My function prints the values backwards, so when I print the list, I get: 5 5 4 3 2 1

Could someone help me on this? I would greatly appreciate it :)
Here is my code:
[CODE]
list.h

ifndef LIST_H
define LIST_H

class List
{
public:
List();
~List();
void insert(int value);
void print();
void insert_at_end();
int size();
private:
class Node
{
public:
Node(int value, Node next)
{m_value = value; m_next = next;}
int m_value;
Node
m_next;
};
Node *m_head;

    int iSize;

};

endif

[/CODE]
[CODE]
list.cpp

include <iostream>

using namespace std;

include "list.h"

List::List()
{
m_head = NULL;
iSize = 0;
}
List::~List()
{
// cout << "List::~List() was called" << endl;

Node *ptr = m_head;
while (ptr != NULL)
{
    Node *temp;

    temp = ptr;
    ptr = ptr->m_next;
    delete temp;
}

}

void List::insert(int value)
{
m_head = new Node(value, m_head);
iSize++;
}

void List::print()
{
Node *ptr = m_head;
while (ptr != NULL)
{
cout << ptr->m_value << endl;

    ptr = ptr->m_next;
}

}

int List::size() {
return iSize;
} ...