Jump to content

vet911

Members
  • Content Count

    98
  • Joined

  • Last visited

Community Reputation

0 Neutral

About vet911

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. That is what I figured out because when I took it back out of the code it was working as before. I haven't been able to figure it out sense. I'll continue to work at it some more. Thanks
  2. I did get an error message: 500 Internal Server Error. I removed the important info from the paypal hidden stuff. What I tried to do was check the $row['sold'] value to see if it was sold. 1= sold, 0 = not sold. It works, but not the way I would like. I was trying some different things that's why the commented out stuff.
  3. $result = $dbh->query($sql); if($result) { $i = 0; $max_columns = 3; foreach ($result as $row) { // open row if counter is zero if($i == 0) { echo "<tr VALIGN='top'>"; } // if ($row['avail'] != "0") //{ // make sure we have a valid product ALIGN='CENTER' if($row['image'] != "" && $row['image'] != null) { echo "<td><div class=box><a href=$row[image] rel=lightbox title=$row[image]><img class=border src=$row[image]>"; if($row['itemno'] != "" && $row['itemno'] != null) { echo "<a>Item No: </a>$row[itemno]<br />"; } if($row['description'] != "" && $row['description'] != null) { echo "<a>Description: </a>$row[description]<br /> "; } //if($row['sold'] !=1) //{ if($row['price'] != "" && $row['price'] != null) { echo "<a>Price: $</a>$row[price]<br />"; echo "<form target='paypal' action='' method='post'>"; echo "<input type='hidden' name='cmd' value='_cart'>"; echo "<input type='hidden' name='add' value='1'>"; echo "<input type='hidden' name='business' value=''>"; echo "<input type='hidden' name='item_name' value='$row[description]'>"; echo "<input type='hidden' name='item_number' value='$row[itemno]'>"; echo "<input type='hidden' name='amount' value='$row[price]'>"; echo "<input type='hidden' name='shipping' value='7.00'>"; echo "<input type='hidden' name='shipping2' value='0.50'>"; echo "<input type='hidden' name='handling' value='2.00'>"; echo "<input type='hidden' name='currency_code' value='USD'>"; echo "<input type='hidden' name='return' value=''>"; echo "<input type='hidden' name='undefined_quantity' value='1'>"; echo "<input type='image' src='' height='21' border='0' name='submit' alt=''>"; echo "</form>"; } //else($row['sold'] !=0) //{ //echo "<img src='images/sold.png'>"; //} //} //echo "</form>"; } echo "</div></td>"; // } // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) { echo "<td>&nbsp;</td>"; } } } My website shows items listed from the database with a picture and associated information including a icon to make the purchase. I want to show the item as sold after the purchase and not the hidden info that is sent to aPayapl to make the purchase. I would like show the item as sold and attach a sold icon but eliminate the paypal hidden info. I tried but when I run the program it breaks. I tried to comment out the stuff i tried. I need some help please. Thanks in advance for any help.
  4. I have to say you are the man. I have looked at that sense this morning when I made the post about being lost. I can honestly say I did not see those dollar signs. I appreciate all your help. Something else has been in my thoughts, I have a sign up page and after you login it brings you to a form which is blank. I want people to be able to change their own stuff. If they did it right the would have to fill out, name address, city, state, phone before they cold save that page without filling in the rest of the form. What I'm thinking, is there a way to see if they filled out the partial required form and if so it will load that info and they would be able to fill in the rest or update it at a later time? Thanks for your help.
  5. Ok so this is what I have now. <?php try { { /*** mysql hostname ***/ $hostname = 'localhost'; /*** mysql username ***/ $username = 'xxxx'; /*** mysql password ***/ $password = ''; $dbname = 'dblogin'; $dhb = null; $dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true ); /***echo a message saying we have connected***/ echo "connected"; $get_id=$_REQUEST['id']; $registerStmt = $dbh->prepare(' UPDATE register SET fname = :fname, lname = :lname, address = :address, city = :city, state = :state, zip = :zip, phone = :phone, large = :large, lsize = :lsize, lmatl = :lmatl, medium = :medium, msize = :msize, mmatl = :mmatl, small = :small, ssize = :ssize, smatl = :smatl, desc1 = :$desc1, desc2 = :$desc2, desc3 = :$desc3 WHERE id = :id '); $registerStmt->execute([ 'fname' => $_POST['fname'], 'lname' => $_POST['lname'], 'address' => $_POST['address'], 'city' => $_POST['city'], 'state' => $_POST['state'], 'zip' => $_POST['zip'], 'phone' => $_POST['phone'], 'large' => $_POST['large'], 'lsize' => $_POST['lsize'], 'lmatl' => $_POST['lmatl'], 'medium' => $_POST['medium'], 'msize' => $_POST['msize'], 'mmatl' => $_POST['mmatl'], 'small' => $_POST['small'], 'ssize' => $_POST['ssize'], 'smatl' => $_POST['smatl'], 'desc1' => $_POST['desc1'], 'desc2' => $_POST['desc2'], 'desc3' => $_POST['desc3'], 'id' => $get_id, ]); } } catch(PDOException $e) { echo $e->getMessage(); } ?> And this is the error message. SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens I counted all the variables and tokens and I think they match, so am I wrong?
  6. Thanks for the reply, like the Bobby Tables but still lost on how to do it. I'm really lost.
  7. This is the error I'm getting. Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'xxx', desc2 ='xx', desc3 ='x' WHERE id = '1'' at line 15' in This is my code: require_once('connect.php'); $get_id=$_REQUEST['id']; $fname = $_POST['fname']; $lname = $_POST['lname']; $address = $_POST['address']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $phone = $_POST['phone']; $large = $_POST['large']; $lsize = $_POST['lsize']; $lmatl = $_POST['lmatl']; $medium = $_POST['medium']; $msize = $_POST['msize']; $mmatl = $_POST['mmatl']; $small = $_POST['small']; $ssize = $_POST['ssize']; $smatl = $_POST['smatl']; $desc1 = $_POST['desc1']; $desc2 = $_POST['desc2']; $desc3 = $_POST['desc3']; $sql = "UPDATE register SET fname ='$fname', lname ='$lname', address ='$address', city ='$city', state ='$state', zip ='$zip', phone ='$phone', large ='$large', lsize ='$lsize', lmatl ='$lmatl', medium ='$medium', msize ='$msize', mmatl ='$mmatl', small ='$small, ssize ='$ssize', smatl ='$smatl', desc1 ='$desc1', desc2 ='$desc2', desc3 ='$desc3' WHERE id = '$get_id' "; $dbh->exec($sql); If you could give me some direction to figure this out it would be appreciated. Thanks in advance for your time.
  8. Hi, I found out the problem, the error was generating and shown at the bottom of the page. I have sense figured out that the password was incorrect. I changed that and now it works. I want to correct the script so it's not supplying directly to the database as mentioned in the reply from "benanamen" but not sure how to do that. Do I have to remove the script from the form page and have the form call the script to insert the data to the database? I have done this before but not recently. Any help would be appreciated. Thanks to all who replied.
  9. This is what is shown in the html file after the process completes. <script src="bootstrap/js/bootstrap.min.js"></script> SQLSTATE[HY000] [1045] Access denied for user 'xxxxxx'@'localhost' (using password: YES) </body> </html>
  10. I'm not seeing any error messages. The page refreshes back to the blank form. Thanks for the feedback.
  11. I have enclosed all the form below, this worked fine on localhost that's why I was surprised it didn't work. <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" media="screen"> <script type="text/javascript" src="jquery-1.11.3-jquery.min.js"></script> <link rel="stylesheet" href="style.css" type="text/css" /> <link rel="stylesheet" href="style_test.css" type="text/css" /> <title></title> </head> <body> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="http://www.php">About</a></li> <li><a href="http://guidelines.php">Guidelines</a></li> <!--<li><a href="http://home.php">Back</a></li> --> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="logout.php?logout=true"><span class="glyphicon glyphicon-log-out"></span> Log Out</a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> <div class="clearfix"></div> <!-- <div class="container-fluid" style="margin-top:80px;"> <div class="container"> --> <div class="container-fluid text-center" style="margin-top:80px;"> <div class="row content"> <div class="col-sm-3 sidenav"> </div> <div class="col-sm-6 text-left"> <!--<div> --> <h2>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</h2> <div id="fillout"> <h2>Please fill out form.</h2> <hr/> <form action="" method="post"> <label>First Name:</label> <input type="text" name="fname" id="fname" required="required" placeholder="First Name"/><br /><br /> <label>Last Name:</label> <input type="text" name="lname" id="email" required="required" placeholder="Last Name"/><br/><br /> <label>Address:</label> <input type="text" name="address" id="address" required="required" placeholder="Address"/><br/><br /> <label>City:</label> <input type="text" name="city" id="address" required="required" placeholder="City"/><br/><br /> <label>State:</label> <input type="text" name="state" id="state" required="required" placeholder="State"/><br/><br /> <label>Zip Code:</label> <input type="text" name="zip" id="zip" required="required" placeholder="Zip Code"/><br/><br /> <label>Phone:</label> <input type="text" name="phone" id="phone" required="required" placeholder="603-111-2222"/><br/><br /> <label>Large:</label> <input type="text" name="large" id="large" placeholder="21mm & up"/><br/><br /> <label>Cut:</label> <input type="text" name="lsize" id="lsize" placeholder="Hexagon"/><br/><br /> <label>Material:</label> <input type="text" name="lmatl" id="lmatl" placeholder="Aquamarine"/><br/><br /> <label>Medium:</label> <input type="text" name="medium" id="medium" placeholder="11mm - 20mm"/><br/><br /> <label>Cut:</label> <input type="text" name="msize" id="msize" placeholder="Round"/><br/><br /> <label>Material:</label> <input type="text" name="mmatl" id="mmatl" placeholder="Smokey Quartz"/><br/><br /> <label>Small:</label> <input type="text" name="small" id="small" placeholder="1mm - 10mm"/><br/><br /> <label>Cut:</label> <input type="text" name="ssize" id="ssize" placeholder="Trillion"/><br/><br /> <label>Material:</label> <input type="text" name="smatl" id="smatl" placeholder="Peridot"/><br/><br /> <label>Cab or Carving 1:</label> <input type="text" name="desc1" id="desc1" placeholder="Description 1"/><br/><br /> <label>Cab or Carving 2:</label> <input type="text" name="desc2" id="desc2" placeholder="Description 2"/><br/><br /> <label>Cab or Carving 3:</label> <input type="text" name="desc3" id="desc3" placeholder="Description 3"/><br/><br /> <input type="submit" value=" Save Form " name="submit"/><br /> </form> </div> <!--</form>--> <!-- </div> --> <div class="col-sm-3 sidenav"> </div> </div> </div> <script src="bootstrap/js/bootstrap.min.js"></script> <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if(isset($_POST["submit"])){ $hostname='XXXX'; $username='XXXX16'; $password='XXXX16'; try { $dbh = new PDO("mysql:host=$hostname;dbname=dblogin",$username,$password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line $sql = "INSERT INTO register (fname, lname, address, city, state, zip, phone, large, lsize, lmatl, medium, msize, mmatl, small, ssize, smatl, desc1, desc2, desc3) VALUES ('".$_POST["fname"]."','".$_POST["lname"]."','".$_POST["address"]."','".$_POST["city"]."','".$_POST["state"]."','".$_POST["zip"]."','".$_POST["phone"]."','".$_POST["large"]."','".$_POST["lsize"]."','".$_POST["lmatl"]."','".$_POST["medium"]."','".$_POST["msize"]."','".$_POST["mmatl"]."','".$_POST["small"]."','".$_POST["ssize"]."','".$_POST["smatl"]."','".$_POST["desc1"]."','".$_POST["desc2"]."','".$_POST["desc3"]."')"; if ($dbh->query($sql)) { echo "<script type= 'text/javascript'>alert('New Record Inserted Successfully');</script>"; } else{ echo "<script type= 'text/javascript'>alert('Data not successfully Inserted.');</script>"; } $dbh = null; } catch(PDOException $e) { echo $e->getMessage(); } } ?> </body> </html>
  12. I'm having trouble sending data to database, nothing apprear in table and no error messages. Below is the file I'm using. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if(isset($_POST["submit"])){ $hostname='xxxxxx'; $username='xxxxxx'; $password='xxxx'; try { $dbh = new PDO("mysql:host=$hostname;dbname=dblogin",$username,$password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // <== add this line $sql = "INSERT INTO register (fname, lname, address, city, state, zip, phone, large, lsize, lmatl, medium, msize, mmatl, small, ssize, smatl, desc1, desc2, desc3) VALUES ('".$_POST["fname"]."','".$_POST["lname"]."','".$_POST["address"]."','".$_POST["city"]."','".$_POST["state"]."','".$_POST["zip"]."','".$_POST["phone"]."','".$_POST["large"]."','".$_POST["lsize"]."','".$_POST["lmatl"]."','".$_POST["medium"]."','".$_POST["msize"]."','".$_POST["mmatl"]."','".$_POST["small"]."','".$_POST["ssize"]."','".$_POST["smatl"]."','".$_POST["desc1"]."','".$_POST["desc2"]."','".$_POST["desc3"]."')"; if ($dbh->query($sql)) { echo "<script type= 'text/javascript'>alert('New Record Inserted Successfully');</script>"; } else{ echo "<script type= 'text/javascript'>alert('Data not successfully Inserted.');</script>"; } $dbh = null; } catch(PDOException $e) { echo $e->getMessage(); } } ?>
  13. $getid = $_POST['id']; $getitemno = $_POST['itemno']; $getavailability = $_POST['availability']; // Connect to server and select database. try { echo "$getitemno"; // UPDATE data $sql = "UPDATE cut_stones SET itemno= :itemno, availability= :availability WHERE id= :id"; $stmt = $dbh->prepare($sql); $stmt->bindParam(':id', $_POST['id'], PDO::PARAM_INT); $stmt->bindParam(':itemno', $_POST['itemno'], PDO::PARAM_STR); $stmt->bindParam(':availability', $_POST['availability'], PDO::PARAM_INT); $stmt->execute(); } catch(PDOException $e) { echo $e->getMessage(); } // if successfully updated. $dhb = null; echo " Updated"; I figured it out. I have listed the code above. Thanks for the help.
  14. I updated the code, I don't get any error message. But when I look at the database it doesn't change availability to (0). Still lost. try { echo "$getitemno"; // UPDATE data $sql = "UPDATE cut_stones SET itemno= :itemno, availability= :availability WHERE id= :id"; $stmt = $dbh->prepare($sql); $stmt->bindParam(':id', $_POST['$id'], PDO::PARAM_INT); $stmt->bindParam(':itemno', $_POST['$itemno'], PDO::PARAM_STR); $stmt->bindParam(':availability', $_POST['availability'], PDO::PARAM_INT); $stmt->execute(); } catch(PDOException $e) { echo $e->getMessage(); } // if successfully updated. $dhb = null; echo " Updated"; ?>
  15. I'm trying to update the itemno specified from available (1) to (0). I'm getting this error message and can't seem to figure it out. I must be missing something really easy. Any help would be appreciated. This is the error message: connected tv-jw10-976 SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='78'' at line 5 Updated $getid = $_POST['id']; $getitemno = $_POST['itemno']; $getavailability = $_POST['availability']; try { echo "$getitemno"; // UPDATE data $sql = "UPDATE cut_stones SET itemno= :itemno, availability= :availability, WHERE id='$getid'"; $stmt = $dbh->prepare($sql); $stmt->bindParam(':itemno', $_POST['$itemno'], PDO::PARAM_STR); $stmt->bindParam(':availability', $_POST['availability'], PDO::PARAM_INT); $stmt->execute(); } catch(PDOException $e) { echo $e->getMessage(); } // if successfully updated. $dhb = null; echo " Updated"; ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.