WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-30-2004, 07:49 PM
WebProWorld New Member
 

Join Date: Apr 2004
Location: www.rapidbikes.co.uk
Posts: 9
L Plate web designer RepRank 0
Default Link variable (PHP)

Hello,

I don't really know much about PHP but you've got to start somewhere.

I wondered if anyone could help me. I'm trying to open a new window set to a specific size and with no toolbars etc when clicked on a picture. I can open a new window using target="_blank" but when I put in the rest of the code it wont accept it: <a href='$picName' onclick="window.open('$picname.htm','','width=550, height=480','resizable=no','scrollbars=no'); return false;" target="_blank">I'm guessing its because of the JavaScript but I'm not sure how to fix it.

Matt
Reply With Quote
  #2 (permalink)  
Old 09-30-2004, 08:16 PM
ronniethedodger's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Central US
Posts: 1,581
ronniethedodger RepRank 0
Default

I cannot see your entire script file, so I am assuming that you have the code inside of standard Html.

Try wrapping your variables as such <? variable >

Code:
<a href='<?$picName>' onclick="window.open('<?$picname>.htm','','width=550,height=480','resizable=no','scrollbars=no'); return false;" target="_blank">
Also, what is the name of the file you are running. It must end with a php extension in order for the server to parse it as php thru the interpreter.
Reply With Quote
  #3 (permalink)  
Old 10-01-2004, 10:08 AM
WebProWorld New Member
 

Join Date: Apr 2004
Location: www.rapidbikes.co.uk
Posts: 9
L Plate web designer RepRank 0
Default PHP

Thanks for your reply, that was well quick!

Basically I've built my website using html and JavaScript, I don't actually know much about PHP, I've had some written for me for free so that a customer can submit an advert and I can go on line in the admin database and accept/decline or edit the advert before it appears live. Most of this works very well, there's just a few things I'd like to change, one of them is when a user clicks on a thumbnail to see the fullsize picture I would like the picture to appear in a window at a set size with no toolbars. I know how to do this within html but not within php. The file is called advertisement.php which starts with <?php I presume it's the onclickevent it doesn't like or maybe its because I have a $variable in the middle of it. Here's a bit more of the code
Code:
 
                                                $width = $width/$ratio;
                        $height = $height/$ratio;
                    }
                }
                $s="','','width=550,height=480','resizable=no','scrollbars=no'); return false;" target="_blank">[img]$picName[/img]";
            }
            else $s="[img]$adAttDir/no.png[/img]";
        }
        else $s="[img]$adAttDir/no.png[/img]";    


Many thanks for your time

Matt
Reply With Quote
  #4 (permalink)  
Old 10-02-2004, 03:33 PM
WebProWorld New Member
 

Join Date: Apr 2004
Location: www.rapidbikes.co.uk
Posts: 9
L Plate web designer RepRank 0
Default PHP

Help
Does anyone know how to make JavaScript work within PHP, I can't get the onclick event to work
Code:
$s="[img]$picName[/img]"; 

I just want to be able to open a window set to a specific size etc.  I Can do it in html but not within PHP.

any help much appreciated
Matt
Reply With Quote
  #5 (permalink)  
Old 10-02-2004, 03:36 PM
ronniethedodger's Avatar
WebProWorld 1,000+ Club
 

Join Date: Aug 2003
Location: Central US
Posts: 1,581
ronniethedodger RepRank 0
Default

I tell you what. Can you take your php file and copy it over to another file with a .txt extension, then post the link to that file here? That way I or someone else can grab it and run it thru on their local machine to see what is what. We will probably need to see this file in it's entirety
Reply With Quote
  #6 (permalink)  
Old 10-02-2004, 03:53 PM
WebProWorld New Member
 

Join Date: Apr 2004
Location: www.rapidbikes.co.uk
Posts: 9
L Plate web designer RepRank 0
Default PHP

Ok, here's the whole advertisement.php in a .txt file
http://www.rapidbikes.com/advertisement.txt

if you search for onclick you will find the section easier.

thanks for your help

Matt
Reply With Quote
  #7 (permalink)  
Old 10-02-2004, 04:33 PM
WebProWorld Pro
 

Join Date: May 2004
Location: United Kingdom
Posts: 176
php~pro RepRank 0
Default

Escape from " with \.

eg.$s="<a href=\"$picName\"
Reply With Quote
  #8 (permalink)  
Old 10-03-2004, 08:27 AM
WebProWorld New Member
 

Join Date: Apr 2004
Location: www.rapidbikes.co.uk
Posts: 9
L Plate web designer RepRank 0
Default PHP

Thank you sooooooo much
problem solved
much appreciated

Matt
Reply With Quote
  #9 (permalink)  
Old 10-04-2004, 02:20 PM
WebProWorld Pro
 

Join Date: May 2004
Location: United Kingdom
Posts: 176
php~pro RepRank 0
Default

You would have had it solved alot sooner if people who knew what they were doing replied only. Escaping is one of the very basic rules of php syntax. Anyone with the slightest clue about php coding would have answered your query easily, from the very first snippet you posted. Evevryone thinks they know everything in site and backend development.
Reply With Quote
  #10 (permalink)  
Old 10-06-2004, 01:36 PM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default Link code in PHP page

How can I get it to work if it's in a php page? Looks like this:

$htmlwebsite = '<a href<>\\'.$website.'\\>'.$website.'</a>';

The browser treats it like a relative url when it's an absolute url. Take out the <> and put = in it's place.

Instead of going to (example): www.webproworld.com it goes to www.kaytrimbath.com/www.webproworld.com
Reply With Quote
  #11 (permalink)  
Old 10-06-2004, 02:24 PM
WebProWorld Pro
 

Join Date: May 2004
Location: United Kingdom
Posts: 176
php~pro RepRank 0
Default

With a correct escape. Try reading up on syntax in the manual. You can even download your own free copy. More satisfying to solve it yourself than mooching forums for the answer surely.

And Ive never seen anything like this. Did you make it up or did someone give you it.
Code:
$htmlwebsite = '<a href<>\\'.$website.'\\>'.$website.'';
Below should be correct
Code:
$htmlwebsite = "<a href=\"".$website.">".$website."</a>";
Also use the editor code wrappers as this bb will not always correctly display your code.[/code]
Reply With Quote
  #12 (permalink)  
Old 10-06-2004, 05:38 PM
WebProWorld Pro
 

Join Date: Aug 2004
Location: Maryland
Posts: 219
webmasterjunkie RepRank 0
Default Getting there, thanks php~pro

Well, I got it down to this now. That takes me out of my pretected area and to my root directory, but no matter how name ../ I put in, it only gets me to my root.

echo '<a href<>"../',$web,'">'.$web.'</a>';

Again, take out the <> and put = instead.

Oh, yeah, I made it up. That's why it looks funny, but it kinda works. I am going to paste everything after my database connection:

mysql_connect("localhost",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM business";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$company=mysql_result($result,$i,"company");
$house=mysql_result($result,$i,"house");
$street=mysql_result($result,$i,"street");
$city=mysql_result($result,$i,"city");
$state=mysql_result($result,$i,"state");
$zip=mysql_result($result,$i,"zip");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
echo "$first $last
$company
$house $street
$city, $state $zip
Phone: $phone

Mobile: $mobile
Fax: $fax
";
echo '<a href<>"mailto:',$email,'">'.$email.'</a>
';
echo '<a href<>"../',$web,'">'.$web.'</a>';
$i++;
}
?>

That still makes the url look like w3.kaytrimbath.com/w3.google.com
Instead of w3.google.com
But the email works great.
Reply With Quote
  #13 (permalink)  
Old 10-08-2004, 10:31 AM
WebProWorld Member
 

Join Date: Oct 2003
Location: St. Louis
Posts: 30
lutenegger RepRank 0
Default

I'm guessing that you just have that web variable comes out like this $web="www.google.com";

You have this
echo '<a href<>"../',$web,'">'.$web.'';

You need this
echo '<a href = "http://'.$web.'">'.$web.'</a>';

Remember for absolute links you need the http://
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , ,



Thread Tools
Display Modes

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

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


Search Engine Optimization by vBSEO 3.2.0