473,767 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling a php function

I am trying to call a function from "a href" inside the same page.
this is the code:
echo "<br><br><a href=\"isearch( $query)\">More results from
Mysite</a>";
// calling the function isearch

function isearch($query)

{$query=urlenco de($query);

$request='http://api.search.yaho o.com/WebSearchServic e/V1/webSearch?appid =Ja
hangir&query=' .urlencode($que ry).
'&output=php&re sults=100&site= mysite.com;

$response=file_ get_contents($r equest);

if ($response === false) {

die('Request failed');}

$phpobj=unseria lize($response) ;

$count=$phpobj["ResultSet"]["totalResultsRe turned"];

if($phpobj["ResultSet"]["totalResultsAv ailable"]==0)

{echo "<br>NO RESULTS TO DISPLAY"; }

echo "<tr>"; echo "<h4 style=\"color:# FF0000\" align=\"center\ ">Results
from
Mysite</h4>";

for($i=0;$i<$co unt;$i++)

{ echo '<pre>';

$no=$i+1;

$url=$phpobj["ResultSet"]["Result"]["$i"]["Url"];

echo "<h3>" ."$no. ". "<a href=\"$url\">" .
$phpobj["ResultSet"]["Result"]["$i"]["Title"] . "</a></h3>"; echo
"</tr>";

echo "<tr>"; echo $phpobj["ResultSet"]["Result"]["$i"]["Summary"]; echo
"</tr>";

echo "<br>"; echo "<tr>"; echo "<b>"
..$phpobj["ResultSet"]["Result"]["$i"]["Url"] ."</b>"; echo "</tr>";

echo "<br>"; $link=$phpobj["ResultSet"]["Result"]["$i"]["DisplayUrl "];

echo "<tr>"; echo "<a href=\"$url\">$ link</a>"; echo "</tr>";

echo '</pre>'; }}

whenever i try to execute this function i either get an "Object not
found
error" or "Access Forbidden error".

Can someone tell me where am i going wrong here??

thanks in advance

Dec 24 '06 #1
3 2515
no
thecoolone wrote:
I am trying to call a function from "a href" inside the same page.
this is the code:
echo "<br><br><a href=\"isearch( $query)\">More results from

you must break a string to call a function.
try this:

echo "<br><br><a href=\"" . isearch($query) . "\">More results from
Mysite</a>";
Dec 24 '06 #2
no
oh, yeah
and first write your function

function isearch() {
....

}

and then call the

echo "<br><br><a href=\"" . isearch($query) . "\">More results from
Mysite</a>";
Dec 24 '06 #3

thecoolone wrote:
I am trying to call a function from "a href" inside the same page.
this is the code:
echo "<br><br><a href=\"isearch( $query)\">More results from
It's not clear what you're wanting to do.
a) Do you want a link that executes/calls isearch?
b) Or, do you want the href link/value to contain the results of
isearch?

I'm thinking you want (a). If so, try something like this:
echo '<br><br><a
href="?action=s earch&amp;query ='.urlencode($q uery).'">More
results</A>';

then you'd need to add some code to your page likey so:

if ( isset($_GET['action']) && $_GET['action'] == 'search' )
{
if ( !empty($_GET['query']) )
isearch($_GET['query']);
}

Dec 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2963
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int p3); The parameters here can be read either in the forward order from p1 till p3 or reverse order from p3 till p1. Can anyone explain what is the advantage/disadvantage of either of
6
3310
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference in VBA from my other Access applications. This works fine and I'm quite happy with it... except for one area; error handling. In most of my functions I call an error handler which
14
3011
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
1
2914
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same source file!), the app reports an "unknown exception" error.
5
3435
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS 5), but fails on IIS 6 running on a Win2003 server. The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide some common functionality. The Page_Load handler the failing webpage starts out like this: ...
2
3150
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean the stack pointer and it does it by the command "add esp,8" after returning from the called function. My questions: 1. Is the stack pointer common in a certain thread(or process)? 2. How does the called function get the parameters, is it by...
18
4357
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I can use dlopen/whatever to convert the function name into a pointer to that function, but actually calling it, with the right number of parameters, isn't easy. As far as I can see, there are only two solutions: 1) This one is portable. If...
15
22859
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which could either be f1() or f2(). BRs!
11
3200
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to define nor pass this reference correctly to the legacy DLL. What am I doing wrong? Thanks in...
16
517
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both and my c++ code should call c code.but when i tried to call a function in c code externing that function in my c++ code, i am getting unresolved external symbol error. Whatever i try its giving more and more errrors...so is it possible to merge 2...
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9405
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10013
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9841
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7383
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3930
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 we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.