Page 2 of 2
Little change to above code
Posted: Mon Jun 28, 2004 10:17 am
by EricS
Previous code:
Code: Select all
$result = mysql_query("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc");
echo($result);
New code:
Code: Select all
$sql = "select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc";
echo ($sql);
$result = mysql_query($sql);
Be in the previous code you were telling echo to print the MySQL resource id, the new code is telling echo to print the sql.
Check the SQL that is printed to make sure it's as you expect it to be.
Posted: Mon Jun 28, 2004 10:30 am
by stantheman
Still says Resource Id#3
Posted: Mon Jun 28, 2004 10:38 am
by EricS
Post the database section of the code please.
Posted: Mon Jun 28, 2004 10:38 am
by patrikG
php manual wrote:mysql_query() returns a resource identifier or FALSE if the query was not executed correctly
If a resource ID is returned by mysql_query() you have run a valid SQL statement. The resource ID is simply an identifier for your "resource" - in this case a mysql-database. You can use all of PHP4+'s bundled mysql-functions (e.g. mysql_num_rows(), mysql_fetch_array()) etc. to do whatever you require - fetch data, etc. It's all in the PHP Manual.
A general note: if you are creating an online shop:
YOU MUST(!!!!) make sure that what you are doing is as secure as possible. That means you know about PHP as well as mySQL security issues (e.g. register_globals, sql injection etc. etc.).
If you plan to write your own credit card transaction script as part of this shop-system: don't unless you can honestly say that you know the ins and outs of the security issues involved. And there are plenty. You'd be dealing with other people's money and one mistake in your script can cost them - and eventually you - a lot of money, time etc.
Posted: Mon Jun 28, 2004 2:42 pm
by stantheman
I'm not actually building shopping cart for use i want to use the consept of a shopping cart for another project of mine and i feel this type of logic works better.
Posted: Tue Jun 29, 2004 6:57 am
by stantheman
I'm still not getting anything to print out
Posted: Tue Jun 29, 2004 6:59 am
by patrikG
please post the relevant bits of the code you're using.
Posted: Tue Jun 29, 2004 8:03 am
by stantheman
They are one page one of the thread at the top
Posted: Tue Jun 29, 2004 8:09 am
by patrikG
I know. I presume you have modified the code to get the db-access working. Post that code-snippet, please.
Posted: Tue Jun 29, 2004 8:45 am
by stantheman
ok i guess i should get your opion on how i shoudl go about this. This is exactly what i'm trying to do i'm not sure if i need to use the shopping cart method or not maybe you may have some useful hints. I have the page where you can customize you home
http://www.dutchmanlanding.com/customizehome.html
on submission is does some calculations and gives you your new price with the options selected and it prints a list of the options selected
What i'm trying to do it make the list after submission a checkbox so that you can uncheck them so you can remove that option becasue maybe you relized the price is to much BHut i've been struggling trying to figure this out so that is why i thought the shopping cart method might work but maybe you may have another idea you can throw my way.