Jurjen Roels
|
| Posted: 08/22/2002, 7:38 AM |
|
Hi,
I have a record. When inserting a new record i have a custom after insert event.
In this event i want to add the mysql_insert_id() to the query string
I do this with:
$last_id=mysql_insert_id();
CCAddParam(CCGetQueryString("QueryString", ""), "product_id", $last_id);
This does not seem to work within CCS.
I suppose that if i add the parameter it will be added tot the QueryString which is used in the redirect part of the main page.
What am i doing wrong?
|
|
|
 |
Nicole
|
| Posted: 08/23/2002, 4:11 AM |
|
Jurjen,
you cannot use CCAddParam() function in such way because it return a result and it should be assigned to any variable. E.g.:
$my_var = CCAddParam(CCGetQueryString("QueryString", ""), "product_id", $last_id);
But in your case you should use another code. Look at generated code and find $Redirect variable. It stores the page name and parameter string to pass. It is used to redirect user. So you should add custom parameter to it using code (form After Insert event):
global $Redirect;
$Redirect .= "&product_id=". mysql_insert_id();
|
|
|
 |
Jurjen Roels
|
| Posted: 08/25/2002, 12:45 PM |
|
That does not work.
$redirect is overwritten by the generated code. it uses the querystring to pass variables.
So the question is still how do i add parameters to the querystring
|
|
|
 |
Jurjen Roels
|
| Posted: 08/25/2002, 1:01 PM |
|
|
|
|
 |
Jurjen Roels
|
| Posted: 08/25/2002, 1:01 PM |
|
|
|
|
 |
Jurjen Roels
|
| Posted: 08/25/2002, 1:02 PM |
|
The following code:
$last_id=mysql_insert_id();
echo("last id :".$last_id);
echo(" query current". CCGetQueryString("QueryString", ""));
CCAddParam(CCGetQueryString("QueryString", ""), "product_id", $last_id);
echo(" query after". CCGetQueryString("QueryString", ""));
Gives the following response:
last id :20
query current ccsForm=products
query after ccsForm=products
Looks like CCAddParam does not work. What am i doing wrong?
Jurjen
|
|
|
 |
Jurjen Roels
|
| Posted: 08/25/2002, 1:12 PM |
|
I understand now what nicole meant:
$some_var=CCAddParam(CCGetQueryString("QueryString", ""), "product_id", $last_id);
Then $some_var holds the whole querysting + product_id=xx;
This does not solve my problem....But i found a work around. I just used some code in the generated part to use that parameter
|
|
|
 |
|