I highly agree with diafol if you have time to change it. If not and ryantroop's above comment is a concern then you could always redirect the user to the cart with every param except the ones used to add items.
I highly agree with diafol if you have time to change it. If not and ryantroop's above comment is a concern then you could always redirect the user to the cart with every param except the ones used to add items.
The solution to your problem? Don't refresh. :-/
Not true. I would reccomend simply doing a redirect to the regular cart URL (without params) after you have updated the cart quantities. I put an example below. Since I don't know your URL's I improvised :)
if (isset($_GET['add']))
$_SESSION['cart_'.$_GET['add']]+='1';
header('Location: /cart.php');
}
Pricing a job is highly dependent on a few major factors like the complexity of the project, the skill/experience of the development organization, and current market rates. I can't give you an exact number but this article is a good read on the subject.
I believe the lock item has to be an object as well so if you wanted to put a lock on the counter you would have to use the Integer type instead of the primitive "int".
What you need to do is have the server return a link to the image. Something like "http://mysite.com/images/my_image.jpeg". Then take that link and apply it to the "src" tag of an image element. designershiv's answer above would do it if you were using jQuery but it doesn't look like you are. To apply the source do this:
var imageElem = document.getElementById('image_elem_id');
imageElem.src = 'http://mysite.com/images/my_image.jpeg';
Thank you for the nicely indented post. I am confused as to where you are stuck. Can you point out the exact line numbers and reason why you are stuck?
Also, Im not sure if you posted your production code in here or not but this needs to be changed:$sql="SELECT * FROM fgusers3 WHERE id = '".$q."'";
Thats open to SQL injection. Again, not sure if this is just sample code but make sure that doesn't make it into production systems.
For more info see this page: http://www.wikihow.com/Prevent-SQL-Injection-in-PHP
ardav is saying that without code we can't help you very much. Usually you get the "Webpage Expired" message when data has already been submitted to a form and you try to hit the "Back" button on your browser. This will normally throw an error / warning message because it may result in you re-submitting the data to the page.
I believe the information you need is here:
http://stackoverflow.com/questions/112190/php-ini-smtp-how-do-you-pass-username-password
Check out the second post (marked as the answer)
header( "LOCATION:, $adredirect" );
What's that comma doing after the Location: header?
This is going to be setup in your Apache config (I believe). Not exactly sure where it is though sorry :-/
This is my personal opinion but I've always considered XML config files for PHP to be a little.... weird. This is more of a .NET way to do a config file. Why not just use a "keyword"="value" style config? Or you could even use a config.php script to hold values and also hold other useful config info.
I am a little fuzzy on this subject but I believe the problem lies in the fact that the copy constructor is not always called by default when using the assignment operator on your objects. Your best best is to either manually override the assignment operator. Feel free to correct me if I'm wrong
EDIT:
Narue beat me to it.
Ooo Fbody beat me out by seconds haha :D
In your init.cpp file you are re-declaring the class. You do not need to do this since you already prototyped it in init.h. In init.cpp it should be:
void Initialization::test()
{
// Code for test() method here
}
You need to declare A as a namespace. Then you can put
using A::B;
once and just use the class name.
Lolz this is priceless ^^^
ok, base isn't a method, and I'm smart enough to know that!
so, here's the definition:
class cmd { string base; char extension[80]; };
yes, that's really all there is, it's just a way for me to organize the commands.
Wooah don't get sassy or nobody will help you. You need to declare the member variables as public if you are going to access them directly (Instead of using getter, setter methods).
ok so i have this program here i had to finish, and it was for input and output files, i wrote everything, and even wrote the data.in and data.out files but when i run it i get nothing in return. do the files have to be in the ".in" format cause when i save them, in notepad its data.in.txt
the only thing that was in data.in were four float values
but it returns blank, why? please help.#include <fstream> #include <iomanip> using namespace std; int main() { float val1, val2, val3, val4; //declares 4 variables ifstream inData; // declares input stream ofstream outData; // declares output stream outData << fixed << showpoint; inData.open("data.in"); outData.open("data.out"); inData >> val1 >> val2 >> val3 >> val4; outData << val1 << endl; outData << val2 << endl; outData << val3 << endl; outData << val4 << endl; inData.close(); outData.close(); system("pause"); return 0; }
If the name of the file in windows is data.in.txt then you have to specify that name in the constructor for your ifstream object. So it should look like this instead:
inData.open("data.in.txt");
Also when opening files ALWAYS check to make sure they are open (i.e make sure you have received a valid file handle). Here are two examples:
// This uses the fstream method is_open() to make sure you have a valid file handle
if( inData.is_open() ) {/* Do something*/ }
// This example exits the program if there is no valid file handle …
Another question I have is why are you modding constants? 7 % 10 is always going to be 7 so why not just put 7?
This
RParallel( input[5] ); // calls the funtion
should be this instead
RParallel( input ); // calls the funtion
When you are passing arrays as arguments to a function you only pass the name. The reason for the linker error is when you pass input[4] (Or whatever array subscript you want) you are now passing a variable of type double, not double[]
No he means not agree because of the following line:
cin >> input[1] >> input[2] >> input[3] >> input[4] >> input[5];
This is saying that the array has up to 6 elements but it is defined as int input[5]. This means that calling input[5] will cause the program to crash because it is outside the bounds of the array. It should be this:
cin >> input[0] >> input[1] >> input[2] >> input[3] >> input[4];
Also, using this
int something;
cin>>something;
is dangerous because if the user enters a character instead of an int the program will freak out.
I am not sure how far along you are but this is a great example of when to use polymorphism. If you think about it, Spades, hearts, diamonds and clubs are all cards so why not make a base class Card and then child classes for the different suits.
Ex.
class Card
{
//Insert code and methods for base class
// Should be methods and attributes that can apply to all suits
};
class Spade : public Card
{
// Insert methods and attributes specific to the spade suit
};
// Do that for the three other suits
// When you need to declare them
Card *hearts[13];
Card *diamonds[13];
Card *spades[13];
Card *clubs[13];
// In your for loop
spades[index] = new Spade();
// Do that for all suits
while ( grade != '\n' )
Isn't grade an int or double?? This will never work unless its a character array or string.
Do some research on the getline() function. It is in the iostream library. It has an overloaded form that accepts a third argument which is the delimiting character.
You need to make the lList class inherit from the Node class if you want to access the protected members in Node from lList.
class lList : public Node
{
// Insert code for class
}
You cant get the file to open? Does the file exist in your project directory? Also, in lines 37 and 38 you do:
if (i % 2 == 0) evenSum += i;
if (i % 2 > 0) oddSum += i;
You have never initialized i with a value. This will produce a logical error.
Could you post the code? Have you done any debugging?
Yea your approach is definitely a little off so far. Do you want your program to count how many times a letter (that you specify) appears in a certain string? For example: How many times does the character 'p' appear in the string "apples"? And you want your class to return 2? If so, you should either make the constructor accept the search character and the string to be searched or make a method that accepts those as parameters and returns the count or a negative number if it is not found, for example.
Something simple like this??
const int SIZE = 10 // Or whatever size you want the array to be
int array[SIZE];
ofstream oFile("c:\\someDirectory");
// Load Array
for (int i = 0; i < SIZE; i++)
array[i] = i;
// Output to file
for (i = 0; i < SIZE; i++)
oFile << array[i] << endl;
oFile.close();
// Call other program to read from the file you just created
Removed**
Said something stupid :/
The structure of you program overall is a little off. The option to Quit should really only be contained in the main program loop. So you should present all of the options that the program can do (which includes quit) just in the main menu.
I have always done something like this
if (!myfile) { // error message // exit (1) } // do file stuff here
I usually do this as well..... however you can use the fail method which is contained in the newer fstream lib
ifstream someFile("whatever.txt");
if (someFile.fail())
{
// put error message here and exit program
}
What about calling the generateString function within your buttonclick function, except have generateString return the string instead of void
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
String^ getgenerateString = generateString();
}
String^ generateString()
{
String^ sendThisString = "SendThis";
return sendThisString;
}
If you wanted to use your array of struct outside of that method's scope (myFunc1) you need to return to something, then pass it to another method (like myFunc2)
You just want to dynamically allocate a new array of your struct right? Like this:
myStruct* mySimpleClass::myFunc1 (int arraySize) {
myStruct struct1 = new myStruct[arraySize];
return struct1;
}
void initialize()
{
input.open ("WUexamp1.txt");
}
Files should not be opened this way. You should pass the file name and the fstream object as reference. Like this:
char fileName[] = "input.txt";
bool initialize(char[] fName, fstream& iFile) {
iFile(fName, ios::input | ios::beg);
if (iFile.fail())
return false; // Indicates file open error
else return true;
}
When you pass an array to a function, you only need to pass the name of the array (i.e starting address) Do not include size declarations
pickColor(color[3][19], red, green, blue); // WRONG!
pickColor(color, red, green, blue); // Correct
Ok, first off, please read this before posting code again:
http://www.daniweb.com/forums/misc-explaincode.html
Second, you need to accumulate the numbers that are entered by the user. Depending on what you have learned so far, you can either use an accumulator (the numbers entered by the user are added to this variable with each iteration of the loop) or you could use an array, then add all the elements in the array, get the average, etc...
rand() % 7 is going to get you numbers between 0 and 6 which will overstep the bounds of your array by 1 if a 6 is pulled.
I'm confused why you broke up the loop like you did?
That is correct, if you use rand() % 6 + 1 you will be good. Also, when you define a function:
void printScreen(char dice[16][6])
You only need the second array size defined.
void printScreen(char dice[][6])
*EDIT: Sorry, upon second look I see you return position and not index, so it would work, the second vers of the code is a little more concise/ clear tho and you dont need as many variables
Also, a smal logical problem :
int searchList(const int list[], int size, int value)
{
int index = 0,
position = -1;
bool found = false;
while(index < size && !found)
{
if(list[index] == value)
{
found = true;
position = index;
}
index++;
}
return position;
}
The index will be incremented one more time even if the PIN is found because it runs one more time after the flag is set to true. If the PIN is located, you want to return that position. Like this:
int searchList(const int list[], int size, int value)
{
int index = 0,
while(index < size)
{
if(list[index] == value)
return index;
index++;
}
return -1; // Indicates PIN not found
}
I agree with jonsca, use a 2D array. The rest is all up to you and VERY customizable. Depending on how crazy your prof is.... you could step through the array and randomize each dice using rand() generator limited by the amount of letters in alphabet.
yep, put thomas' and my posts together and you got yourself a correct answer haha
Looking at the for loop in your backwards function:
for(count = SIZE; count >= 0; count--); { cout << strPtr[count] << endl; }
The first thing you print is strPtr[11] which will contain logical garbage, the array will only go to subscript [10] if the array size is 11.
Instead, what about this:
for (count = strlen(strPtr); count >= 0; count --)
cout << strPtr[count] << endl;