Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Calling php function inside javascript function
Old 10-08-2010, 11:36 AM Calling php function inside javascript function
Skilled Talker

Posts: 83
Trades: 0
How can I call a PHP Function inside a Javascript Function? This is what I have so far, but I don't think I'm doing it the right way.
Any suggestions?

PHP Code:
<?php
function phpQuery(){

     
$query mysql_query("INSERT INTO mytable VALUES('','name','email')");

}
?>
<script type="text/javascript">
function delayQueries()
{
  timeoutID = window.setTimeout(doQueries, 2000);
}

function doQueries()
{
  var runQuery = "<?php phpQuery(); ?>";    
}
</script>
Smudly is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-08-2010, 11:50 AM Re: Calling php function inside javascript function
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
I dont think that will work.

However you could use ajax to call a separate .php file with the php sql query in it. ?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 10-08-2010, 10:14 PM Re: Calling php function inside javascript function
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
The javascript function will be executed by the clients browser, it seems you are lost in the "Server / client" relationship snafu. To execute a php function on the server you will have to send a request (probably ajax) for the page to the server, the php on the server will then need to return the results to the client browser. If you need some help message me and we can confer in a chat.
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Calling php function inside javascript function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12060 seconds with 12 queries