Jump to content

Rayj00

Members
  • Posts

    18
  • Joined

  • Last visited

Rayj00's Achievements

Member

Member (2/5)

0

Reputation

  1. Appreciate your help. I only got more confused with your code...llike how does it call the php without a URL? I'll just keep digging I guess.
  2. So one thing I forgot....I already had a submit button. It's used to initialize the broadcaster stream and start the broadcast. <button onclick="startPublishing()" class="btn btn-info" disabled id="start_publish_button">Start Broadcasting</button> So how would your <button id="btnsend">Send Stream ID</button> integrate with what I have? Or can I just insert your code after the startPublishing() function?
  3. So hold on for a bit. I found something weird going on with my index page.
  4. And this is connUpdate.php: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "WebRTCApp"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stream1 = $_POST['streamId']; $sql = "UPDATE broadcast SET streamID='stream1' WHERE id=1"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?>
  5. This is the $.ajax: $.ajax({ type: 'POST', url: 'connUpdate.php', data: {streamId : streamId} )}.done(function(){ alert('AJAX was successfull!'); alert('Data to the server'); }).fail(function(){ alert('There was some error performing the AJAX call!'); });
  6. Sorry...I misunderstood. The html/javascript and $.ajax are all in the index.php file. I have a separate file for connecting and updating the database called connUpdate.php
  7. So, I said everything works WITHOUT the ajax code. How does that equate to my javascript being the culprit?
  8. So, are you saying the code I posted looks ok? Like I said. Everything works as coded...WITHOUT the ajax code. My only problem is with the ajax....which I have been trouble shooting for a few days now.
  9. Note that the above mentioned javascript is included, along with my html in a file called index.php.
  10. Sorry. I originally posted what I tried at that time. What I posted above is what I am trying to get to work right now. I am not getting any messages back. And the database is not updated.
  11. Here is my connUpdate.php: <?php $servername = "localhost"; $username = "root"; $password = "password"; $dbname = "WebRTCApp"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $stream1 = $_POST['streamId']; $sql = "UPDATE broadcast SET streamID='stream1' WHERE id=1"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . $conn->error; } $conn->close(); ?> And my javascript: $.ajax({ type: 'POST', url: 'connUpdate.php', data: {streamId : streamId} )}.done(function(){ alert('AJAX was successfull!'); alert('Data to the db was successfull!); }).fail(function(){ alert('There was some error performing the AJAX call!'); }); One thing that is really bugging me is I can never see or find any error logging. And yes, my php.ini file is configured for logging errors with E_ALL.
  12. For now I will only have the one record so id is not used. How do I update the streamId using ajax?
  13. So you have to bear with me as I am not a programmer or developer. I'm kinda learning as I go. But here is the database: mysql> SELECT * from broadcast; +----+----------+ | id | streamID | +----+----------+ | 1 | 23456 | +----+----------+ 1 row in set (0.00 sec) I need to update the streamID using, I assume, ajax.
  14. Right now I have only two records....Id, and streamID I want to update the steamId. So this is only one issue. Worse than this is I cannot seem to get a $.ajax to work! No matter what I try, I cannot see the ajax being executed?
×
×
  • 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.