Insensus 52 Junior Poster

I've placed an additional subpattern in the matching pattern which matches only the part of the link after the http://
It basically matches like this: ([url]http://(www.website.com[/url])) which sets the following back-references for the replacement

$1 = [url]http://www.website.com[/url]
$2 = [url]www.website.com[/url]
Cap'nKirk commented: spot on, thx +3
Insensus 52 Junior Poster

By default PCRE regex patterns in PHP don't match newlines with . and maybe POSIX patterns do, I'm not sure.
But since you probably have newlines in your template file, I think changing the pattern to the following should solve your issues:

$header = preg_replace("/".$bodytag."(.*)/is", '', $temp);
$footer = preg_replace("/(.*)".$bodytag."/is", '', $temp);

Also there is probably an easier way to do this, without the need for regex, assuming I have the right idea of how your template file works.

$bodypos = strpos($temp, $bodytag);                   // Find the position of the %BODY%
$header = substr($temp, 0, $bodypos);                 // The length of the header is the same as the position of the %BODY%
$footer = substr($temp, $bodypos + strlen($bodytag)); // And the start of the footer is the position of the %BODY% plus it's length
Insensus 52 Junior Poster

A for loop is set up as follows:

for ( inital step; condition to continue; step to execute after every loop )

So your second for loop, the one supposed to decrease, has the first two arguments mixed up.
This turns it into an infinite loop because $row2[0] = 15 will evaluate as if your condition said 15 which is always equivalent to true thus your loop never ends.
Also the 'fake' condition in your first argument would've produced an infinite loop since you want to terminate when something that is decreasing exceeds a certain value.

My guess at what you're looking for would be:

for ($row2[0] = 15; $row2[0] >= $rownum3; $row2[0]--)
karthik_ppts commented: helpful post +6
Insensus 52 Junior Poster

This happens because you can't access an array's members directly inside a double-quoted string.

You can either try like this

study_period='{$period[$i]}'

that might work, I'm not sure.

Or just do it like this

study_period='".$period[$i]."'"

which will work for sure.

Insensus 52 Junior Poster

That is exactly what my code does.

If you however don't want the form to submit at all you obviously shouldn't use PHP to do the checking but JavaScript.
In that case, however, remember that JavaScript can be switched off and you'd still have to use PHP to check for numerals which means using my code.

Still I think it's very wise of you to say that I didn't understand your question when you don't understand the answer.


I'll try to break my code down to your level by providing an example.

The user enters:

first: a
second: b

My code on sign.php will do this:

$error = 0;
Is first a number? - No => $error += 1 //So $error is now 1
Is second a number? - No => $error += 2 //So $error is now 3
Is $error non-zero? - Yes => Send the browser back to the form but pass the error number $error along

On the form my code now produces the following:

//$_GET['error'] = 3;
Is the first bit set in $_GET['error']? - Yes => Print 'Invalid input!' after the first input box
Is the second bit set in $_GET['error']? - Yes => Print 'Invalid input!' after the second input box

Considering your response you probably don't know that 1 is written as 01 in binary, 2 as 10 and 3 as 11 which we use here to transfer the information about the input back to the …

Xufyan commented: <3 ! Xufyan +3
Insensus 52 Junior Poster

Change line 11. from

$id = $_GET['id'];

to

$id = $_POST['id'];
karthik_ppts commented: hmmm +5
Insensus 52 Junior Poster

mysql_query returns a boolean false when the query fails so if you fix the query (to which the second error applies) the first will disappear also.

As for the second error: it's probably something to do with $UserID as the rest looks alright.
Maybe you could show us what the query looks like when it's executed? (echo $SQL)

Insensus 52 Junior Poster

Check out this function http://php.net/urlencode

Insensus 52 Junior Poster

The | isn't the string concatenation operator in PHP.
It's the bitwise OR operator, that's why you get the randomness.

Use

$emailSubject = 'Work Order: ' . $_POST['company'];
karthik_ppts commented: yes +5
Insensus 52 Junior Poster
bool pComp(int* a, int* b) { return *a < *b; }

vector<int*> pVec;
std::sort(pVec.begin(),pVec.end(), pComp);
Jsplinter commented: thank you +2
Insensus 52 Junior Poster

Are you serious?

Insensus 52 Junior Poster

What you have now is:

10 => 0
11 => 1

I suspect you want:

9 => 0
10 => 1

Which I'd do like:

$ASoliderPercent = floor($attackerSoldiers/10);
Insensus 52 Junior Poster
$rands = range(300, 10000);
shuffle($rands);

$random1 = array_pop($rands);
$random2 = array_pop($rands);
$random3 = array_pop($rands);
...
diafol commented: I like that :) +13
Insensus 52 Junior Poster

That's because HTML automatically reduces subsequent horizontal spacing to one space only.
If you want more you'll have to use the &nbsp; HTML-entity.

Insensus 52 Junior Poster

DeIntegro,

The reason you're only getting one row is because you're querying for one row. You need to query an array of rows.

$row = mysql_fetch_[b]row[/b]($result);

should be

$row = mysql_fetch_[b]array[/b]($result);

This is not true.
Both functions fetch one row from the query and store it in an array.
The only difference between them is how the array in which the row is stored is constructed:
mysql_fetch_row returns an enumerated array (eg. {[0] => a, [1] => b})
mysql_fetch_assoc returns an associative array (eg. {[x] => a, [y] => b})
mysql_fetch_array returns an array containing both of these (eg. {[0] => a, [x] => a, [1] => b, [y] => b}).

To get multiple rows from your query simply call mysql_fetch_array/assoc/row again and again until it returns false:

while($row = mysql_fetch_array($sql)){
    // Do something with the row
}
diafol commented: Nice explanation +13
Insensus 52 Junior Poster

Yes the line numbering is correct so the question is, why did you put a --> at the end of line 36? (And also 37, 38, 39)

Maybe you were trying to comment out those lines? Note that what you've placed are only HTML comments and since PHP executes before anything is done with the HTML, PHP sees a --> in it's code and that doesn't really make sense.

Insensus 52 Junior Poster

If you look at this page http://www.cplusplus.com/reference/algorithm/find/ you'll see that find() requires the == operator to be defined on your class, and it's not.

Something like this probably:

bool A :: operator ==(const A &t) const
{
	return ((x == t.x) && (strcmp(name, t.name) == 0));
}

On a side note, why did you define putData() as a member-function of A even though it doesn't do anything with the A it's called from?

And why does getData() take an argument which it doesn't use?

Insensus 52 Junior Poster

The dereference (*) operator has lower priority than the member (.) operator so you need to add brackets:

(*str).length()
Insensus 52 Junior Poster

What rubberman said is actually wrong.
In a multiset an element's key is itself so you need to specify only one type.

Now I'll try to explain to you why you get this error:
When you use a function that's defined from a template, your compiler will at compile-time create an actual function from your template definition for the required type.
Now because your instantiation happens with an int the multiset inside your function will be a multiset<int> and therefore multiset<int>::insert(const string&) will generate an error even though you will be preventing that statement from ever happening at run-time. Your compiler can't know that and therefore can't compile.

You COULD do this with templates, but then you'd need to create a new specialization for every different type of variable which is pretty much the same amount of work as just making three different functions.

Insensus 52 Junior Poster
long2ip();

:P

dalip_007 commented: excellent +2