traxy Posted May 2, 2009 Share Posted May 2, 2009 Hey Guys, I am having trouble, I am working on an assignment is basically an online store that sells CDs. Now I am trying to add items to the Cart but getting is weird error "Object Id #2", see below for the code and yes I know its very messy code at the moment but im just testing with it. <?php $DBConnect=@mysqli_connect("localhost", "username", "password", "database") Or die("<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysqli_connect_errno($DBConnect) . ":" . mysqli_connect_error($DBConnect)) . "</p>"; $TableName="cart"; $CdId = "$_GET[cdid]"; $CdNamestring = "SELECT cd_name FROM CDs WHERE cd_id='$CdId'"; $CdName = mysqli_query($DBConnect, $CdNamestring); $ItemQtystring = "SELECT item_qty FROM cart WHERE cd_id='$CdId'"; $ItemQty = mysqli_query($DBConnect, $ItemQtystring); $TotalQty = $ItemQty + 1; $Pricestring = "SELECT cd_price FROM CDs WHERE cd_id='$CdId'"; $Price = mysqli_query($DBConnect, $Pricestring); $CurrentTotalPricestring = "SELECT total_price FROM cart WHERE cd_id='$CdId'"; $CurrentTotalPrice = mysqli_query($DBConnect, $CurrentTotalPricestring); $TotalPrice = $Price + $CurrentTotalPrice; echo "Table: '$TableName' cd_id: '$CdId' CD Name: $CdName ItemQty: '$ItemQty' TotalQty: '$TotalQty' Price: '$Price' Current Total: '$CurrentTotalPrice' TOTAL:'$TotalPrice'"; $SQLstring = "INSERT INTO $TableName VALUES ('','','$CdName','$TotalQty','$TotalPrice')"; $QueryResult=mysqli_query($DBConnect, $SQLstring) Or die("<p>Unable to execute the query.</p>" . "<p>Error code " . mysqli_connect_errno($DBConnect) . ":" . mysqli_connect_error($DBConnect)) . "</p>" . '<a href="admin.html">Return to Delete.php page</a>'; echo "<p>Successfully Added to Cart</p>"; echo '<a href="main.php">Return CD Selection</a>'; mysqli_close($DBConnect); ?> Im echoing all the variables to the screen to see what they are and this is the output: Table: 'cart' cd_id: '2' CD Name: Object id #2 ItemQty: 'Object id #3' TotalQty: '2' Price: 'Object id #4' Current Total: 'Object id #5' TOTAL:'2' Please let me know if you need more information. Link to comment https://forums.phpfreaks.com/topic/156498-what-does-this-mean-object-id-2/ Share on other sites More sharing options...
Mchl Posted May 2, 2009 Share Posted May 2, 2009 OK... you got it all wrong MySQLi is used like this: $qry = "SELECT cd_name, item_qty, cd_price FROM CDs WHERE cd_id='$CdId'"; $result = mysqli_query($DBConnect, $Pricestring); $row = mysqli_fetch_assoc($result); var_dump($row); //this will show an array with data Link to comment https://forums.phpfreaks.com/topic/156498-what-does-this-mean-object-id-2/#findComment-824109 Share on other sites More sharing options...
ignace Posted May 2, 2009 Share Posted May 2, 2009 Object id #.. is a description for it's internal objects Link to comment https://forums.phpfreaks.com/topic/156498-what-does-this-mean-object-id-2/#findComment-824113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.