Jump to content

BlackAce

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

BlackAce's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This is part of a larger script that is processing form submissions. I realize that I failed to include the 2nd parameter of imagejpeg() which is the location where I'd like to save the new file. Thus: imagejpeg($image, $filename); Thank you for your help, sometimes it just helps to write this stuff out.
  2. The script below runs without any errors (I've enabled all PHP errors just to be sure). But the file that is saved out does not have the watermark on it anywhere. Just the original source image. Here is a live example for you to view: http://www.ahsnewsline.com/watermark.php <?php $thumb_dir = "img/"; $perm_name = "wm_news001.jpg"; $filename = $thumb_dir.$perm_name; echo "<strong>WATERMARK IMAGE:</strong><br/><img src='img/video-icon.png'/>"; echo "<br/><strong>BEFORE:</strong><br/><img src='$filename'/>"; echo "<br/>$filename<br/><br/>"; $watermark = imagecreatefrompng('img/video-icon.png'); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); $image = imagecreatefromjpeg($filename); $size = getimagesize($filename); $dest_x = $size[0] - $watermark_width; $dest_y = $size[1] - $watermark_height; imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); imagejpeg($image); imagedestroy($image); imagedestroy($watermark); echo "<br/><hr/><br/><strong>AFTER:</strong><br/><img src='$filename'/>"; echo "<br/>$filename"; ?> NOTE: This version uses imagecopy() instead of imagecopymerge() due to it's PNG-24 support. And yes, I was using PNG-8 when I was using the imagecopymerge() function. Regardless, it's still not working. Any ideas?
  3. When I do the following: for(i = 0; i < mySplitResult.length; i++){ document.write("<br /> Element " + i + " = " + mySplitResult[i]); } I get this: So it's obviously working and splitting into the two groups. So I'm not sure why "mySplitResult[1]" returns undefined, using the code in my post above. EDIT: So here's a chunk of code from my PHP file that generates the responseText. else { $x=0; $topurl=''; while($row = mysql_fetch_array($result)) { if($x == 0 && $row['specialty_shortname']!=NULL) { $topurl = "specialty.php?view=SP&specialty=".$row['specialty_shortname']."mySPLIT"; $x++; echo $topurl; } elseif($x == 0 && $row['facility_ID']!=NULL) { $topurl = "detail.php?view=ST&facility_id=".$row['facility_ID']."mySPLIT"; $x++; echo $topurl; } if($row['specialty_shortname']!=NULL) { echo "<a href='specialty.php?view=SP&specialty=".$row['specialty_shortname']."'>".$row['specialty_displayname']."</a><br/>"; } if($row['facility_ID']!=NULL) { echo "<a href='detail.php?view=ST&facility_id=".$row['facility_ID']."'>".$row['facility_name']."</a><br/>"; } } } If I remove the second "mySPLIT" from the elseif, mySplitResult[1] returns with the correct information instead of undefined. But the second "mySPLIT" shouldn't ever be printed if the first if statement comes back true. :-\
  4. OK, so using split() here's where I am: <script type="text/javascript"> function showResult(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var myString = xmlhttp.responseText; var mySplitResult = myString.split("mySPLIT"); //document.getElementById("txtHint").innerHTML=xmlhttp.responseText; document.myform.action = mySplitResult[0]; document.getElementById("txtHint").innerHTML=mySplitResult[1]; } } xmlhttp.open("GET","search_mysql.php?q="+str,true); xmlhttp.send(); } </script> <form method="POST" action="null" name='myform'> <input type="text" size="30" onkeyup="showResult(this.value)" /> </form> <div id="txtHint"></div> The form action updates perfectly now (yay!), however, the rest of the responseText is coming back as undefined when I try to call it with mySplitResult[1]. Any ideas?
  5. Thanks Zane, I've dropped that in as you instructed. Still not sure how to read through my responseText, locate the var or value of the var ($topurl) and use that to replace 'whatever' as indicated in your example.
  6. Hi All-- Here's what I'm trying to accomplish. I copied this basic AJAX function from another blog for use on a search feature I was building on our site. It runs a PHP script, and then returns the text to a predefinied div on the original page. Here is the code: <script type="text/javascript"> function showResult(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","search_mysql.php?q="+str,true); xmlhttp.send(); } </script> <form method="POST" action="null"> <input type="text" size="30" onkeyup="showResult(this.value)" /> </form> <div id="txtHint"></div> In addition to creating the result text that is returned to the "txtHint" div, my PHP script also generates a var $topurl that I want to also return to the form, and replace "null" as the form action. I don't really know anything about AJAX, so I don't know how to modify the script to update the form action as well as print the result text in the div below. Help?
  7. Ok, so I've spent quite a bit of time piecing together this solution from a variety of sources. As such, I may have something in my code below that doesn't make sense or isn't neccessary. Please let me know if that is the case. I'm creating an administrative form that users will you to add/remove items from a MySQL table that lists open positions for a facility. The foreach loop generates all of the possible job specialties from a table called 'specialty_list'. This table is joined to a second table ('open_positions') that lists any positions that have been selected previously. Where I'm stuck is getting the checkbox to be checked if the facility_ID from the open_positions table matches the $id passed in the URL via ?facility_id=''. Here's where I am so far: $query = "SELECT specialty_list.specialty_displayname , specialty_shortname , open_positions.position , facility_ID FROM specialty_list LEFT OUTER JOIN open_positions ON open_positions.position = specialty_list.specialty_shortname ORDER BY specialty_list.specialty_shortname"; $results = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($results)) { $positions[$row['specialty_shortname']] = $row['specialty_displayname']; } echo "<form method='POST' action='checkbox.php'>"; foreach($positions as $specialty_shortname => $specialty_displayname) { $facility_ID = $row['facility_ID']; $checked = $facility_ID == $row['facility_ID'] ? ' checked' : ''; echo "<input type='checkbox' name='position[]' value=\"{$specialty_shortname}\"{$checked}> {$specialty_displayname}</input><br/>"; } echo "<input type='hidden' name='facility_ID' value='$id'>"; echo "<input type='submit' value='Submit Checkboxes!'>"; echo "</form>"; Any ideas how to get this working? I feel like I'm very close, but I just can't get it. I also tried starting from scratch with a WHILE statement instead of a FOREACH, but haven't tweaked it enough to prevent duplicate checkboxes. With that in mind, here it is, just in case that's a better direction: $query = "SELECT specialty_list.specialty_displayname , specialty_shortname , open_positions.position , facility_ID FROM specialty_list LEFT OUTER JOIN open_positions ON open_positions.position = specialty_list.specialty_shortname ORDER BY specialty_list.specialty_shortname"; $results = mysql_query($query) or die(mysql_error()); echo "<form method='POST' action='checkbox.php'>"; while($row=mysql_fetch_assoc($results)) { $facility_ID = $row['facility_ID']; $specialty_shortname = $row['specialty_shortname']; $specialty_displayname = $row['specialty_displayname']; if ($facililty_ID==$id) { $checked=' checked'; } echo "<input type='checkbox' name='position[]' value=\"$specialty_shortname\"$checked> $specialty_displayname</input><br/>"; } echo "<input type='hidden' name='facility_ID' value='$id'>"; echo "<input type='submit' value='Submit Checkboxes!'>"; echo "</form>";
  8. You're exactly right. Thank you for taking time to give explanation, that really helps me get a better grasp on these functions. I really appreciate it.
  9. I need some assistance getting my results to display the way I intend. Perhaps this belongs in the PHP forum--if so, let me know. Basically, I am creating a page that lists all of the facilities that have open positions in a particular specialty area. I want them to display as follows: <h1>State Name</h1> <h3>Facility Name #1</h3> <p>Facility City, Facility State</p> <h3>Facility Name #2</h3> <p> Facility City, Facility State</p> <h1>State Name #2</h1> <h3>Facility Name #3</h3> <p>Facility City, Facility State</p> The PHP code I've included below does this, but repeats the state name for each facility. I want this to show the state name once, then all the facilities in that state below it. You'll notice that I have commented out the "GROUP BY facility_state" part of the query, which does group them by state, but only displays the first facility in that state, not all of them. Please pardon the newbness, I'm just starting at all this! Thanks! $query = "SELECT facility_info.facility_ID as fID, facility_name, facility_city, facility_state, open_positions.position, open_positions.status FROM facility_info, open_positions WHERE facility_info.facility_ID=open_positions.facility_ID AND open_positions.status!='NULL' ORDER BY facility_state, facility_name"; //GROUP BY facility_state $results = mysql_query($query) or die(mysql_error()); $prev_id=0; $num=mysql_num_rows($results); for($i=0;$i<$num;$i++){ // loop for each open position $f=mysql_fetch_array($results); if($prev_id!=$f["fID"] && $f["position"]==$specialty){ // display facility info if($prev_id) echo '</h3>'; echo '<h2 style="margin-bottom:0px;">'.htmlspecialchars($f["facility_state"]).'</h2>'; echo '<h3 style="margin-bottom:0px;">'.htmlspecialchars($f["facility_name"]).'</h3>'; echo htmlspecialchars($f["facility_city"]); echo ', '; echo htmlspecialchars($f["facility_state"]); $prev_id=$f["facility_ID"]; } } echo '</h3>'; mysql_close(); ?>
×
×
  • 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.