-3

I want to capture image from webcam user image that image stored in specified folder and captured image path store into mysql using php. I have an problem with webcam captured image path is not stored in mysql database. so please help me...

<script src="webscript.js"></script>

 <!-- First, include the Webcam.js JavaScript Library -->
 <script type="text/javascript" src="webcam.min.js"></script>
 <script type="text/javascript" src="script.js"></script>
 
 <!-- Configure a few settings and attach camera -->
 <script language="JavaScript">
  Webcam.set({
   width: 320,
   height: 240,
   image_format: 'jpeg',
   jpeg_quality: 90
  });
  Webcam.attach( '#my_camera' );
  
  var shutter = new Audio();
  shutter.autoplay = false;
  shutter.src = navigator.userAgent.match(/Firefox/) ? 'shutter.ogg' : 'shutter.mp3';
  
  function take_snapshot() {
   // take snapshot and get image data
   Webcam.snap( function(data_uri) {
    // display results in page
    document.getElementById('results').innerHTML = 
     '<h2>Here is your image:</h2>' + 
     '<img src="'+data_uri+'"/>';
                                Webcam.upload( data_uri, 'upload.php', function(code, text) {
                                           alert(data_uri);
                                });
   } );
  }
  
 </script>
<?php
include 'connection.php';  

    // be aware of file / directory permissions on your server
    $newname = move_uploaded_file($_FILES['webcam']['tmp_name'], 'uploads/webcam'.date('YmdHis').rand(383,1000).'.jpg');
    $query = "INSERT INTO entry(name) VALUES('".$_GET['url']."')";
    mysql_query($query)or die(mysql_error());
 echo "<script>alert('successfully..');</script>";

?>
<!DOCTYPE html>
<html>
<head>
<title>Javascript Webcam</title>
<link href="font-awesome.min.css" rel="stylesheet"/>
<link href="bootstrap.min.css" rel="stylesheet"/> 
</head>
<body>
<center>
<div class="row">
 <div class="col-md-6"> 
 <h3>Profile Picture</h3>
 <div id="my_camera"></div>
 <!-- A button for taking snaps -->
 <form>
  <input type=button class="btn btn-success" value="Take Snapshot" onClick="take_snapshot()">
 </form>
 <div id="results" class="well">Your captured image will appear here...</div>
 </div>
</div>
</center>

 
</body>
</html>
Dnyanesh
  • 75
  • 1
  • 9
  • are `$dis, $limit` variables from php? yes then `" SELECT * FROM bed limit ". $dis.",". $limit . "` – Bender Jan 07 '15 at 04:11
  • @lemon your second sentence is irrelevant, have a look at http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php – user221931 Jan 07 '15 at 04:19

1 Answers1

0

Assuming $mysqli is a successfully connected [new Mysqli] object.

$query = "SELECT * FROM 'database.table' WHERE 'somecolumn'='someval' LIMIT= 5";

if ($stmt = $mysqli->prepare($query)) {

/* execute statement */
$stmt->execute();

/* bind result variables */
$stmt->bind_result($name, $code);

/* fetch values */
while ($stmt->fetch()) {
    printf ("%s (%s)\n", $name, $code);
}

/* close statement */
$stmt->close();
Rasclatt
  • 12,498
  • 3
  • 25
  • 33
ZenStein
  • 151
  • 7