Wildhalf Posted December 11, 2006 Share Posted December 11, 2006 I need Help Badly.... I think this is something simple but just cant get my head around it....I have everything working In my project the database is returning everything it should, i know this as i am using a print staement to show it...... But i have one small problem i need help with....In My mid.php file i am using javascript to open a new window which the url needs the value of one of the returned varialbes... THe right value is being returned as the print statement shows but in url states its an invalid url.....$friend_1 (is decalared as an int in database) is the variable i need on the end of my url, i know the javascript below is right also as if i use the number that the varialbe holds everything works fine...<a href="javascript:;" onClick="window.open('http://www.MySite.com'+'$friend_1','myWin','scrollbars=yes,width=694,height=500,left=150,top=150');"><img src="friend1.gif" border="0"/></a></td> What am i doing wrong. When i use the print function in the code below it prints the right number... Any ideas???Thanks KieronHave a look at my php code:<?// Get database connectioninclude 'db.php';// Create variables from URL.$refer_id = $_REQUEST['id'];$sql = mysql_query("SELECT * FROM tblFriends WHERE myspace_id='$refer_id'");$data=mysql_fetch_array($sql);$friend_1 = $data[friend_1];$friend_2 = $data[friend_2];$friend_3 = $data[friend_3];$friend_4 = $data[friend_4];$friend_5 = $data[friend_5];$friend_6 = $data[friend_6];/* Let's strip some slashes in case the user enteredany escaped characters. */$friend_id = stripslashes($friend_id);$friend_1 = stripslashes($friend_1);$friend_2 = stripslashes($friend_2);$friend_3 = stripslashes($friend_3);$friend_4 = stripslashes($friend_4);$friend_5 = stripslashes($friend_5);$friend_6 = stripslashes($friend_6);print "This is Friend $friend_1\n";print "This is Friend $friend_2\n";print "This is Friend $friend_3\n";print "This is Friend $friend_4\n";print "This is Friend $friend_5\n";print "This is Friend $friend_6\n";include "header.php";include "mid.php";include "footer.php";?> Link to comment https://forums.phpfreaks.com/topic/30265-php-problem-with-displaying-returned-number/ Share on other sites More sharing options...
kenrbnsn Posted December 11, 2006 Share Posted December 11, 2006 You need to echo the PHP variable so Javascript sees the value correctly.[code]onClick="window.open('http://www.MySite.com'+'<?php echo $friend_1; ?>','myWin','scrollbars=yes,width=694,height=500,left=150,top=150');">[/code]Ken Link to comment https://forums.phpfreaks.com/topic/30265-php-problem-with-displaying-returned-number/#findComment-139190 Share on other sites More sharing options...
Wildhalf Posted December 11, 2006 Author Share Posted December 11, 2006 Thanks a bunch worked like a charm.....Not much left now and i can launch my best creation yet...I believe my site will take Myspace adders to the next level...Everyone will be able to get thousands upon thousands of friends easilyThanks again Link to comment https://forums.phpfreaks.com/topic/30265-php-problem-with-displaying-returned-number/#findComment-139203 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.