any good eyes

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

Post Reply
dbdvd7
Forum Newbie
Posts: 18
Joined: Fri Nov 17, 2006 2:33 pm

any good eyes

Post by dbdvd7 »

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";
 
 }
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Re: any good eyes

Post by Luke »

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 »

what the?
now it brought up an error on line 57 which is the

Code: Select all

if (isset($result)) {
Parse error: syntax error, unexpected '{' in /home/penguinp/public_html/extramediumapparel/membermu/addcart.php on line 57
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

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());
}
?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

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 »

that helped, i got it working now.
Post Reply