Will Gresham commented: Brilliant link +1
Salem commented: Makes you wonder what problems 1 to 4 were, since this is apparently #5 +29
Oh wow, how did I miss that part? Sorry 'bout that one.
I would assume you know how to create forms already. Have the login button send an AJAX request (by calling some JS in the onClick event handler) to a separate PHP login script (passing the username and password) which checks the database, updates session variables, etc. This file can respond with some sort of success/failure code. Your AJAX script can read this value and either refresh the page (if login succeeded) or give the user an error (if it failed).
Honestly, you have been given the proper solutions. Sending (and therefore, reading) your forms with the POST method sends variables through the headers sent. For this purpose, however, I would recommend SESSIONs as people could potentially look at the header information. SESSION variables are contained solely on the server (aside from the associated client COOKIE which only contains the SESSION ID).
For the sake of an installation script, you should probably exit()
after redirecting. As to why this isn't happening is beyond me.
Just out of curiosity, does this mean that scripts are loaded into the PHP interpreter in their entirety, so that anything can happen to the file during execution and the its execution will be unaffected?
Take a look at ShellExecute
Edit: I misunderstood ArkM's post, I thought it was advising against the use of system() (as is usually the case). I suppose in this case, it would be okay?
You never initialized the value of x. When is the loop supposed to stop? Stopping at the null character '\0' might be a good idea... Also, you can't have both the loop and and function keeping track of top. You can use a while loop to go through the string and push
will modify top for you.
It seems you read all the posts about the problem, but none about the solutions. Computer specs are not the issue. Care to post which compiler you use?
What about this:
double n = 123.456;
int x = (int)(n + .5);
If the decimal portion is .5 or greater, the addition will carry it up to the next higher integer. I would think it would be quite a bit faster.
A better idea, why not just include edge checking code when you count the neighbors? An if statement or two with a simple little condition(s). That way you don't have to start your array at index '1', therefore making it much simpler (especially to someone reading your code, ie. teacher).
Take a look at an ascii chart to find out how you will tell if it is capital or not, and how to change the character. Note that you can treat chars like numbers.
The loop does whatever you tell it to. The way you wrote it, it goes through the input by a single character.
Basically, for each character, check if it is the first character in the line or if it has a space before it. If it does, capitalize it. And AncientDragon is right, it would make more sense to read the entire line in at once and process it within a variable.
I do not know of any standard function that would perform this task. You could always fix your own code though. Do you understand what you wrote?
int main (int argc, char *argv[], char **env)
{
char c, lastc = ' ' ;
c = cin.get();
do {
cout.put(c);
c = cin.get();
if (lastc)
{
c = toupper(c);
}
} while ( !cin.eof());
return EXIT_SUCCESS;
}
Your algorithm:
1. Get one character, put in 'c'
2. Output 'c' (no check for capitalization? hmm...)
3. Get one character, put in 'c'
4. If 'lastc' (it will always be a space, which is 32, which will evaluate to true. every single time...)
5. Go back to step 2 until there are no more characters to read
Ignoring the task of initialization (for now), you would access it like so: numberLists[row][col];
. To get the number 4 for example, the code would be numberLists[0][1];
(1st row, 2nd column).
My best guess, without seeing this in context, is that it is to define a two-dimensional array. It is very unlikely that you will see pointers to single ints (unless you're trying to pass them by reference the 'C' way). In this case, you have one large array with lots of pointers in it. Each one of the "smaller" pointers actually refers to another array. That way you have two dimensions represented.
I was just about to suggest that, but you beat me to it :P See How do I flush the input stream? for a slightly better solution (will ignore more than just 256 characters)
While this is not critical in any way, you should note that the large outputting section at the bottom won't actually print any of the embedded quotes. In this line:
cout<<"Each ""generation"" eight babies are born with variations." << endl;
You are actually writing separated strings but the compiler is concatenating them for you, so no error is given. You want something like this:
cout<<"Each \"generation\" eight babies are born with variations." << endl;
The backslash make it into a special control character.
I'm impressed at the use of genetic programming; I'm doing some work with it as well. As for use of objects, anything more complicated could like use objects to store genes and whatnot, instead of using strings like you did in this example.
Instead of making us download your .zip file, post some sample lines of the .dat file, including ones that do work and ones that don't (ie. Truman).
For me, this problem only occurred when I entered more than 100 characters. Try adding this:
if(cin.fail())
cin.ignore(256, '\n');
just after you read the filename.
Other things wrong with your code:
-Don't use system commands. Just don't.
-You are letting the user input 20,000 characters into a 2,000 character buffer. Could be a typo, but fix it anyway.
When AncientDragon wrote Code[h] != 0
, his code was correct. Yours isn't. Why? AncientDragon's codes
array was a string literal, which automatically has a '\0' or 0 value at the end. Your array does not. Either append a '\0' element or change your codes array to look like AncientDragon's.
Replace "persons.txt" with a string variable containing the filename you have gotten from the user. I hope you know how to get user input...
By the way, code tags should look like this:
[code=c++] ...your code... [/code]
The fact that you tried is appreciated, however :P
I hope that you at least recognize the importance of the programming concepts rather than memorizing the text of the book, like your neurotic teacher seems to think.
Be careful to note that in math.h, these functions expect the angle in radians, not degrees.
Well, does the Clients table have a field named propID?
Help you how? This book starts at the very beginning so if you don't understand it you may be in trouble...
You are adding two boundaries for each file. Move your second boundary addition outside of the loop.
I can't see how this would work even with one file; there are no PHP tags! Furthermore, can you describe what doesn't work when you input two files? Actual PHP errors, or it doesn't add one/both to the message?
Are you familiar with databases? Databases contain tables, tables contain records, or "rows". Each row has multiple "columns" of data. I am saying that each record should have information stored for each field I mentioned. Maybe you should find a good MySQL tutorial.
Edit your post and put [code=c++] before your code and [/code] after it. Or, if you use the advanced editor, there is a button that will do it for you.
Multiplication is repetitive addition. Use loops.
There are millions/billions/whatever of IP addresses that make up the internet. The standard HTTP port is 80.
1. PATIENCE. Yours is not the only post on DaniWeb.
2. Do not PM for help. It wont get you any more attention. If anything, it will make people ignore you.
3. Copy (ctrl+c) your entire code, then paste (ctrl+v) it inside code tags.
Each mysql record is one message, contains the message body, title, time etc. and the users it is to and from. The user fields would optimally be references to the ids inside a user table. You can then perform queries to get all the message to a user (inbox), all messages from a user (sentbox), and whatever else you desire.
Are you programming console C++ or WinAPI/MFC? It makes a big difference in how we would help you.
Well since you bought it from microsoft, don't they owe you a working product? (just joking!). At any rate you could always ask them.
Try creating a new project with the same code. If it works, great. You can just ditch the broken one.
when i include html tags the redirect doesnt work
Very true. You can't send header information (thats where you're redirecting) after outputting anything. All you could do is put your meta tags after the redirection code. That would be useless though, because your program will never get to this point.
So you want to provide a common portal to all three sites within your own? Use Sockets to connect to their servers, get the page you want (while sending the info they require), and process it for the info you want.
If you have been given an assignment, that would insinuate that you have been to class. Have you payed attention at all? Taken any notes? Instructors don't often make you do things they have never instructed you on.
The problem practically gives away what you need to do. Have you been to class at all? Taken any notes? All you need is a simple (very simple) loop, a few counters, and the basic math knowledge to perform squares and cubes. Oh, and some form of getting input (also quite simple!).
@Blocker: You keep saying it doesn't run. What does that mean exactly? PHP errors? Or does it always disable the button? Does it never disable the button? It helps to be as specific as possible.
For this thread I hope a useful application for GOTO has become clear.
Yes, one use came to mind immediately. It is great for making messy code! The knowledge that it is a poor practice has been know widespread for decades. So why is your case is an exception?
Since you are just using ShellExecute (not ShellExecuteEx) you could just change "open" to "runas". I think.
He meant for you to look at your notes. Doesn't using the resources you have make sense?
-Use code tags so I can see where line 16 is
-Why are you performing the same query twice? $q_user
is essentially the same is $query
-You should check that the query result ( $q_user
) is not false before checking the number of rows