473,473 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to call function

93 New Member
Hi

I have a function call getMovieLength. How do I call the function so that I can calculate the $cellwidth variable in the php code below. It shows error message like below
"Notice: Use of undefined constant movieLength - assumed 'movieLength' in C:\htdocs\..\MB2search.php on line 779
Warning: Division by zero in C:\htdocs\..\MB2search.php on line 784"


[HTML]
$movie = $db->get_row("select * from Movie where movieID='" . $_GET['movieID'] . "'");
....
....

function getMovieLength(lengthString) {
times = lengthString.split(':');
return (((parseInt(times[0]) * 60) + parseInt(times[1])) * 60) + parseInt(times[2]);
}

...
...
var movieLength = getMovieLength("<?php echo $movie->duration?>");
...
...
[/HTML]

[PHP]
<?php

$allEvents = $db->get_results("SELECT * FROM EventsShotsStartAndStopFrames where movieID='" . $_GET['movieID'] . "' and eventCategory = 'Dialogue'");
$prevTime = 0;
$movieLengthTimeline = (movieLength * 30);

foreach($allEvents as $timeline)
{
$frameDuration = ($timeline->shotStartFrame) - $prevTime;
$cellwidth = round(($frameDuration * 650)/ $movieLengthTimeline);//round here
?>

<td width="<?php echo ($cellwidth); ?>" height="17" bgcolor=black></td>

<?php
$frameDuration = ($timeline->shotStopFrame) - ($timeline->shotStartFrame);
$cellwidth = round(($frameDuration * 650)/ $movieLengthTimeline);//round here

?>

<td width="<?php echo ($cellwidth); ?>" height="17" bgcolor=green></td>
<?php
$prevTime = ($timeline->shotStopFrame);
}
?>
[/PHP]
Jan 24 '08 #1
6 1443
code green
1,726 Recognized Expert Top Contributor
PHP is assuming that movieLength is a constant because it is not a variable
[PHP]$movieLengthTimeline = (movieLength * 30);[/PHP] What is it meant to be?
Jan 25 '08 #2
nma
93 New Member
Hi

It is actually calling a javascripts function into a php code..but I am not sure how to write it

Thanks
Jan 25 '08 #3
Atli
5,058 Recognized Expert Expert
Hi.

It is not possible to call Javascript functions in your PHP code, or PHP functions in Javascript code.
(Unless you use AJAX, but that's a whole other topic)

This is because the Javascript code is execute on the client's browsers (client-side) while the PHP code is executed on the server (server-side) before the code is sent to the browser.

The only way to have PHP call a Javascript function is to print the function call as Javascript code to the browser, but it can not directly interact with the Javascript code.
Jan 25 '08 #4
Amzul
130 New Member
Expand|Select|Wrap|Line Numbers
  1. var movieLength = getMovieLength("<?php echo $movie->duration?>");
Expand|Select|Wrap|Line Numbers
  1. $movieLengthTimeline = (movieLength * 30);
u cant, (i am sure 99.9999% server / client)
its a js var, data from php. so just try do:

Expand|Select|Wrap|Line Numbers
  1. $movieLengthTimeline = ($movie->duration * 30); 
if its possible
Jan 25 '08 #5
Atli
5,058 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. var movieLength = getMovieLength("<?php echo $movie->duration?>");
Expand|Select|Wrap|Line Numbers
  1. $movieLengthTimeline = (movieLength * 30);
u cant, (i am sure 99.9999% server / client)
its a js var, data from php. so just try do:

Expand|Select|Wrap|Line Numbers
  1. $movieLengthTimeline = ($movie->duration * 30); 
if its possible
That won't work, as the PHP $movie->duration variable is supposed to be run through the Javascript function and the result returned into PHP via the Javascript variable.

The easiest solution to this problem is to re-write the Javascript function as a PHP function.
Jan 25 '08 #6
nma
93 New Member
Hi All

I solve the problem...I write the functions again in php and put before the running lines code inside the php and it works

Is it ok if i put that php functions anywhere in php codes ?

Thanks
Jan 26 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another...
3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
4
by: Dave | last post by:
I have a program that I've written a class for. I need to call the function in the program from the class. When I try to call the function I receive the error, the name xxx does not exist in the...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
11
by: yangsuli | last post by:
i want to creat a link when somebody click the link the php script calls a function,then display itself :) i have tried <a href=<? funtion(); echo=$_server ?>text</a> but it will call the...
46
by: Steven T. Hatton | last post by:
I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it says. http://java.sun.com/docs/books/tutorial/essential/concurrency/syncrgb.html <shrug> -- NOUN:1. Money or...
0
by: Mike S | last post by:
I've seen examples of using the CallWindowProc Windows API function to call functions through their addresses in VB6 -- a clever workaround to emulate C-like function pointer semantics. A...
9
by: CryptiqueGuy | last post by:
Consider the variadic function with the following prototype: int foo(int num,...); Here 'num' specifies the number of arguments, and assume that all the arguments that should be passed to this...
6
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.