Insensus 52 Junior Poster

Your openWithCURL function doesn't return anything.
I suppose you want

function openWithCURL($url){
 	$curl_handle=curl_init();
	curl_setopt($curl_handle,CURLOPT_URL, $url);
	$result = curl_exec($curl_handle);
	curl_close($curl_handle);
	return $result;
}
Insensus 52 Junior Poster

Well this functions.php file prints a new line at lines 7 to 9

?>

<?php

And you probably know that printing requires the headers to be sent so you can't change them anymore after printing.

Try removing these 3 lines.

Insensus 52 Junior Poster

Are you sure it failed?
When you're using exec like in your post, it won't output anything but only return the last line of the result of the given command.

If you want all the output supply an array as second argument to exec. This array will then be filled with each line of the output of the given command:

exec("PERL C:/Program Files/Zend/Apache2/htdocs/Scripts/test.pl", $result);
print_r($result);
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

How about this

$text = preg_replace('/(https{0,1}:\/\/([\w\-\.\/#?&=]*))/', '<span class="tweet_links_intext"><a href="$1" target="_blank">$2</a></span>', $text);
Insensus 52 Junior Poster

How about this.

$string_exp = "/^[A-Za-z\x80-\x95 .'-]+$/";
Insensus 52 Junior Poster

At line 7 you specify the variable $path1 but in the copy function on line 11 you use $path which is undefined.
This produces the error.

Insensus 52 Junior Poster

Use exec instead of system and specify an empty array as the 2nd variable. This will then be filled with all the lines output by the command.
http://www.php.net/manual/en/function.exec.php

$result = array();
exec('/usr/bin/whois 4.2.2.2', $result);

Now you have an array filled with all the lines, excluding trailing whitespace, of the output.
To print this with <br />'s just use

echo implode("<br />", $result);
Insensus 52 Junior Poster

You forgot a " on line 10

$id1 = implode("-", $id);

and $id isn't an array but a single value so you can't implode that (implode takes an array).

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

It's definitely possible with the GD library but from reading your question I feel like your expectations of the capabilities of the GD library are too big.

The GD library exists only for basic drawing functions, it will not check for you whether two lines are intersecting for instance.
I wouldn't know of any library for PHP that ís capable of doing such things for you and I wouldn't bother looking for one as finding it and getting it set-up right would take just as much time as coding by hand.


I suggest you think of your goal in an abstract way, completely disjunt from any programming tools. This way you should be able to come up with a set of rules or guidelines to which you want your image to adhere.
Once you have those rules you can come back to programming and thinking about how to implement your set of rules.

Hopefully you are willing to give this a shot and if you do but get stuck this forum will be glad to help you. :)

Insensus 52 Junior Poster

In your original code $rows wasn't null because of line 6:

$rows = array();

But good you fixed it yourself.

Insensus 52 Junior Poster

Just add

$rows[$k] = array();

in between lines 7 and 8.

Insensus 52 Junior Poster

Ok this will probably not solve it (I'm going to experiment with your code a bit later to find a solution) but there's at least one thing that's kind of odd.

You are looping the action of extracting something from the stream into prices with your overloaded operator>>, but your overloaded operator>> reads the given stream until it reaches the end.
So to my understanding your while loop will only execute once because after the first extraction you should be at the end of the stream.

As for a solution to your original problem, I haven't figured that out yet but maybe you could try skipping the copy algorithm and doing it with loops for now so you can output some more information on what's going on.

Insensus 52 Junior Poster

Maybe you would also like to post your operator>> because I'm not able to solve it like this.
Perhaps someone with actual coding skills might be able to, though, but to me it seems unlikely.

Insensus 52 Junior Poster

Are you perhaps including this file in another file?

What's on line 28 of /blam/login1.php?

Something I encountered a few days ago: Is your file perhaps saved as UTF-8 with BOM?

Insensus 52 Junior Poster

The closing double-quote for your MySQL query on line 39 is actually the wrong character.
It should be a " and you have a , so the string is never closed and eats the rest of your code.

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

It would help if you'd also post the error but a first suggestion would be to use <?php as starting tag instead of your <? on line 1.

Insensus 52 Junior Poster
vector<string> data;
vector<string>::iterator found = find(data.begin(), data.end(), "search");

int pos = found - data.begin();
Insensus 52 Junior Poster

Well I think my approach is only limited by the physical MySQL limits which probably results in more than enough room for items unless your game goes really big.
But then you'd probably get some real programmers to do the job for you, eh. :p

Insensus 52 Junior Poster

What do you mean by hard coding something into a table?

Insensus 52 Junior Poster

This is just a suggestion but maybe it'll be the key to you figuring it out.

Keep an 'items' table containing all the items in your game with a structure like:
id, type, upgrades, owner
Then you could just fetch all items with a certain type and a certain owner enabling multiples of one item upgradable seperately.

Insensus 52 Junior Poster

Change

$result = mysql_query("SELECT userid FROM user ORDER BY userid DESC LIMIT 0,1");

to

$result = mysql_query("SELECT userid FROM user ORDER BY userid DESC LIMIT 0,1") or die(mysql_error());

and you should see an SQL error.
If you can't solve the error, just post it back here.

Insensus 52 Junior Poster

Try taking one specific case of your query (choose a $period[$i] and $gpa[$i]) and run that query in phpmyadmin.
If it doesn't return anything there's obviously something wrong with your query.

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

Judging from the code you wrote I feel like you don't really know what you're doing.
So please make sure you understand my code instead of ignorantly copying it.

#include <iostream>
#include <time.h>

int main()
{
    time_t before = time(NULL);

    char input;
    std::cin >> input;

    //time_t after = time(NULL);
    //std::cout << difftime(after, before) << " seconds passed";
    std::cout << difftime(time(NULL), before) << " seconds passed";
}
Insensus 52 Junior Poster

Also, may I ask why you want to do this in the first place?

If it's for measuring the time the users takes to produce some input it's much easier to check the time before you ask for input, check it again right after input has been received and simply subtract the two.

Take a look at this if that is the case:
http://www.cplusplus.com/reference/clibrary/ctime/clock/
http://www.cplusplus.com/reference/clibrary/ctime/time/
http://www.cplusplus.com/reference/clibrary/ctime/difftime/

Insensus 52 Junior Poster

This error occurs because you are including a certain file multiple times and therefore trying to redefine the Figure class.

I've always been taught to wrap my class header files in the following format to prevent multiple definitions:

#ifndef __IN_HEADERNAME
#define __IN_HEADERNAME

  //
  // The original header goes here
  //
#endif
Insensus 52 Junior Poster
Insensus 52 Junior Poster

In the first file you set two variables with the username and password for MySQL.
When connecting however you don't use these variables but two constants.

Also, or die(mysql_error()) can be appended to any MySQL function, including mysql_connect.
If you would've done that, mysql_connect would throw the first error instead of mysql_select_db.

Insensus 52 Junior Poster

In line 91 you're trying to construct the member Patient which is a type not a member.
You did it right everywhere else though.

This, however, is not the only thing wrong with the 'Patient' construction in Billing.
You're constructing a Patient from a Person but you haven't specified a Patient constructor expecting a Person argument.

Insensus 52 Junior Poster

In connection.php you are connecting with MySQL functions but in Prepared_Statements.php you are trying to execute queries with the MySQLi functions.

Insensus 52 Junior Poster

Because 150.000 x 150.000 floats equals ~21GB of memory.
I don't think you have that much RAM in your computer.

Insensus 52 Junior Poster

I already mentioned above that ,if javascript is not a cool option ,then go for jquery.
Traffic control is must because otherwise it may reault to the server down.

Do you know that jQuery is actually a JavaScript framework and therefore if you switch off JavaScript you also switch of jQuery?
I guess you didn't.

Insensus 52 Junior Poster

If you have read this line above,you wouldn't have asked this ....
And about validations,it's better to use javascript or JQuery for this ,than using PHP because it must be done on client side otherwise it will just increase the load on your server.These are some of the basics that must be taken into considerations while programming.....
Hopefully it's clear...

Since we don't even know what his program is intended for I will take your comment as if you mean to apply it to every website that takes input from the user.

A simple counter-example would be a money booking site: What if someone disables JavaScript and inputs a value of -1000 to be booked from his account to someone else. Do you really think server load is what you should be worried about in that case?

Insensus 52 Junior Poster

If the link to the page is something.php?error=insertsomethinghere
then $_GET = insertsomethinghere

Header is explained by IIM and the errors are due to not checking whether the variables are set

isset($_GET['error'])

I only provided you with a basic outline of how you would program what you requested, I'm not here to do your work for you.

header("Location: form.php?error=$error");

This is to redirect the user to the same page..for more reference about header,click here...
And moreover...the code above is not required at all...
Just use javascript for the same....Click here to learn about different kinds of validation(These are called validations i.e., numeric input,or alha-numeric input etc)

If you read my earlier answer you wouldn't have mentioned JavaScript as it can be turned off and then where's your validation?

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

In short, this is what you do:

sign.php

$error = 0;
if(!is_numeric($val1))
	$error += 1;

if(!is_numeric($val2))
	$error += 2;

if($error != 0)
	header("Location: form.php?error=$error");

This sends the user back to the form and passes information about which field wasn't a numeral.
1 (01): The first is not a numeral
2 (10): The second is not a numeral
3 (11): Both are not a numeral
Note: Make sure there is NO output before the header function or you will get an error.

form.php

<form method="post" action="sign.php">
	<input type="text" name="first">
	<?php echo ($_GET['error'] & 1) ? "Invalid input!" : ""; ?>
	<select name="select">
	<option>+</option>
	<option>-</option>
	<option>x</option>
	<option>/</option>
	<option>%</option>
	<?php echo ($_GET['error'] & 2) ? "Invalid input!" : ""; ?>
	<input type="text" name="second">
	<input type="submit" name="submit" value="submit">
	</form>

Hope this is understandable.

Insensus 52 Junior Poster

Change line 11. from

$id = $_GET['id'];

to

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

In comes the bragging.

You reached 499 points, so you achieved position 324 of 111445 on the ranking list


You type 622 characters per minute
You have 121 correct words and
you have 0 wrong words

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

Instead of assuming there are people on this forum who can simulate your server in their heads, could you maybe post what it is that is actually going wrong? Any errors?

Insensus 52 Junior Poster

When a PHP script is done executing all non-persistent connections will be closed.
Non-persistent connections are made with the _connect database functions so as long as you stick to that, there's nothing to worry about.

Insensus 52 Junior Poster

Answering that question would be easier if you could state what it is exactly you're trying to achieve.
Saves us from trying to figure it out through your code.

Insensus 52 Junior Poster

If you want someone to look at your source code, why not post it in your topic to begin with?
It's why they invented the code-tag.

Insensus 52 Junior Poster

The / is escaped because it signifies the end (or start) of the pattern.
Only pattern modifiers can follow after that.

And there is no difference between those two.

Insensus 52 Junior Poster
$regex = '/^[0-9]{5,}\/[a-zA-Z]\.[0-9]{2,}$/';
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