Jump to content

dodgeitorelse3

Members
  • Posts

    266
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by dodgeitorelse3

  1. Solved using preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $map) Thanks for your help mac_gyver, just needed to be pointed in right direction.
  2. ahhh, looking at the view source it is showing <div style='float:left;' class='showchevy_1'> <iframe id='mapdl' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible; width:100%;' src='/maps/php/map_dload2.php?map=Abbusata_Bridge_Coop​'> </iframe> </div> It must be getting the ​ from the game server itself during query. I assume I have to make a change in my database for the collation for this column. Any suggestions? I tried setting the trname column for this map to Abbusata_Bridge_Coop​ but still doesn't find it. the source code for the echo is <body bgcolor="darkslategrey"><br> Abbusata_Bridge_Coop​<font color='lightgreen' size=2><b><i><font color='white'>Abbusata_Bridge_Coop​</font></i></b> was not found.</font></body>
  3. I have a query such as : $map = mysql_real_escape_string ($_GET['map']); //echo $map; $result = mysql_query("select content, size, released, creator, modder, type from `maps` WHERE `trname` LIKE '$map%' ORDER BY trname ASC") or die('Error, query failed'); this works fine except for one map which is called Abbusata_Bridge_Coop. When $_GET['map'] is equal to Abbusata_Bridge_Coop I can echo $map and it displays as such but in the query it returns it cannot find it in database however when I change query to $result = mysql_query("select content, size, released, creator, modder, type from `maps` WHERE `trname` LIKE 'Abbusata_Bridge_Coop' ORDER BY trname ASC") it works. Can anyone shed some light on this issue for me? I should say that I use $map% in query because I need to show all maps that start with that name (some have added text at end of them).
  4. you are mostly wrong by not giving us any info as to why you think something is wrong ..... we have better things to do than sit and sift through your code trying to find something that may or may not be correct. If you want an answer then you should follow the posting guidelines.
  5. @ Jessica, I will try to figure out how to just update without selecting the rows. I have a new column in the database that holds the word "New" which shows on our downloads pagew to let the users know which maps arte the 10 newest. Please see http://chevys-place.nl/downloads.php What we have is a standalone cms and the owner of the site is even more of a noob than I so I am making him a control panel to edit all his files saving him from going to each file and manually editing it. Basically I am trying to automate as much as I can for him lol. Imagine a noob making it easier for a noob
  6. I have tried your suggestion and cannot get it to update more than the same 1 row I was getting when I originally posted. I also tried removing the i from your code at both mysqli sections to no avail.
  7. would I need to use a foreach instead of doing the update in the while statement?
  8. I have written some code to update last 10 newest maps in my database that are decided by the date in a column named released. I have written the code to show me step by step what is happening. However the only row that gets updated is the 10th one. I first show what rows are labeled New in db, then the code clears all those rows. It then shows me a list of the 10 rows to be updated and then shows the rows that have been updated. this is the code for this.... <html> <head> <title>Update 10 newest maps in database</title> </head> <body> <?php // show maps marked as new $conn = mysql_connect('localhost','xxx','xxx'); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db(americas_army, $conn); if(!$status) die("Failed to select database!"); // show maps marked as new $sql_current = "select content, released, Newest from maps WHERE Newest = 'New' ORDER BY released desc"; $result_current = mysql_query($sql_current); $num_rows = mysql_num_rows($result_current); $i=1; echo '<font size=3>These are the current maps marked as new in database</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_current=mysql_fetch_assoc($result_current)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_current[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_current[released]."</b></font></td><td align='center'><font color='black'>".$rows_current[content]."</font></td></tr>"; } echo '</table>'; //clear New from Newest column //clear New from Newest column $sql_clear = "UPDATE maps ". "SET Newest = '' "; mysql_select_db('americas_army'); $retval = mysql_query( $sql_clear, $conn ); if(! $retval ) { die('<br />Could not enter New data in Newest column: ' . mysql_error()); } echo "<br />Cleared New data in Newest column successfully\n"; // show any fields with New left in Newest column $sql_cleared_results = "select content, released, Newest from maps WHERE Newest = 'New' ORDER BY released desc"; $result_cleared_results = mysql_query($sql_cleared_results); $num_rows = mysql_num_rows($result_cleared_results); $i=1; echo '<br /><br /><font size=3>These are the current maps marked as new that were not cleared to prepare for adding New to last 10 maps (should show none)</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_cleared_results=mysql_fetch_assoc($result_cleared_results)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_cleared_results[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_cleared_results[released]."</b></font></td><td align='center'><font color='black'>".$rows_cleared_results[content]."</font></td></tr>"; } echo '</table>'; // show newest 10 maps to be marked as new $sql_to_be_marked_new = "select content, released, Newest from maps ORDER BY released desc limit 10"; $result_to_be_marked_new = mysql_query($sql_to_be_marked_new); $num_rows = mysql_num_rows($result_to_be_marked_new); $i=1; echo '<br /><br /><font size=3>These are the 10 maps to be marked as new in database</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_to_be_marked_new=mysql_fetch_assoc($result_to_be_marked_new)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_to_be_marked_new[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_to_be_marked_new[released]."</b></font></td><td align='center'><font color='black'>".$rows_to_be_marked_new[content]."</font></td></tr>"; $sql_add_new = "UPDATE maps ". "SET Newest = 'New' ". "WHERE released = '".$rows_to_be_marked_new[released]."'" ; } echo '</table>'; $last_ten_results_to_be_marked_as_new[] = "$rows_to_be_marked_new[Newest]"; //Update New from 10 most recent form released column while($rows_to_be_marked_new=mysql_fetch_assoc($result_to_be_marked_new)){ $sql_add_new = "UPDATE maps ". "SET Newest = 'New' ". "WHERE released = '".$rows_to_be_marked_new[released]."'" ;} mysql_select_db('americas_army'); $retval = mysql_query( $sql_add_new, $conn ); if(! $retval ) { die('<br /><br />Could not add New data in Newest column: ' . mysql_error()); } echo "<br /><br />Added New data in Newest column successfully\n"; // get 10 newest maps by released column $sql_new_results = "select content, released, Newest from maps ORDER BY released desc limit 10"; $result_new_results = mysql_query($sql_new_results); $num_rows = mysql_num_rows($result_new_results); $i=1; echo '<br /><br /><font size=3>These are the newest 10 maps marked as new </font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_new_results=mysql_fetch_assoc($result_new_results)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_new_results[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_new_results[released]."</b></font></td><td align='center'><font color='black'>".$rows_new_results[content]."</font></td></tr>"; } echo '</table>'; mysql_close(); ?> This is the screen shot of what I see on page when code is executed. Any ideas why it only updates the one row? sorry had the code to update rows commented out, removed comment marks.
  9. ok, after fiddling around with this I used //loop through array using foreach foreach($lines as $line) { if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); } fwrite($f,$line); //place $line back in file } and it works like a charm. davidAM thank you very much. @ denno020, I will still try what you suggested so I can learn a bit more so a thank you to you also.
  10. @ DavidAM, I tried your suggestion first by changing code to //loop through array using foreach foreach($lines as $line) { if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); fwrite($f,$line); //place $line back in file } } which did put the new line before the key line but it did not put the first part of the file back in giving me this tooltips[5654]=["/mapimages/", "<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br><br>Terrain: <br><br>Creator: <br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line as my finished file. I assume I misunderstood what you said. @ denno020, I have to look at the preg_grep, the array_splice and the file_put_contents as all of this file writing stuff is new to me.
  11. Hi folks, I am stumped as to why I cannot write data to a specific pointer position in an existing file. The file I want to write to contains ... ****many other lines are here, removed to shorten for this post**** tooltips[304]=["/mapimages/tn_spider1.jpg", "Operation_BlackSpider120<br><br>Objectives:<br>A: Make contact with the Black Spider<br>B: Locate the case that has the laptop location<br>C: Locate and hack the laptop<br>D: Use access code and release the prissoners<br>E: Move out and locate the extractionpoint <br><br>Terrain: Snow and Hills<br><br>Creator: SF{Ops}PatFinder<br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[305]=["/mapimages/tn_296_nomap.jpg", "The_Observatory_PF<br><br>Objectives:<br>A: Infiltrate the Observatory Complex<br>B: Locate and secure experimental communications data<br>C: Disable the laser weapon system<br>D: Restore power to sattellite communication system<br>E: Restore main power grid<br>F: Radio for extraction<br>G: Locate extraction point<br><br>Terrain: In and outside buildings<br><br>Creator: -{KWK}-Kman<br><br>Modder: SF{Ops}PatFinder<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[306]=["/mapimages/tn_296_nomap.jpg", "The_Breach<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br>E: <br>F: <br>G: <br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[307]=["/mapimages/tn_radio1.jpg", "SFRadioTower<br><br>Objectives:<br>A: Disable the radiotower antenna generator<br>B: Rescue AID worker<br>C: Destroy the attack helicopter<br>D: Destroy the weapon cache<br><br>Terrain: <br><br>Creator: 151Alpha<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[308]=["/mapimages/tn_agency.jpg", "The_Agency<br><br>Objectives:<br>A: Infiltrate the intelligence facility (7x)<br>B: Locate and question the analist<br>C: Secure the stolen intel<br>D: Access the mainframe to stop any intel transfer<br>E: Locate extraction point<br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line }(), tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips //***** NO NEED TO EDIT BEYOND HERE tipprefix: 'imgtip', //tooltip ID prefixes createtip:function($, tipid, tipinfo){ if ($('#'+tipid).length==0){ //if this tooltip doesn't exist yet return $('<div id="' + tipid + '" class="ddimgtooltip" />').html( '<div style="text-align:center"><img src="spacer.jpg" data-src="' + tipinfo[0] + '" /></div>' + ((tipinfo[1])? '<div style="text-align:left; margin-top:5px">'+tipinfo[1]+'</div>' : '') ) .css(tipinfo[2] || {}) .appendTo(document.body) } return null }, positiontooltip:function($, $tooltip, e){ var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1] var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(), x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(ddimgtooltip.tooltipoffsets[0]*2) : x y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y $tooltip.css({left:x, top:y}) }, showbox:function($, $tooltip, e){ var $tipimage=$tooltip.find('img:eq(0)') if (!$tipimage.attr('data-srcloaded')) $tipimage.attr({'src':$tipimage.attr('data-src'), 'data-srcloaded':1}) $tooltip.show() this.positiontooltip($, $tooltip, e) }, hidebox:function($, $tooltip){ $tooltip.hide() }, init:function(targetselector){ jQuery(document).ready(function($){ var tiparray=ddimgtooltip.tiparray var $targets=$(targetselector) if ($targets.length==0) return var tipids=[] $targets.each(function(){ var $target=$(this) $target.attr('rel').match(/\[(\d+)\]/) //match d of attribute rel="imgtip[d]" var tipsuffix=parseInt(RegExp.$1) //get d as integer var tipid=this._tipid=ddimgtooltip.tipprefix+tipsuffix //construct this tip's ID value and remember it var $tooltip=ddimgtooltip.createtip($, tipid, tiparray[tipsuffix]) $target.mouseenter(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.showbox($, $tooltip, e) }) $target.mouseleave(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.hidebox($, $tooltip) }) $target.mousemove(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.positiontooltip($, $tooltip, e) }) if ($tooltip){ //add mouseenter to this tooltip (only if event hasn't already been added) $tooltip.mouseenter(function(){ ddimgtooltip.hidebox($, $(this)) }) } }) }) //end dom ready } } //ddimgtooltip.init("targetElementSelector") ddimgtooltip.init("*[rel^=imgtip]") I want to write to this file at the space before the line containing "return tooltips" without the quotes. Note that line is 71 lines from the bottom. This is the code I use to write to the file .... <?php echo("Tooltip ID Number from db: " . $_POST['tooltip_number'] . "<br />\n"); echo("Thumbnail name for image: " . $_POST['tn_image'] . "<br />\n"); echo("Map Name: " . $_POST['map_name'] . "<br />\n"); echo("Objective A: " . $_POST['obj_a'] . "<br />\n"); echo("Objective B: " . $_POST['obj_b'] . "<br />\n"); echo("Objective C: " . $_POST['obj_c'] . "<br />\n"); echo("Objective D: " . $_POST['obj_d'] . "<br />\n"); echo("OTerrain: " . $_POST['terrain'] . "<br />\n"); echo("Creator: " . $_POST['creator'] . "<br />\n"); echo("Modder: " . $_POST['modder'] . "<br />\n"); echo("Mods: " . $_POST['mods'] . "<br />\n"); echo "<br /><br /><br />"; $new_tt = "\r\n\r\n tooltips[" . $_POST['tooltip_number'] . "]=[\"/mapimages/" . $_POST['tn_image'] . "\", \"" . $_POST['map_name'] . "<br><br>Objectives:<br>A: " . $_POST['obj_a'] . "<br>B: " . $_POST['obj_b'] . "<br>C: " . $_POST['obj_c'] . "<br>D: " . $_POST['obj_d'] . "<br><br>Terrain: " . $_POST['terrain'] . "<br><br>Creator: " . $_POST['creator'] . "<br><br>Modder: " . $_POST['modder'] . "<br><br>Mods: " . $_POST['mods'] . "\", {background:\"gray\", border:\"none\", font:\"bold 12px Arial\", color:\"black\"}]\r\n\r\n"; echo "$new_tt"; $key = 'return tooltips'; //copy file to prevent double entry $file = "test_fwrite_file.js"; $newfile = "test_fwrite_file.txt"; copy($file, $newfile) or exit("failed to copy $file"); //load file into $lines array $fc = fopen ($file, "r"); while (!feof ($fc)) { $buffer = fgets($fc, 4096); $lines[] = $buffer; } fclose ($fc); //open same file and use "w" to clear file $f=fopen($newfile,"w") or die("couldn't open $file"); /* uncomment to debug print_r($lines); print "<br>\n"; */ //loop through array using foreach foreach($lines as $line) { fwrite($f,$line); //place $line back in file if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); } //place $line back in file } fclose($f); copy($newfile, $file) or exit("failed to copy $newfile"); ?> however when it writes to the file it places it after the $key such as tooltips[308]=["/mapimages/tn_agency.jpg", "The_Agency<br><br>Objectives:<br>A: Infiltrate the intelligence facility (7x)<br>B: Locate and question the analist<br>C: Secure the stolen intel<br>D: Access the mainframe to stop any intel transfer<br>E: Locate extraction point<br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line tooltips[5654]=["/mapimages/", "<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br><br>Terrain: <br><br>Creator: <br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] }(), tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips //***** NO NEED TO EDIT BEYOND HERE what do I need to do to place it at the right spot?
  12. I use http://www.dynamicdrive.com/dynamicindex4/imagetooltip.htm
  13. wouldn't you use '% ".$keyword."% ' ?
  14. well I see in one of OP's first posts he says error is 18-Feb-2013 12:04:13 UTC] PHP Warning: Invalid argument supplied for foreach() in /home/measured/public_html/leeds/study-info/demogstore.php on line 12 but in his Screenshot for firebug it is saying /home/measured/leeds/study-info/demogstore.php notice the public_html? of course I could be way off base here lol
  15. $sql = "UPDATE tbl_news SET clmn_comment='".$comment."' WHERE id=".$id; seems to me that the where clause has a beginning ". but no ending ." and sql statement starts with " and has no closing "
  16. ok dannon I will thank you very much
  17. ty guys, worked with $result = mysql_query("select * from lgsl where `comment`= '".$_POST['comment']."'") or die('Error, query failed'); now about the injection thing? Is it really something I need to worry about since I am the only one that has access to this file?
  18. ty dannon, tried that and also added the missing underscore in $POST but still fails.
  19. ok so I am trying to learn to use $_POST. I have written a query with a where clause is using the $_POST but I keep getting query failed. I know the $_POST works as I can echo the value. Can anyone spot my error? $result = mysql_query("select * from lgsl where `comment'= ".$POST['comment']."") or die('Error, query failed');
  20. #left-header { background: url("../Pictures_Other/b3.png") no-repeat scroll 0 0 transparent; height: 150px; margin-top: 5px; }
  21. glad you got it
  22. why not just put link into database? Is there a downside to that? <a href="contactus.php">Contact Us</a>
  23. where does it connect to the database?
  24. are you sure it is userdir?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.