Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by thenelson
at 2024-07-28 13:22:43
Point:500 Replies:18 POST_ID:828624USER_ID:11486
Topic:
PHP Scripting Language;Scripting Languages;Hypertext Markup Language (HTML)
I have a php script that calls a second php script. Using echo in the first script for example:
echo "</br>ALL NUMBERS COMPLETED!</br>";
displays in the browser. But using echo in the second php script does not display in the browser. How do I print a string in the second php script to the browser?
TIA
echo "</br>ALL NUMBERS COMPLETED!</br>";
displays in the browser. But using echo in the second php script does not display in the browser. How do I print a string in the second php script to the browser?
TIA
Accepted Solution
Expert: Ray Paseur replied at 2024-08-04 04:49:52
500 points EXCELLENT
July 29th,
I wrote: "...the "poll" script is not called directly by your code, but is instead passed to Twilio, where Twilio would read the output from the script (the XML document). I think that's why you're not seeing browser output from it -- because its output is supposed to go to Twilio and not to the browser."
August 4th,
I got an answer from Twilio tech support: "The other scripts used by your app, e.g. poll.php are executed by Twilio, so Twilio sees those echo statements. This is why you don't see them in your browser. Your browser only sees echo statements in the scripts that it executes."
Do you understand that these are equivalent answers?
I wrote: "...the "poll" script is not called directly by your code, but is instead passed to Twilio, where Twilio would read the output from the script (the XML document). I think that's why you're not seeing browser output from it -- because its output is supposed to go to Twilio and not to the browser."
August 4th,
I got an answer from Twilio tech support: "The other scripts used by your app, e.g. poll.php are executed by Twilio, so Twilio sees those echo statements. This is why you don't see them in your browser. Your browser only sees echo statements in the scripts that it executes."
Do you understand that these are equivalent answers?
Expert: duncanb7 replied at 2024-08-03 21:51:57
Thanks for sharing
Author: thenelson replied at 2024-08-03 21:50:03
The Twilio tech support guy suggested:
"If you want to view data from another script executing then you could save it to a file or database table, and then from your script (the one executing in your browser) read the file or database table.
This assumes that both scripts (the one executing in your browser and the one executing for Twilio) have access to the same file system or database."
A clumsy workaround but should work.
Thanks for your help.
"If you want to view data from another script executing then you could save it to a file or database table, and then from your script (the one executing in your browser) read the file or database table.
This assumes that both scripts (the one executing in your browser and the one executing for Twilio) have access to the same file system or database."
A clumsy workaround but should work.
Thanks for your help.
Author: thenelson replied at 2024-08-03 21:40:07
He did not provide a way around the problem. I asked. If he responds with a solution, I will share it.
Expert: duncanb7 replied at 2024-08-03 21:35:50
Could you send the code from Twilio tech support or your code to fix your issue for sharing ?
Author: thenelson replied at 2024-08-03 21:32:24
I've requested that this question be closed as follows:
Accepted answer: 0 points for thenelson's comment #a39380166
for the following reason:
Answer came from Twilio tech support.
Accepted answer: 0 points for thenelson's comment #a39380166
for the following reason:
Answer came from Twilio tech support.
Author: thenelson replied at 2024-08-03 21:31:18
I got an answer from Twilio tech support:
"The other scripts used by your app, e.g. poll.php are executed by Twilio, so Twilio sees those echo statements.
This is why you don't see them in your browser. Your browser only sees echo statements in the scripts that it executes."
"The other scripts used by your app, e.g. poll.php are executed by Twilio, so Twilio sees those echo statements.
This is why you don't see them in your browser. Your browser only sees echo statements in the scripts that it executes."
Expert: Ray Paseur replied at 2024-07-29 09:39:21
And here is "new patients"
<?phpsession_start();require 'Services/Twilio.php';date_default_timezone_set('US/Arizona');// Set our AccountSid and AuthToken$sid = 'xxx';$token = 'xxx';// List of phone numbers in associative array with patients name, type of referral, referrer's name$numbers = array( "8004278145"=>"Nelson.Hochberg,Pain Management,Doctor Seby",);// Instantiate a client to Twilio's REST API$client = new Services_Twilio($sid, $token);foreach ($numbers as $number=>$info){ try { $call = $client->account->calls->create ( '928-714-7090', // Caller ID $number, // Your friend's number // Location of your TwiML 'http://www.barnwellmd.com/twilio/poll.php?info=' . str_replace(' ', '$', $info) . '&number=' . $number, array('StatusCallback'=>'http://www.barnwellmd.com/twilio/callback.php', 'IfMachine'=>'Continue') ); echo "</br>Started call: " . $number . " Time: " . date("Y m j g:i a") . " - info: " . $info . "</br>"; file_put_contents ("response.txt", "Started call: " . date("Y m j g:i a") . " " . $number . " " . $info . PHP_EOL, FILE_APPEND); } catch (Exception $e) { echo 'Error starting phone call: ' . $e->getMessage() . ""; }}echo "</br>ALL NUMBERS COMPLETED!</br>";// @end snippet?> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:
As I follow this logic, it appears to me that the "poll" script is not called directly by your code, but is instead passed to Twilio, where Twilio would read the output from the script (the XML document). I think that's why you're not seeing browser output from it -- because its output is supposed to go to Twilio and not to the browser.
Expert: Ray Paseur replied at 2024-07-29 09:35:49
Here is poll.php
<?phpsession_start();require 'Services/Twilio.php';$response = new Services_Twilio_Twiml();$number = $_GET["number"];// greet the caller by nameif($info = str_replace('$', ' ', $_GET["info"])) { $temp = explode(",", $info); $name = $temp[0]; $typeproblem = $temp[1]; $referprovider = $temp[2]; $temp = explode(".", $temp[0]); $fname = $temp[0]; $lname = $temp[1]; } else { $name = ""; $typeproblem = 0; $fname = ""; $lname = ""; }if ($typeproblem == '8') { $typeproblem = '3'; $gname = "doctor " . $lname; } else { $gname = $fname; }$_SESSION['name'] = $name;$_SESSION['fname'] = $fname;$_SESSION['lname'] = $lname;$_SESSION['typeproblem'] = $typeproblem;$_SESSION['referprovider'] = $referprovider;$_SESSION['number'] = $number;$_SESSION['info'] = $info;echo "<?xml version="1.0" encoding="UTF-8"?><Response>";switch($_POST['AnsweredBy']){ case 'machine': ?> <Say loop="2"> Hello <?php echo $fname ?>. This is Doctor Jane Barnwells office calling for <?php echo $name ?> to schedule an appointment. Please call 9 2 8, 7 1 4, 5 5 5 5 to complete the new patient forma and schedule your appointment. Thank you. </Say> <?php file_put_contents ("response.txt", "Lft machine msg:" . date("Y m j g:i a") . " " . $number . " " . $info . PHP_EOL, FILE_APPEND); break; case 'human': file_put_contents ("response.txt", "Human: " . date("Y m j g:i a") . " " . $number . " " . $info . PHP_EOL, FILE_APPEND); break;}?> <Gather numDigits="1" action="process_poll.php" method="POST"> <Pause length="1"/> <Say>Hello <?php echo $fname ?>.</Say> <Pause length="1"/> <Say>This is Doctor Jane Barnwells office calling for" <?php echo $name ?> .</Say> <Pause length="1"/> <Say>If You Would Like me to wait while you get <?php echo $name ?> . Press 1.</Say> <Pause length="1"/> <Say>If You are " <?php echo $name ?> or can speak for <?php echo $name ?> . Press 2.</Say> <Pause length="1"/> <Say>If this is a wrong number for <?php echo $name ?> . Press 3.</Say> <Pause length="1"/> <Say loop="2">If this is an answering machine for <?php echo $name ?> . please call 9 2 8, 7 1 4, 5 5 5 5, to complete the new patient forms and schedule your appointment with Doctor Barnwell. Thank you.</Say> </Gather></Response> 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:
On line 42, it uses echo to write an XML document tag. When you use "view source" in your browser do you see this tag? Near line 60 it looks like it closes PHP and has some XML. These would be expected to go to the browser, unless there is something in the other script that is buffering this information.
Author: thenelson replied at 2024-07-29 09:22:06
call-new-patients.php is the first script and it calls poll.php.
The lines in call-new-patients.php that call poll.php are:
The lines in call-new-patients.php that call poll.php are:
$call = $client->account->calls->create( '928-714-7090', // Caller ID $number, // Your friend's number // Location of your TwiML 'http://www.barnwellmd.com/twilio/poll.php?info=' . str_replace(' ', '$', $info) . '&number=' . $number 1:2:3:4:5:6:
These are lines that call a routine at Twilio.com which in turn calls poll.php.
Notice I have two echo statements in call-new-patients.php. These show up in the browser window. I removed the echo statements from poll.php because they were not showing up in the browser window. I assume this is because call-new-patients.php is still displayed in the browser's url window and still has the browser window.
Notice I have two echo statements in call-new-patients.php. These show up in the browser window. I removed the echo statements from poll.php because they were not showing up in the browser window. I assume this is because call-new-patients.php is still displayed in the browser's url window and still has the browser window.
Expert: Ray Paseur replied at 2024-07-29 08:14:24
I see the upload now -- don't know how I missed it.
Anyway, we have one script called "new patients" and another called "poll", right? How do these scripts relate to one another?
Anyway, we have one script called "new patients" and another called "poll", right? How do these scripts relate to one another?
Author: thenelson replied at 2024-07-28 18:02:33
Ray_Paseur,
I uploaded the code.
I uploaded the code.
Expert: Ray Paseur replied at 2024-07-28 17:55:22
Let me try this question again...
Please show us the URL and the code...
We are only experts, not mind readers. If you can help us help you by giving us information it will be more likely to work out well for you. Really. Author: thenelson replied at 2024-07-28 16:17:54
mcnute,
I am not very knowledgeable in jQuery. Where in the first script do I put the code:
I am not very knowledgeable in jQuery. Where in the first script do I put the code:
$.ajax({url: 'second.php',success: function(data){$('body').append(data);}}); 1:2:3:4:5:6:
Do I just use an echo statement in the second script?
What do you mean by:
"It makes no sense to output the second script data after you close the html tag."
I have uploaded the two scripts. As you can see there is no actual html in either script. The second script does have TwiML: the Twilio Markup Language which is formatted similar to html.
BTW: The second script calls a third script and the third script calls a forth script. I assume I would put jQuery code in the first script to capture the other three scripts.
What do you mean by:
"It makes no sense to output the second script data after you close the html tag."
I have uploaded the two scripts. As you can see there is no actual html in either script. The second script does have TwiML: the Twilio Markup Language which is formatted similar to html.
BTW: The second script calls a third script and the third script calls a forth script. I assume I would put jQuery code in the first script to capture the other three scripts.
Expert: Ray Paseur replied at 2024-07-28 14:30:53
a php script that calls a second php script
Please show us the URL and the code that is involved in this process. Thanks, ~Ray Expert: mcnute replied at 2024-07-28 14:22:24
You'll need to do it with javascript/ajax in order to stay on your first site and pull data from the second asynchronously.
jQuery:
jQuery:
$.ajax({url: 'second.php',success: function(data){$('body').append(data);}}); 1:2:3:4:5:6:
It makes no sense to output the second script data after you close the html tag. The data from your second.php should go somewhere between the body tag. A p or a div anywhere there within. Just to let you know.
This assumes that you delete the meta refresh tag from your head also. Good Luck!
Author: thenelson replied at 2024-07-28 14:05:55
So using the <meta HTTP-EQUIV="refresh"...> tag will redirect the page to the new script but I assume the echo statements from the first script will then no longer display on the browser. I need some way that the first script can continue running and both scripts print to the browser. Is that possible?
Expert: duncanb7 replied at 2024-07-28 13:37:40
first php scipt including second script
First script, first.php
====================
<?php
echo "<p>everything you want form 1st php</p>";
// other coding here you want
?>
<html>
<head>
<meta HTTP-EQUIV="refresh" CONTENT="0" URL=http://yoursite/php/second.php>
</head>
<body>
<?php echo "<table><tr><td>How are you today </td></tr></table>"; ?>
</body>
</hmtl>
Second Script,second.php
============================
<?php
echo "second output ....heree......";
// other coding here you want
?>
So that is for all and you CAN control every php script easily or individually
Talk you later, bye bye
Duncan
First script, first.php
====================
<?php
echo "<p>everything you want form 1st php</p>";
// other coding here you want
?>
<html>
<head>
<meta HTTP-EQUIV="refresh" CONTENT="0" URL=http://yoursite/php/second.php>
</head>
<body>
<?php echo "<table><tr><td>How are you today </td></tr></table>"; ?>
</body>
</hmtl>
Second Script,second.php
============================
<?php
echo "second output ....heree......";
// other coding here you want
?>
So that is for all and you CAN control every php script easily or individually
Talk you later, bye bye
Duncan