PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dbdvd7
Forum Newbie
Posts: 18 Joined: Fri Nov 17, 2006 2:33 pm
Post
by dbdvd7 » Thu Nov 30, 2006 1:57 pm
Can anyone see why I just get a blank page when this loads?
Code: Select all
require('./include/config.inc');
db_connect();
if ($_SERVER['REQUEST_METHOOD'] == "POST") {
$product_name = $_POST['product_name'];
$Small = $_POST['Small'] ;
$Medium = $_POST['Medium'];
$Large = $_POST['Large'];
$XLarge = $_POST['XLarge'];
}
mysql_connect("MYSQLHOST", "MYSQLUSER", "MYSQLPASS") ;
mysql_select_db("MYSQLDB") or die(mysql_error());
$sql="INSERT INTO CartItems (product_name, Small, Medium, Large, XLarge) VALUES
('$product_name','$Small','$Medium','$Large', '$XLarge',NOW()) WHERE (uid='$uid' AND pwd='$pwd')";
$result=mysql_query($sql) or die("insert fails");
if (isset($result)) {
echo "Items Added Successfully";
} else {
echo "Error. Contact Admin";
}
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Thu Nov 30, 2006 1:59 pm
Run this and see what happens...
Code: Select all
require('./include/config.inc');
db_connect();
if ($_SERVER['REQUEST_METHOOD'] == "POST") {
$product_name = $_POST['product_name'];
$Small = $_POST['Small'] ;
$Medium = $_POST['Medium'];
$Large = $_POST['Large'];
$XLarge = $_POST['XLarge'];
}
mysql_connect("MYSQLHOST", "MYSQLUSER", "MYSQLPASS") ;
mysql_select_db("MYSQLDB") or die(mysql_error() . 'THERE WAS AN ERROR SELECTING YOUR DATABASE');
$sql="INSERT INTO CartItems (product_name, Small, Medium, Large, XLarge) VALUES
('$product_name','$Small','$Medium','$Large', '$XLarge',NOW()) WHERE (uid='$uid' AND pwd='$pwd')";
$result=mysql_query($sql) or die("insert fails");
if (isset($result)) {
echo "Items Added Successfully";
} else {
echo "Error. Contact Admin";
}
dbdvd7
Forum Newbie
Posts: 18 Joined: Fri Nov 17, 2006 2:33 pm
Post
by dbdvd7 » Thu Nov 30, 2006 2:05 pm
what the?
now it brought up an error on line 57 which is the
Parse error: syntax error, unexpected '{' in /home/penguinp/public_html/extramediumapparel/membermu/addcart.php on line 57
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Thu Nov 30, 2006 3:04 pm
Try this...
Code: Select all
<?php
require './include/config.inc';
db_connect();
if ($_SERVER['REQUEST_METHOOD'] == "POST") {
$product_name = $_POST['product_name'];
$Small = $_POST['Small'] ;
$Medium = $_POST['Medium'];
$Large = $_POST['Large'];
$XLarge = $_POST['XLarge'];
}
mysql_connect("MYSQLHOST", "MYSQLUSER", "MYSQLPASS") or die(mysql_error());
mysql_select_db("MYSQLDB") or die(mysql_error());
$sql = "INSERT INTO CartItems (product_name, Small, Medium, Large, XLarge)
VALUES ('$product_name','$Small','$Medium','$Large', '$XLarge', NOW()) WHERE (uid='$uid' AND pwd='$pwd')";
if (!mysql_query($sql) || !mysql_affected_rows()) {
die("insert fails: " . mysql_error());
}
?>
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Nov 30, 2006 3:04 pm
Then we need the first 57 lines of code.
dbdvd7
Forum Newbie
Posts: 18 Joined: Fri Nov 17, 2006 2:33 pm
Post
by dbdvd7 » Thu Nov 30, 2006 3:23 pm
that helped, i got it working now.