
carbonxps
Members-
Posts
23 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
carbonxps's Achievements

Newbie (1/5)
0
Reputation
-
Sorry I didn't realize it was joomla specific, it's a component I added onto joomla. Honestly thought it was PHP question.
-
Hi there, I call a variable from a component to get a users location: JRequest::getInt('CS_SESSION_LOCATIONID', null, 'COOKIE'); Only trouble is that in some case's I want to reset the value from a link. Any body got any idea how to clear CS_SESSION_LOCATIONID ? Thanks.
-
Thanks so much, that's perfect..... Unfortunately I can't use sessions as this is going to link to other applications on different servers. Thanks again.
-
OK I'm off on a bit of a tangent at the moment.... I thought ahead and even if I get the array to the next page I need to extract just the values I need, so I thought it would make more sense to do this first then deal with the array. for($i = 0; $i < $cart["idx"]; $i++) { print_r($cart[$i]['product_id']); echo "<BR/>"; $result=implode(',', $cart[$i]) ; echo $result; } The print r command is outputting exactly the values I want, but I can't get this into the results, logic says to me that I need to use: $result=implode(',', $cart[$i]['product_id']) ; But this gives an error: Warning: implode() [function.implode]: Invalid arguments I might be going about this all wrong, but basically I have an array called $cart which contains multiple items, all i'm trying to do is extract 1 part of the array the product_id, then I was to pass this value via url to a get variable so I can then filter a recordset based on the contents. All I need to do is have a variable on my results page like id1, id2, id3 etc. I would be very grateful for any advice. Thanks in advance..
-
Sorry the array didn't post correctly: array(3) { ["idx"]=> int(2) [0]=> array(5) { ["quantity"]=> int(4) ["product_id"]=> string(3) "122" ["parent_id"]=> string(3) "122" ["category_id"]=> string(2) "15" ["description"]=> string(0) "" } [1]=> array(5) { ["quantity"]=> int(1) ["product_id"]=> string(2) "77" ["parent_id"]=> string(2) "77" ["category_id"]=> string(2) "19" ["description"]=> string(0) "" } }
-
I think I'm making the array wrong, can somebody tell me how to extract the product_id into a serialize array from the following Array This is the output from var_dump $cart array(3) { ["idx"]=> int(2) [0]=> array(5) { ["quantity"]=> int(4) ["product_id"]=> string(3) "122" ["parent_id"]=> string(3) "122" ["category_id"]=> string(2) "15" ["description"]=> string(0) "" } [1]=> array(5) { ["quantity"]=> int(1) ["product_id"]=> string(2) "77" ["parent_id"]=> string(2) "77" ["category_id"]=> string(2) "19" ["description"]=> string(0) "" } } All I want to do is get the product_id to another page so I can use it in a select. So I want the the variable /array to be 122, 77 Obviously there maybe more than two items in the array. Thanks again.
-
Hey thanks for that, I've modified the code to just use product_id: <?PHP $str = serialize($cart[product_id]); $strenc = urlencode($str); print $str . "\n"; echo"<BR?>"; print $strenc . "\n"; ?> <A href="/test/getcart.php?cartinfo=<?PHP echo $strenc; ?>">test</A> <?PHP $cartinfo = unserialize($_GET["cartinfo"]); var_dump($cartinfo); ?> The variable is: cartinfo=N%3B But output is NULL Thanks again.
-
Hi all, new to php and struggling passing an array via url. first page: $str = serialize($cartinfo); $strenc = urlencode($str); <A href="/test/getcart.php?cartinfo=<?PHP echo $strenc; ?>">test</A> Which does add a long string to the URL so I guess to here it's fine. Second Page: <?PHP $cartinfo = unserialize($_GET["cartinfo"]); var_dump($cartinfo); ?> However all I get is: bool(false) Any advice would be great, I also tried adding $cartinfo to the session, but this didn't work either. Surely passing variables should be straight forward??? Thanks.
-
Ah cool, I corrected this and got a similar error on $result1 so I changed that to: if(isset($result1)) So no errors now, but the table still isn't updating. As soon as I hit submit any changes lost and the page re-loads the original data. Any ideas? Sorry I'm very new to php...
-
Thanks so much for your help. I tried this and now I get an error: Fatal error: Call to undefined function is_set() in test.php on line 68
-
Thanks for that, I thought debugging had to be enable on the server in php.ini. I am very new to php obviously..... At least I'm getting some errors now: Notice: Undefined variable: Submit in test.php on line 68 Notice: Undefined variable: result1 in test.php on line 76 I also thought variables were declared as they were used??? Thanks again.
-
Hi All, Can't get this code working. the statement works fine directly on the table, just not when executed from the PHP file: <strong>Multi Update</strong><br> <?php $host="localhost"; // Host name $username="user_name"; // Mysql username $password="Password"; // Mysql password $db_name="dbname"; // Database name $tbl_name="tablename"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT mik1vm_product.product_id, mik1vm_product.product_sku, mik1vm_product.product_name, mik1vm_product.product_in_stock, mik1vm_product.product_in_stock_cardiff FROM $tbl_name"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Product Id</strong></td> <td align="center"><strong>SKU</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>In Stock</strong></td> <td align="center"><strong>In Stock Cardiff</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><? $product_id[]=$rows['product_id']; ?><? echo $rows['product_id']; ?></td> <td align="center"><input name="product_sku[]" type="text" id="product_sku" value="<? echo $rows['product_sku']; ?>"></td> <td align="center"><input name="product_name[]" type="text" id="product_name" value="<? echo $rows['product_name']; ?>"></td> <td align="center"><input name="product_in_stock[]" type="text" id="product_in_stock" value="<? echo $rows['product_in_stock']; ?>"></td> <td align="center"><input name="product_in_stock_cardiff[]" type="text" id="product_in_stock_cardiff" value="<? echo $rows['product_in_stock_cardiff']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE $tbl_name SET product_sku='$product_sku[$i]', product_name='$product_name[$i]', product_in_stock='$product_in_stock[$i]' , product_in_stock_cardiff='$product_in_stock_cardiff[$i]' WHERE product_id='$product_id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:test.php"); } mysql_close(); ?> The page loads fine, but just doesn't update the DB. Thanks in advance for any help.
-
OK So I've got a datepicker that sends a date in d/m/y format. My DB stores the data in Unix Timestamp Which I can convert the date to with strtotime however this does the exact date & time. All I want is the actual day. I've spent hours trying to convert this with just the day with mixed results... Thanks.
-
Hi all, I have a what I thought was a call to the db: $db->sp("attrib_stock1"); However when I try to calculate on this field or assign it's value to a variable it fails however if I put it in a page it actually echoes out the value. If I were to say $blahblah = $db->sp("attrib_stock1"); echos $blahblah it would echo 0 (zero) but if I replace it with $db->sp("attrib_stock1"); it echoes out the value. What does $db->sp mean? can I assign this value to a variable? Thanks for any advice.
-
Adding variables together Newbie Question...
carbonxps replied to carbonxps's topic in PHP Coding Help
Yes your absolutely correct. I thought: $db->sp("attrib_stock2") was the value from the database, but it does echo... I don't suppose anybody can break down this: $db->sp("attrib_stock2") to explain further? Thanks very much for your help.