Hi all, New to posting on this forum and trying to get my add page to wish list working correctly.
Passing the code and type variables through to this page and echos fine. But when trying to add my database results into an array I am getting the Resource id #4. The code I am using is below without the dasebase password. - <?php
-
include 'session.php';
-
$con = mysql_connect("94.136.61.138", "xxxxx", "xxxx");
-
setcookie ('basket', $cart);
-
-
if (isset ($_POST["code"])) $code = mysql_real_escape_string($_POST["code"]);
-
if (isset ($_POST["type"])) $type = mysql_real_escape_string($_POST["type"]);
-
-
$dbcode = $_POST["code"];
-
$dbtable = $_POST["type"];
-
echo "table =" .$dbtable;
-
echo "<br>";
-
echo "code = ".$dbcode;
-
-
$query = mysql_db_query("xxxxxxx", "select smalltitle, smallimage, alt_small_img, costprice from $dbtable where pagelocation = '$dbcode'");
-
echo mysql_error();
-
while ($row = mysql_fetch_row($query)){
-
echo $row[0];
-
-
for ($z=0; $z<count($code); $z++){
-
$shoppinglist[] = array(($code[$z][1] /$row[1]) ,$row[0], $row[1], 0);
-
-
}
-
-
}
-
for ($i=0; $i<count($shoppinglist); $i++){
-
addel($shoppinglist[$i][0], $shoppinglist[$i][1], $shoppinglist[$i][2], $shoppinglist[$i][3]);
-
}
-
-
echo $query;
-
//echo $shoppinglist;
-
-
-
-
//header("location:wish_list.php");
-
?>
--------
Any help with this would be great.
To see the results of this you can look at the page LINK REMOVED FOR USER SAFETY.
Many thanks and hope this is easy to sort as I have try changing lots of things, but always come out with this error or before an Array error.
Thanks
whiskyman
5 1991 Atli 5,058
Recognized Expert Expert
Hey.
The echo on line #30 is generating the "Resource id #" output. It is what you get when you echo the return values of functions that return resources, rather than actual variables. - These include functions like mysql_connect and mysql_query.
Those return values are not meant to be used directly, but to be used by other functions to fetch values from external resources.
P.S.
You should avoid using the mysql_db_query function. Using the mysql_select_db and mysql_query separately is recommended instead. (The mysql_db_query function is deprecated in 5.3, and removed in 6.0)
Hi Atli and thank you for your message back.
I have changed that code and taken away the echos. I now get the cart going right through to the next page and displays the value Array now. you can see this by clicking the link below again. Nothing appears in the cart. Im sure my session.php code is correct, but I have listed it below and added the include session.php code to every page. - <?php
-
session_start();
-
session_name('cartdetails');
-
$private_id = session_id();
-
$privateKey = $_SESSION['pr_key'];
-
$IPADDRESS = $_SERVER['REMOTE_ADDR'];
-
-
-
if (!isset($_SESSION["cart"])){
-
$_SESSION["cart"] = array();
-
$_SESSION["partof"] = 0;
-
}
-
-
function wishlist($type, $code){
-
$tmp = $_SESSION["cart"];
-
$is = false;
-
for ($i=0; $i<count($tmp); $i++){
-
if (($tmp[$i][1] == $code)){
-
$is = true;
-
$tmp[$i][0] = $tmp[$i][0] + $no;
-
break;
-
}
-
}
-
if ($is==false){
-
$tmp[] = array($type, $code);
-
}
-
$_SESSION["cart"] = $tmp;
-
}
-
-
?>
Any other help you have on this would be excellent.
Markus 6,050
Recognized Expert Expert
Hey, Whiskeyman. Welcome to Bytes.com.
Firstly, in future could you, when posting code, wrap the code in [code] ... [/code] tags. This formats the code making it easier to read and, thus, debug.
Second, to your problem. The reason you see "Array" when trying to output the session data is because you need to access specific indexes of the array, just like you would any other array. As you are not using strings for your indexes, you'll access them numerically (in this case 0 for $type and 1 for $code). -
printf('Type is: %s<br />Code is: %s', $_SESSION['cart'][0], $_SESSION['cart'][1]);
-
Marl/
Hi Markus and thanks for your help there. I am still struggling to get this working. We keep changing things and hopefully I will get there. Thanks again and any other suggestings would be great. It really the first time I have done a session cookie and just getting my head round it.
Thanks again and I will make sure next time I put code into this forum I will put the tags in.
Alan
numberwhun 3,509
Recognized Expert Moderator Specialist
Hello! I removed your link from your thread, but not for spam purposes. The reason is because if you go to the link, it seems that the site is questionable in the browsers I tried it in. This could be caused by the SSL cert being bad or that the site is an IP but resolves to a .ru URL.
Either way, please make sure the that links you post are safe and resolve correctly. Thank you!
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Newbie |
last post by:
OK, this may be impossible since I'm using 3rd party shopping cart ASP
software, but I've been able to finagle a lot of other stuff I thought
wouldn't work, so here we go:
I'm using a form in which users enter numbers to be calculated into a square
footage cost. Upon submitting, the results page uses ASP to give the total
and the chance to add the new totalled item to the cart or try a new
calculation. Part of the cart's software has a...
|
by: Don Grover |
last post by:
I am retrieving costs and product id's from a sql db. and need to build a
shopping cart around it.
How do I store the selected items and qty req so I can move into another
catalog and total up as im going.
Just a couple of hints will do, Im familiar with vb script but not java
based code , and im wondering how to store what they select so I can move
around different product ranges.
Don
|
by: Jia Sun |
last post by:
hello , everybody , i need a similar program , just like
fancyimport.com
if possible, pls contact me ,thank you very much .
inchina@gmail.com
|
by: Penny |
last post by:
Hi all,
I've built an online shopping cart using ASP Classic(based on a 'WebThang'
tutorial). The shop cart page (with table showing customers selected items
and costs) has only 3 buttons/links.
1: Back to Shop: Uses 'javascript:history.go(-1)' to go to previous page.
2: Remove Item(one next to each item in cart): Clears the selected item from
the session variable array redisplays the page.
|
by: MickG |
last post by:
I am trying to change the value of the variable "hard" according to
which radio button is pressed and I am having no joy. Could anyone
help me with this, the problematic section is marked with
***********************, I've included all the code incase that isn't
where the problem is.
Any help would be hugely appreciated.
Mick
| |
by: G.E.M.P |
last post by:
High Level Session Handling Design for a Shopping cart
0) What am I missing?
1) How does OSCommerce do it?
I'm thinking about building a shopping cart from scratch,
using a library of dynamic screen generation routines
(already written) that take an XML stream as input from
various "search for products" forms. That way I can
run queries in one window and display the dynamic
results in another. The searching functions will probably
|
by: Vahehoo |
last post by:
Hi,
I have an ASP .Net e-business site that is built using DNN 2.0. I am
having troubles passing my shopping cart items to PayPal. I implemented
a total paynow button, but it was not good enough for my customer. I
found some PayPal ASP.Net controls to be used with .net studio.
Basically, I want the user to be able to shop on my website, add items
to my shopping cart and at the checkout to be taken to the PayPal
website. I would like...
|
by: Travis1012 |
last post by:
Hi,
I require a shopping cart which gathers infomation from customers on what they wish to purchase (all products show a price with them). After they have created their list, they go to the cart they input their contact details (Name, Address, Email) and I recieve the list of products they wish via an email, file or location on the website (preferably email). After that I wish to email them back with a quote for postage to their address for...
|
by: Travis1012 |
last post by:
Hi,
I require a shopping cart which gathers infomation from customers on what they wish to purchase (all products show a price with them). After they have created their list, they go to the cart they input their contact details (Name, Address, Email) and I recieve the list of products they wish via an email, file or location on the website (preferably email). After that I wish to email them back with a quote for postage to their address for...
|
by: Harlan Messinger |
last post by:
The Doctor wrote:
A quandary? Hardly.
I would think that you'd address this question to the bank whose page
you are submitting the information to.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |