kickstart Posted September 10, 2009 Share Posted September 10, 2009 Quote Ok it all works. Thank you very much. I have now put it in my code but it adds a line break. Why? Here's the code I have put it in: Where does it add the line break? All the best Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916386 Share on other sites More sharing options...
sp@rky13 Posted September 11, 2009 Author Share Posted September 11, 2009 Look here and you'll see it. The actual php code I am using is the: 443|666 447|669 445|667 442|672 442|666 429|666 etc... Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916522 Share on other sites More sharing options...
kickstart Posted September 11, 2009 Share Posted September 11, 2009 Hi Seen that, but still do not understand what you see as a problem. I just a couple of text areas with some javascript in them, but not sure on what line break you seem to think is the problem All the best Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916615 Share on other sites More sharing options...
sp@rky13 Posted September 11, 2009 Author Share Posted September 11, 2009 It should be like this instead. Up until I added this code it did it like that but with that new code it's different. do you know why that's caused? Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916644 Share on other sites More sharing options...
kickstart Posted September 11, 2009 Share Posted September 11, 2009 Hi Can't see anything in that code fragment that would cause it. However you also seem to have removed the GROUP_CONCAT, and I think with that before you would have returned a single row with all of them joined together while now you are looping through the results. All the best Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916888 Share on other sites More sharing options...
sp@rky13 Posted September 11, 2009 Author Share Posted September 11, 2009 Well that's the code you gave me here: http://www.phpfreaks.com/forums/index.php/topic,262775.msg1238699.html#msg1238699 Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-916974 Share on other sites More sharing options...
anatak Posted September 12, 2009 Share Posted September 12, 2009 I think you are looking for something like this if i < 10 => echo x between 100*i and (100*i+99) and Y between 0 and 99 else echo x between ((i/10 rest of division)*100 ) and ((i/10 rest of division)*100 +99 ) and y between (i/10 integer part of division)*100 +99 so you need to find or write a function that return you 1 the rest of a division 2 the integer part of a division I think there will be a function like that available in php I just don't know it Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917003 Share on other sites More sharing options...
anatak Posted September 12, 2009 Share Posted September 12, 2009 sorry for this and previous post. I didn't notice that I only read page 1 of this topic please ignore this and previous post (since I was too late to modify) Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917013 Share on other sites More sharing options...
sp@rky13 Posted September 12, 2009 Author Share Posted September 12, 2009 Lol, yah gort it figured out just don't get the pesky linebreak lol Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917016 Share on other sites More sharing options...
kickstart Posted September 12, 2009 Share Posted September 12, 2009 Quote Well that's the code you gave me here: http://www.phpfreaks.com/forums/index.php/topic,262775.msg1238699.html#msg1238699 Yes, but where is the rest of the code to generate that javascript? The assumption in that post is that you would want some other data from the select, hence not using GROUP_CONCAT was more flexible. All the best Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917121 Share on other sites More sharing options...
sp@rky13 Posted September 12, 2009 Author Share Posted September 12, 2009 Kinda confused. What do you mean? Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917124 Share on other sites More sharing options...
kickstart Posted September 12, 2009 Share Posted September 12, 2009 Hi The code posted above just generates a list of X and Y coordinates. There is nothing in it at all to put out the javascript calls . My guess would be that the Javascript is put out in a fixed format with a line break half way through and then the coordinates are echoed out, but that is just a guess. Without see where the rest of it comes from I cannot say anything useful about where the line break comes from. For example my guess is you have code like this:- <pre class="alt2" dir="ltr" style=" margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; background-color: #EFE6C9; overflow: auto">javascript:function%20end(){c=' <?php $yLow = floor($k1 / 10) * 100; $yHigh = $yLow + 99; $xLow = ($k1 % 10) * 100; $xHigh = $xLow + 99; $BetweenClause = "x BETWEEN $xLow AND $xHigh AND y BETWEEN $yLow AND $yHigh"; $con = mysql_connect("localhost","*******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("wwwspark_tribalwars", $con); $result = mysql_query("SELECT c.player AS playerid, CONCAT_WS('|',c.x,c.y) AS xy FROM ally_en28 a INNER JOIN players_en28 b ON a.id = b.ally INNER JOIN villages_en28 c ON b.id = c.player WHERE a.tag = '$vpt_sub' AND $BetweenClause ORDER BY c.player") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['xy']." "; } mysql_close($con); ?>';var%20d=document;if(window.frames.length>0)d=window.main.document;url=d.URL;if(url.indexOf('screen=place')==-1)alert('This%20script%20needs%20to%20be%20run%20from%20the%20rally%20point');a=c.match(/(\d+\|\d+)/g);b=a[Math.round(Math.random()*(a.length-1))].split("|").forms[0].x.value=b[0].forms[0].y.value=b[1].forms[0].spear.value=0;d.forms[0].sword.value=0;d.forms[0].axe.value=0;d.forms[0].spy.value=0;d.forms[0].light.value=0;d.forms[0].heavy.value=0;d.forms[0].ram.value=0;d.forms[0].catapult.value=0;d.forms[0].snob.value=0;d.forms[0].archer.value=0;d.forms[0].marcher.value=0;d.forms[0].knight.value=0;}end();</pre> whereas you want something subtly different like this. <pre class="alt2" dir="ltr" style=" margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; background-color: #EFE6C9; overflow: auto">javascript:function%20end(){c='<?php $yLow = floor($k1 / 10) * 100; $yHigh = $yLow + 99; $xLow = ($k1 % 10) * 100; $xHigh = $xLow + 99; $BetweenClause = "x BETWEEN $xLow AND $xHigh AND y BETWEEN $yLow AND $yHigh"; $con = mysql_connect("localhost","*******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("wwwspark_tribalwars", $con); $result = mysql_query("SELECT c.player AS playerid, CONCAT_WS('|',c.x,c.y) AS xy FROM ally_en28 a INNER JOIN players_en28 b ON a.id = b.ally INNER JOIN villages_en28 c ON b.id = c.player WHERE a.tag = '$vpt_sub' AND $BetweenClause ORDER BY c.player") or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['xy']." "; } mysql_close($con); ?>';var%20d=document;if(window.frames.length>0)d=window.main.document;url=d.URL;if(url.indexOf('screen=place')==-1)alert('This%20script%20needs%20to%20be%20run%20from%20the%20rally%20point');a=c.match(/(\d+\|\d+)/g);b=a[Math.round(Math.random()*(a.length-1))].split("|").forms[0].x.value=b[0].forms[0].y.value=b[1].forms[0].spear.value=0;d.forms[0].sword.value=0;d.forms[0].axe.value=0;d.forms[0].spy.value=0;d.forms[0].light.value=0;d.forms[0].heavy.value=0;d.forms[0].ram.value=0;d.forms[0].catapult.value=0;d.forms[0].snob.value=0;d.forms[0].archer.value=0;d.forms[0].marcher.value=0;d.forms[0].knight.value=0;}end();</pre> However I would be tempted to just built up the list of coordinates and then echo them out once like this <?php $yLow = floor($k1 / 10) * 100; $yHigh = $yLow + 99; $xLow = ($k1 % 10) * 100; $xHigh = $xLow + 99; $BetweenClause = "x BETWEEN $xLow AND $xHigh AND y BETWEEN $yLow AND $yHigh"; $con = mysql_connect("localhost","*******","******"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("wwwspark_tribalwars", $con); $result = mysql_query("SELECT c.player AS playerid, CONCAT_WS('|',c.x,c.y) AS xy FROM ally_en28 a INNER JOIN players_en28 b ON a.id = b.ally INNER JOIN villages_en28 c ON b.id = c.player WHERE a.tag = '$vpt_sub' AND $BetweenClause ORDER BY c.player") or die(mysql_error()); $CoOrdStr = ""; while($row = mysql_fetch_array($result)) { $CoOrdStr .= $row['xy']." "; } mysql_close($con); ?> <pre class="alt2" dir="ltr" style=" margin: 0px; padding: 6px; border: 1px inset; width: 640px; height: 34px; text-align: left; background-color: #EFE6C9; overflow: auto">javascript:function%20end(){c='<?php echo $CoOrdStr; ?>';var%20d=document;if(window.frames.length>0)d=window.main.document;url=d.URL;if(url.indexOf('screen=place')==-1)alert('This%20script%20needs%20to%20be%20run%20from%20the%20rally%20point');a=c.match(/(\d+\|\d+)/g);b=a[Math.round(Math.random()*(a.length-1))].split("|").forms[0].x.value=b[0].forms[0].y.value=b[1].forms[0].spear.value=0;d.forms[0].sword.value=0;d.forms[0].axe.value=0;d.forms[0].spy.value=0;d.forms[0].light.value=0;d.forms[0].heavy.value=0;d.forms[0].ram.value=0;d.forms[0].catapult.value=0;d.forms[0].snob.value=0;d.forms[0].archer.value=0;d.forms[0].marcher.value=0;d.forms[0].knight.value=0;}end();</pre> All the best Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917127 Share on other sites More sharing options...
sp@rky13 Posted September 12, 2009 Author Share Posted September 12, 2009 Thank you very much. It works perfectly. I'm gonna use that echo thing now too. A question though on security. Is there anyway for someone to get the password for the database if they go to the right document? If so how can that be stopped? Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917132 Share on other sites More sharing options...
sp@rky13 Posted September 12, 2009 Author Share Posted September 12, 2009 what I mean is, is there anyway to access this: "localhost","my random username","my password" in any way or form Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917136 Share on other sites More sharing options...
kickstart Posted September 12, 2009 Share Posted September 12, 2009 Hi No, not really any way (that I know of at least) unless the server is configured badly to just output php documents rather than executing them. All theb est Keith Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917210 Share on other sites More sharing options...
sp@rky13 Posted September 12, 2009 Author Share Posted September 12, 2009 Ok cool. And thank you ever so much. Is there a logo or something for php freaks I can put on my site. Not that many people are necessarily into using php there may be someone Link to comment https://forums.phpfreaks.com/topic/173509-phpmysql-including-php-not-echo/page/2/#findComment-917383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.