Jump to content

vet911

Members
  • Content Count

    95
  • Joined

  • Last visited

Community Reputation

0 Neutral

About vet911

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. 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.
  2. 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?
  3. Thanks for the reply, like the Bobby Tables but still lost on how to do it. I'm really lost.
  4. 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.
  5. 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.
  6. 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>
  7. I'm not seeing any error messages. The page refreshes back to the blank form. Thanks for the feedback.
  8. 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>
  9. 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(); } } ?>
  10. $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.
  11. 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"; ?>
  12. 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"; ?>
  13. Thanks for the help. I was using $row before I started to use the array. I have changed it to your suggestion and now it works. I really do appreciate your help and all others who gave their comments.
  14. Thank you Barand for responding. I put the [ ] in place where you suggested. Now I have the exact number of pictures that are in the database under ia listing. But they are all the same #14. I believe I have the multidimensional array code in the wrong place. Is this true?
  15. Thanks for the reply. I only want (1) label. the way I want it shown is in the pictures shown.(original1.jpg is from the original file posted. (array.jpg is what I am getting from the array) I don't know how to get all the data into the array. Help would be appreciated. No sure if the pictures will show up, the original posted were png file and they didnt show. The label "Gypsum City OHRV Park, ort Dodge, IA 2015" is for all the pictures below it.
×
×
  • 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.