So here is the ajax code located in the startPublishing() function:
- streamId = randomToken
- $.ajax({
type: "POST",
url: "connUpdate.php",
data: 'stream=' +streamId,
success: function(response)
{
alert("Record updated");
}
});
here is connUpdate.php
- <?php
// Create connection
$link = mysqli_connect("localhost", "root", "1*General", "WebRTCApp");
// Check connection
// if ($link === false) {
// die("Connection failed: " . mysqli_error());
//}
$streamx = $_POST['stream'];
$sql = "UPDATE broadcast SET streamID = '$streamx' WHERE id=1";
mysqli_query($link, $sql);
if($link->query($sql)===TRUE){
echo "Record updated successfully!";
} else {
echo "Error: Not able to execute $sql. " . mysqli_error($link);
}
mysqli_close($link);
?>
I have a this: <button onclick="startPublishing()" class="btn btn-info" disabled
id="start_publish_button">Start Broadcasting</button>
My code prior to add the ajax works fine. It basically starts up a webrtc video stream, which is what it is meant to do.
The ajax that I am trying to get to work should update a database record with the streamId just before the video is displayed, however it is not working for some reason?
Do you see anything wrong with the ajax and php code I am using?
When I click the button, the video stream starts and I can see it. Which means the startPublishing function was entered. However, the database is never updated.
I'm pulling my hair out over this...
PS: I am not a programmer or developer per-se....more less a dabbler so have mercy on me...
Another thing is I've been dicking around with this for days and have never seen anything in any log file.
I believe I have php logging set up correctly.
Thanks,
Ray