hass1980 Posted April 14, 2009 Share Posted April 14, 2009 I am getting a parse error from the functions.php page. Could anyone help me with this plz. Parse error: parse error in C:\wamp\www\website\functions.php on line 50 <?php function pf_validate_number($value, $function, $redirect) { if(isset($value) == TRUE) { if(is_numeric($value) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $redirect); } else { $final = $value; } } else { if($function == 'redirect') { header("Location: " . $redirect); } if($function == "value") { $final = 0; } } return $final; } function showcart() { if($_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $custsql = "SELECT id, status from orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); } $itemnumrows = mysql_num_rows($itemsres); } else { $custsql = "SELECT id, status from orders WHERE session = '" . session_id() "' AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); If no SESS_ORDERNUM variable is available, the $itemnumrows variable is set to 0: $itemnumrows = mysql_num_rows($itemsres); } } else { $itemnumrows = 0; } $itemnumrows = 0; } if($itemnumrows == 0) { echo "You have not added anything to your shopping cart yet."; } If $itemnumrows has a value, the items are displayed: echo "You have not added anything to your shopping cart yet."; } else { echo "<table cellpadding='10'>"; echo "<tr>"; echo "<td></td>"; echo "<td><strong>Item</strong></td>"; echo "<td><strong>Quantity</strong></td>"; echo "<td><strong>Unit Price</strong></td>"; echo "<td><strong>Total Price</strong></td>"; echo "<td></td>"; echo "</tr>"; while($itemsrow = mysql_fetch_assoc($itemsres)) { $quantitytotal = $itemsrow['price'] * $itemsrow['quantity']; echo "<tr>"; if(empty($itemsrow['image'])) { echo "<td><img src='./productimages/dummy.jpg' width='50' alt='" . $itemsrow['name'] . "'></td>"; } else { echo "<td><img src='./productimages/" . $itemsrow['image'] . "' width='50' alt='" . $itemsrow['name'] . "'></td>"; } echo "<td>" . $itemsrow['name'] . "</td>"; echo "<td>" . $itemsrow['quantity'] . "</td>"; echo "<td><strong>£" . sprintf('%.2f', $itemsrow['price']) . "</strong></td>"; echo "<td><strong>£" . sprintf('%.2f', $quantitytotal) . "</strong></td>"; echo "<td>[<a href='" . $config_basedir . "delete.php?id=" . $itemsrow['itemid'] . "'>X</a>]</td>"; echo "</tr>"; $total = $total + $quantitytotal; $totalsql = "UPDATE orders SET total = " . $total . " WHERE id = " . $_SESSION['SESS_ORDERNUM']; $totalres = mysql_query($totalsql); } echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td>TOTAL</td>"; echo "<td><strong>£" . sprintf('%.2f', $total) . "</strong></td>"; echo "<td></td>"; echo "</tr>"; echo "</table>"; echo "<p><a href='checkout-address.php'>Go to the checkout</a></p>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/ Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 change this... <?php $custsql = "SELECT id, status from orders WHERE session = '" . session_id() "' AND status < 2;"; to this... <?php $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809445 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 Hi MasterACE14 I have just changed it, but still having the same error, What you suggested, looks like the same code you asked me to change. :-\ Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809451 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 the session_id(); wasn't concocted right in the variable. Try and put it all on 1 line incase you missed out the dot . <?php $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809456 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 now getting this error now lol Parse error: parse error, expecting `'('' in C:\wamp\www\website\functions.php on line 61 Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809464 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 there was about 4 errors when I ran this script through phpDesigner. here is the fixed script... <?php function pf_validate_number($value, $function, $redirect) { if(isset($value) == TRUE) { if(is_numeric($value) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $redirect); } else { $final = $value; } } else { if($function == 'redirect') { header("Location: " . $redirect); } if($function == "value") { $final = 0; } } return $final; } function showcart() { if($_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $custsql = "SELECT id, status from orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); } $itemnumrows = mysql_num_rows($itemsres); } else { $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); // If no SESS_ORDERNUM variable is available, the $itemnumrows variable is set to 0: $itemnumrows = mysql_num_rows($itemsres); } } if($itemnumrows == 0) { echo "You have not added anything to your shopping cart yet."; } else { echo "<table cellpadding='10'>"; echo "<tr>"; echo "<td></td>"; echo "<td><strong>Item</strong></td>"; echo "<td><strong>Quantity</strong></td>"; echo "<td><strong>Unit Price</strong></td>"; echo "<td><strong>Total Price</strong></td>"; echo "<td></td>"; echo "</tr>"; while($itemsrow = mysql_fetch_assoc($itemsres)) { $quantitytotal = $itemsrow['price'] * $itemsrow['quantity']; echo "<tr>"; if(empty($itemsrow['image'])) { echo "<td><img src='./productimages/dummy.jpg' width='50' alt='" . $itemsrow['name'] . "'></td>"; } else { echo "<td><img src='./productimages/" . $itemsrow['image'] . "' width='50' alt='" . $itemsrow['name'] . "'></td>"; } echo "<td>" . $itemsrow['name'] . "</td>"; echo "<td>" . $itemsrow['quantity'] . "</td>"; echo "<td><strong>£" . sprintf('%.2f', $itemsrow['price']) . "</strong></td>"; echo "<td><strong>£" . sprintf('%.2f', $quantitytotal) . "</strong></td>"; echo "<td>[<a href='" . $config_basedir . "delete.php?id=" . $itemsrow['itemid'] . "'>X</a>]</td>"; echo "</tr>"; $total = $total + $quantitytotal; $totalsql = "UPDATE orders SET total = " . $total . " WHERE id = " . $_SESSION['SESS_ORDERNUM']; $totalres = mysql_query($totalsql); } echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td>TOTAL</td>"; echo "<td><strong>£" . sprintf('%.2f', $total) . "</strong></td>"; echo "<td></td>"; echo "</tr>"; echo "</table>"; echo "<p><a href='checkout-address.php'>Go to the checkout</a></p>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809477 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 Thanks MasterACE14, I added the corrected code but now got this error Parse error: parse error in C:\wamp\www\website\functions.php on line 120 Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809500 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 try... <?php function pf_validate_number($value, $function, $redirect) { if(isset($value) == TRUE) { if(is_numeric($value) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $redirect); } else { $final = $value; } } else { if($function == 'redirect') { header("Location: " . $redirect); } if($function == "value") { $final = 0; } } return $final; } function showcart() { if($_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $custsql = "SELECT id, status from orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); } $itemnumrows = mysql_num_rows($itemsres); } else { $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); // If no SESS_ORDERNUM variable is available, the $itemnumrows variable is set to 0: $itemnumrows = mysql_num_rows($itemsres); } } if($itemnumrows == 0) { echo "You have not added anything to your shopping cart yet."; } else { echo "<table cellpadding='10'>"; echo "<tr>"; echo "<td></td>"; echo "<td><strong>Item</strong></td>"; echo "<td><strong>Quantity</strong></td>"; echo "<td><strong>Unit Price</strong></td>"; echo "<td><strong>Total Price</strong></td>"; echo "<td></td>"; echo "</tr>"; while($itemsrow = mysql_fetch_assoc($itemsres)) { $quantitytotal = $itemsrow['price'] * $itemsrow['quantity']; echo "<tr>"; if(empty($itemsrow['image'])) { echo "<td><img src='./productimages/dummy.jpg' width='50' alt='" . $itemsrow['name'] . "'></td>"; } else { echo "<td><img src='./productimages/" . $itemsrow['image'] . "' width='50' alt='" . $itemsrow['name'] . "'></td>"; } echo "<td>" . $itemsrow['name'] . "</td>"; echo "<td>" . $itemsrow['quantity'] . "</td>"; echo "<td><strong>£" . sprintf('%.2f', $itemsrow['price']) . "</strong></td>"; echo "<td><strong>£" . sprintf('%.2f', $quantitytotal) . "</strong></td>"; echo "<td>[<a href='" . $config_basedir . "delete.php?id=" . $itemsrow['itemid'] . "'>X</a>]</td>"; echo "</tr>"; $total = $total + $quantitytotal; $totalsql = "UPDATE orders SET total = " . $total . " WHERE id = " . $_SESSION['SESS_ORDERNUM']; $totalres = mysql_query($totalsql); } echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td>TOTAL</td>"; echo "<td><strong>£" . sprintf('%.2f', $total) . "</strong></td>"; echo "<td></td>"; echo "</tr>"; echo "</table>"; echo "<p><a href='checkout-address.php'>Go to the checkout</a></p>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809504 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 wow ok, something different happened there, can now see the web page but now got a few more errors displaying now. Notice: Undefined variable: itemnumrows in C:\wamp\www\website\functions.php on line 61 You have not added anything to your shopping cart yet. Your shopping cart Notice: Undefined index: SESS_LOGGEDIN in C:\wamp\www\website\functions.php on line 28 Notice: Undefined variable: itemsres in C:\wamp\www\website\functions.php on line 43 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 43 Go to the checkout Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809508 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 ok, reverting back to your first script lol. Gimme a few. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809512 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 ok try this... <?php function pf_validate_number($value, $function, $redirect) { if(isset($value) == TRUE) { if(is_numeric($value) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $redirect); } else { $final = $value; } } else { if($function == 'redirect') { header("Location: " . $redirect); } if($function == "value") { $final = 0; } } return $final; } function showcart() { if($_SESSION['SESS_ORDERNUM']) { if($_SESSION['SESS_LOGGEDIN']) { $custsql = "SELECT id, status from orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); } $itemnumrows = mysql_num_rows($itemsres); } else { $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); // If no SESS_ORDERNUM variable is available, the $itemnumrows variable is set to 0: $itemnumrows = mysql_num_rows($itemsres); } } if($itemnumrows == 0) { echo "You have not added anything to your shopping cart yet."; } else { echo "<table cellpadding='10'>"; echo "<tr>"; echo "<td></td>"; echo "<td><strong>Item</strong></td>"; echo "<td><strong>Quantity</strong></td>"; echo "<td><strong>Unit Price</strong></td>"; echo "<td><strong>Total Price</strong></td>"; echo "<td></td>"; echo "</tr>"; while($itemsrow = mysql_fetch_assoc($itemsres)) { $quantitytotal = $itemsrow['price'] * $itemsrow['quantity']; echo "<tr>"; if(empty($itemsrow['image'])) { echo "<td><img src='./productimages/dummy.jpg' width='50' alt='" . $itemsrow['name'] . "'></td>"; } else { echo "<td><img src='./productimages/" . $itemsrow['image'] . "' width='50' alt='" . $itemsrow['name'] . "'></td>"; } echo "<td>" . $itemsrow['name'] . "</td>"; echo "<td>" . $itemsrow['quantity'] . "</td>"; echo "<td><strong>£" . sprintf('%.2f', $itemsrow['price']) . "</strong></td>"; echo "<td><strong>£" . sprintf('%.2f', $quantitytotal) . "</strong></td>"; echo "<td>[<a href='" . $config_basedir . "delete.php?id=" . $itemsrow['itemid'] . "'>X</a>]</td>"; echo "</tr>"; $total = $total + $quantitytotal; $totalsql = "UPDATE orders SET total = " . $total . " WHERE id = " . $_SESSION['SESS_ORDERNUM']; $totalres = mysql_query($totalsql); } echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td>TOTAL</td>"; echo "<td><strong>£" . sprintf('%.2f', $total) . "</strong></td>"; echo "<td></td>"; echo "</tr>"; echo "</table>"; echo "<p><a href='checkout-address.php'>Go to the checkout</a></p>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809519 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 Nope, still getting the following errors lol Notice: Undefined variable: itemnumrows in C:\wamp\www\website\functions.php on line 61 You have not added anything to your shopping cart yet. Your shopping cart Notice: Undefined index: SESS_LOGGEDIN in C:\wamp\www\website\functions.php on line 28 Notice: Undefined variable: itemsres in C:\wamp\www\website\functions.php on line 43 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 43 Go to the checkout Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809526 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 try... <?php function pf_validate_number($value, $function, $redirect) { if(isset($value) == TRUE) { if(is_numeric($value) == FALSE) { $error = 1; } if($error == 1) { header("Location: " . $redirect); } else { $final = $value; } } else { if($function == 'redirect') { header("Location: " . $redirect); } if($function == "value") { $final = 0; } } return $final; } function showcart() { if($_SESSION['SESS_ORDERNUM']) { $custsql = "SELECT id, status from orders WHERE customer_id = " . $_SESSION['SESS_USERID'] . " AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); } else { $custsql = "SELECT id, status from orders WHERE session = '" . session_id() . "' AND status < 2;"; $custres = mysql_query($custsql); $custrow = mysql_fetch_assoc($custres); $itemssql = "SELECT products.*, orderitems.*, orderitems.id AS itemid FROM products, orderitems WHERE orderitems.product_id = products.id AND order_id = " . $custrow['id']; $itemsres = mysql_query($itemssql); $itemnumrows = mysql_num_rows($itemsres); // If no SESS_ORDERNUM variable is available, the $itemnumrows variable is set to 0: $itemnumrows = mysql_num_rows($itemsres); } } if(isset($itemnumrows) && $itemnumrows == 0) { echo "You have not added anything to your shopping cart yet."; } else { echo "<table cellpadding='10'>"; echo "<tr>"; echo "<td></td>"; echo "<td><strong>Item</strong></td>"; echo "<td><strong>Quantity</strong></td>"; echo "<td><strong>Unit Price</strong></td>"; echo "<td><strong>Total Price</strong></td>"; echo "<td></td>"; echo "</tr>"; while($itemsrow = mysql_fetch_assoc($itemsres)) { $quantitytotal = $itemsrow['price'] * $itemsrow['quantity']; echo "<tr>"; if(empty($itemsrow['image'])) { echo "<td><img src='./productimages/dummy.jpg' width='50' alt='" . $itemsrow['name'] . "'></td>"; } else { echo "<td><img src='./productimages/" . $itemsrow['image'] . "' width='50' alt='" . $itemsrow['name'] . "'></td>"; } echo "<td>" . $itemsrow['name'] . "</td>"; echo "<td>" . $itemsrow['quantity'] . "</td>"; echo "<td><strong>£" . sprintf('%.2f', $itemsrow['price']) . "</strong></td>"; echo "<td><strong>£" . sprintf('%.2f', $quantitytotal) . "</strong></td>"; echo "<td>[<a href='" . $config_basedir . "delete.php?id=" . $itemsrow['itemid'] . "'>X</a>]</td>"; echo "</tr>"; $total = $total + $quantitytotal; $totalsql = "UPDATE orders SET total = " . $total . " WHERE id = " . $_SESSION['SESS_ORDERNUM']; $totalres = mysql_query($totalsql); } echo "<tr>"; echo "<td></td>"; echo "<td></td>"; echo "<td></td>"; echo "<td>TOTAL</td>"; echo "<td><strong>£" . sprintf('%.2f', $total) . "</strong></td>"; echo "<td></td>"; echo "</tr>"; echo "</table>"; echo "<p><a href='checkout-address.php'>Go to the checkout</a></p>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809529 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 oooo something new has appeared we are getting there slowly hehe Notice: Undefined variable: itemsres in C:\wamp\www\website\functions.php on line 72 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 72 Notice: Undefined variable: total in C:\wamp\www\website\functions.php on line 110 Item Quantity Unit Price Total Price TOTAL £0.00 Go to the checkout Your shopping cart Notice: Undefined index: SESS_USERID in C:\wamp\www\website\functions.php on line 30 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 33 Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 34 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\website\functions.php on line 39 Go to the checkout Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809531 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 lol your script is hard to read with everything being right up against the left margin. The script has countless problems, I recommend going through it all 1 line at a time, checking variables are set before they are called. It's mostly just the variables that aren't set, which are causing the problems. Make sure each variable is given a value, and if not, then make sure one is set. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809538 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 oh lol, I'm new to php and I have very limited knowledge. This script im following is a tutorial from a textbook but also have it as an ebook. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809545 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 is that the exact same as the textbook? or you altered it? lol Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809547 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 exactly the same as in the textbook, i could attach the ebook if you like? Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809555 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 lol textbook is wrong then. What exactly do you want the script to do? Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809562 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 It should display the shopping cart summary displays a current list of items and the ability to remove them. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809567 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 hmmm, it's not particularly hard to script. The script that you have there is just over complicating something that is rather simple. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809572 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 Books like to complicate things lol. So where do I go from here? Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809581 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 I suggest recoding it yourself starting off with the basics of selecting the data, once you know how that is achieved then you can move onto manipulating the data. on php.net read up on... - session_start(); - mysql_num_rows(); - mysql_fetch_array(); - mysql_query(); - if() { } - else { } - $_POST - $_GET - $variables - array() - echo they are the most basics parts of PHP that you will need. Then you can start putting them into practice. <?php // start the session session_start(); // check the user is logged in if(isset($_SESSION['userid'])) { // select the data from the MySQL tables, Limit how many records you select, Order By a column to organise the data $query = mysql_query("SELECT * FROM `orders`,`products`, `whatever` WHERE `something`='somethingelse' LIMIT 1 ORDER BY `somecolumn`") or die(mysql_error()); // if there is records if(mysql_num_rows($query) > 0) { // throw the results into an array $row = mysql_fetch_array($query); // display the products or whatever that you selected from the database above in the mysql_query(); echo $row['someTableColumn']; // if there is not any records } else { echo "There is no records"; } // if the user isn't logged in } else { echo "You are not logged in!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809587 Share on other sites More sharing options...
hass1980 Posted April 14, 2009 Author Share Posted April 14, 2009 Thanks MasterAce14 Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809697 Share on other sites More sharing options...
MasterACE14 Posted April 14, 2009 Share Posted April 14, 2009 no worries, if you run into troubles with your script feel free to PM me. Quote Link to comment https://forums.phpfreaks.com/topic/154000-parse-error/#findComment-809698 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.