Jump to content


Photo

Fix my syntax please


  • Please log in to reply
4 replies to this topic

#1 Orphy

Orphy
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 March 2006 - 04:08 PM

<HEAD>
<TITLE>Test page</TITLE>
</HEAD>
<BODY>


<FORM METHOD="get" ACTION="graphtest.html">
<INPUT TYPE=hidden NAME=choice VALUE=request>
Type stock symbol(like: bby)  
<INPUT TYPE="text" SIZE="20" NAME="search" VALUE="">
<INPUT TYPE="submit" VALUE="Search!">
</FORM>

<?php

if ($choice == request)
{

echo "<img src= "http://ichart.finance.yahoo.com/z?

s=""$search""&t=1y&q=c&l=on&z=m&a=v&p=s/>""

};
?>

</BODY>
</HTML>



Please look at the echo feature, I do not know how to use the proper syntax . Basically I want a user to submit a symbol and I will give out the graph and that graph is in [a href=\"http://ichart.finance..\" target=\"_blank\"]http://ichart.finance..[/a]. url.

The $search would be the input. So basically if someone typed BBY in the box, the output will give the graph of bby.

Many thanks.

#2 swatisonee

swatisonee
  • Members
  • PipPipPip
  • Advanced Member
  • 253 posts

Posted 25 March 2006 - 04:55 PM

How can it be hidden and inputted in the same form ? if its hidden then it has obviously come in from an earlier page .
Also,

<INPUT TYPE="text" SIZE="20" NAME="search" VALUE="">


should be 

<INPUT TYPE="text" SIZE="20" NAME="search" >

HTH

Shishya

#3 Orphy

Orphy
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 March 2006 - 06:28 PM


Thank you swat, I will fix this and see what happens but before that I am getting error on "echo" line.

Is that how it supposed to be given waht I want as mentioned above. I can follow logic but not syntax.

#4 Gast

Gast
  • Members
  • PipPipPip
  • Advanced Member
  • 131 posts
  • LocationSouth East England

Posted 25 March 2006 - 06:35 PM

[!--quoteo(post=358318:date=Mar 25 2006, 06:28 PM:name=Orphy)--][div class=\'quotetop\']QUOTE(Orphy @ Mar 25 2006, 06:28 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Thank you swat, I will fix this and see what happens but before that I am getting error on "echo" line.

Is that how it supposed to be given waht I want as mentioned above. I can follow logic but not syntax.
[/quote]

There are a couple of errors I can see:

<?php
if ($choice == request) {
// The above line may need to read
// either "$request" or "'request'"

echo "<img src= "http://ichart.finance.yahoo.com/z?s=""$search""&t=1y&q=c&l=on&z=m&a=v&p=s/>""
// This line should be:
// echo "<img src=\"http://ichart.finance.yahoo.com/z?s=".$search."&t=1y&q=c&l=on&z=m&a=v&p=s\" />";

};
?>

OS and Internet Specs:
Windows XP (with SP2), 1680x1050, PHP 4, MySQL 3, Internet Explorer 6 &7 /FireFox 2.0/Opera 9.2

Tutorials:
Simple Introduction to AJAX and XMLHttpRequest
Creating Live Data with AJAX Making a Google Suggest like application

#5 Orphy

Orphy
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 25 March 2006 - 10:34 PM

Hey gast, thank you very much for taking the time out to reply, Yes the code looks cleaner now.

But I am still getting an error. Basically the error is in the whole php codes I think. Thats what I see in dreamweaver.

Is the code logical?

Basically what am I trying to do is, take the user's input and stick in the $search of yahoo url.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users