PHP - Function Stops Working After Div Reload (dom?)
I am creating a 'stream' page with like buttons under each status. It works untill the div is reloaded with new content. I have researched this and it appears to be due to the new content not being loaded into the DOM.
Does anyone know a solution? I have found a few strange ones, for example, forcing a window resize. I tried that but it didn't work. Thanks, Similar TutorialsHello, New to PHP and trying to loop through rows to and get the name of the "property" in this case. I have tried foreach and while and neither seem to want to return all rows by calling the function. Does it have something to do with echo'ing the table structure or can I not return an array out of a function like this? I commented out the while loop as that wasn't working and put in a foreach loop though that didn't return all the data either. Any help is greatly appreciated Code: [Select] <?php function getProperties(){ $sql = "SELECT propertyName FROM properties;"; $result = mysql_query($sql); //$count = mysql_num_rows($result); $property = mysql_fetch_array($result); foreach($property as $propertyName){ echo "<td width=\"157\" height=\"24\" valign=\"middle\"><div align=\"left\"><input type=\"checkbox\" name=\"$propertyName\" \"id=\"$propertyName\" />$propertyName</div></td>"; } /* for($i=0;$i>=$count;$i++){ while($property = mysql_fetch_array($result)){ $propertyName = $property['propertyName']; echo "<td width=\"157\" height=\"24\" valign=\"middle\"><div align=\"left\"><input type=\"checkbox\" name=\"$propertyName\" \"id=\"$propertyName\" />$propertyName</div></td>"; } } */ } ?> I have a div that displays the contents of a mysql table. When the users adds to the table/presses a button I want it to fade out, reload, and fade back in with the new content there. The current PHP code is in its own div called 'stream'... <script> function buttonFunction() { v=$("#txtstatus"); $.post('../action/poststatus.php',{status:v.val()},function(d){ $('div#stream').fadeOut('slow'); $('div#stream').load; $('div#stream').fadeIn('slow'); }); } </script>This fades out and back in but with nothing new loaded. Please help. Thanks, Thanks in advance for any help you can provide on this. Bob G. BACKGROUND: I have an app that is hosted on Host Monster and its script includes a Class that is supposed to send MIME emails with or without attachments using only MIME types text, html, and image. It was working fine. I hadn't worked with or on it for about two months then found, last week, that it would no longer send emails even though the script runs without any Warnings. I've worked on this for several days now and I'm stuck. EXPECTED BEHAVIOR: When the script runs, it should send a simple text only email to a given email address and an more complex email that requires html and an in-line image in the body and an attachment with the same image. The image type is jpeg. ACTUAL BEHAVIOR: The script runs to completion with no Warning but sends neither of the two emails. CODE: Attached and cc'd below is a script which mimics the code in my app and the actual behavior described above but only for the simple email mentioned above. To simplify debug I've commented out that part of the script that should send out the more complex email mentioned above. Note: You can run the script by going to http://www.unitresearch03.com/Admin/SendUserEmailHM01.php Note: Line 6 can be changed to your own email address for testing BEGIN CODE: Code: [Select] <?php //TOP LINE CODE ////SIMPLE MIME EMAIL CODE - NO ATTACHMENTS ////////////////////////////////////////////// $mail = new mime_mail ; $mail->from = "ragsr@ix.netcom.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "SIMPLE MIME EMAIL - NO ATTACHMENTS" ; $mail->body = "SIMPLE MIME EMAIL BODY" ; $mail->send() ; ////END OF SIMPLE MIME EMAIL CODE //////////////////////////////////////////////////////// ////START MIME EMAIL CODE - ALLOWS ATTACHEMENTS ///////////////////////////////////////////////// //SIMPLE SEND EMAIL PG.448 PHP REFERENCE PLUS ATTACHMENT EXAMPLE FROM SAME PAGE //include "mime_mail.inc"; //THIS CAUSED A WARNING AND, APPARENTLY, IS NOT REQUIRED. CODE OK W/O IT //READ FILE $filename="/home1/unitcons/public_html/unitresearch03/TCStripComposition-27Cb.jpg" ; $content_type="image/jpeg" ; //OPEN, EXTRACT DATA, THEN CLOSE FILE $fd=fopen($filename, "r") ; $data=fread($fd, filesize($filename)) ; fclose($fd) ; $fileX="/home1/unitcons/public_html/unitresearch03TCStripComposition-27Cb.jpg" ; $ftype=filetype ($filename) ; $fsize=filesize($filename) ; //echo "FILE TYPE :"."$ftype"."<br>" ; //echo "FD FILE TYPE :"."$fdltype"."<br>" ; //echo "DATA :"."$data"." END DATA"."<br>" ; //echo "FSIZE :"."$fsize"."<br>" ; //echo "FDSIZE :"."$fsize"."<br>" ; //echo "FD :"."$fd"."<br>" ; //CREATE OBJECT INSTANCE $mail = new mime_mail ; //SET ALL DATA SLOTS $mail->from = "thromptmweeklycs@unitresearch03.com" ; $mail->to = "ragsr@ix.netcom.com" ; $mail->subject = "XXXThrompTM Weekly Comic Strip - Week of 6/20/201" ; $mail->body = "<html>Hope you enjoy your ThrompTM today! <br> <br> <br> <img src=http://www.unitresearch03.com/TCStripComposition-27Cb.jpg height='197' width='500' > </html>"; //DEFINE ATTACHMENT $name = $fileX ; $message = $data ; //ADD ATTACHEMENT //$mail->add_attachment ($data, $filename, $content_type) ; //SEND EMAIL //$mail->send() ; ////EBD SEND EMAIL WITH ATTACHMENT ////MIME CLASS class mime_mail { var $parts; var $to; var $from; var $headers; var $subject; var $body ; /* * void mime_mail() * class constructor */ function mime_mail () { $this->parts = array() ; $this->to = "" ; $this->from = "" ; $this->subject = "" ; $this->body = "" ; $this->headers = "" ; } /* * void add_attachement (string message, [string name], [string ctype]) * Add an attachment to the mail object */ function add_attachment ($message, $name = "", $ctype = "text/html jpeg" ) //function add_attachment ($data, $fileX, $content_type ) { echo "CTYPE IN AA :"."$ctype"."<br>" ; //echo "MESSAGE IN AA :"."$message"."<br>" ; echo "ENCODE IN AA: "."$encode"."<br>" ; echo "NAME IN AA :"."$name"."<br>" ; //echo "DATA IN AA :"."$data"."<br>" ; $partsd = $this->parts[] = array ( "ctype" => $ctype, "message" => $message, "encode" => $encode, "name" => $name, ); echo ("ARRAY#1 CTYPE :"."$partsd[ctype]"."<br>") ; //echo ("ARRAY#2 MESSAGE :"."$partsd[message]"."<br>") ; echo ("ARRAY#3 ENCODE :"."$partsd[encode]"."<br>") ; echo ("ARRAY#4 NAME :"."$partsd[name]"."<br>") ; //echo ("ARRAY#5 DATA :"."$partsd[data]"."<br>") ; $sizeX=sizeof($this->parts) ; echo "SIZE OF ARRAY IN ADD ATTACHMENT:"."$sizeX"."<br>" ; } /* * void build_message (array part= * Build message parts of an multipart mail */ function build_message ($part ) { $message = $part[ "message"]; //echo "MESSAGE IN BUILD:"."$message"."<br>" ; $message = chunk_split(base64_encode($message)) ; //echo "MESSAGE :"."$message"."<br>" ; $encoding = "base64" ; $partctype = $part["ctype"] ; $partname = $part["name"] ; echo "PART CTYPE :"."$partctype"."<br>" ; echo "PART NAME :"."$partname"."<br>" ; return "Content-Type: ".$part["ctype"]. ($part["name"]?" ; name =\"". $part["name"]. "\"":""). "\nContent-Transfer-Encoding: $encoding\n\n$message\n" ; } /* * void build_multipart() * Build a multipart mail */ function build_multipart() { $boundary = "b".md5(uniqid(time())) ; $multipart = "Content-Type: multipart/mixed; boundary = $boundary\n\nThis is a MIME encoded message.\n\n--$boundary" ; //$sizeX=sizeof($this->parts) ; //echo "SIZE OF ARRAY :"."$sizeX"."<br>" ; for ($i = sizeof($this->parts)-1; $i >= 0; $i--) { $multipart .= "\n".$this->build_message($this->parts[$i])."--$boundary" ; //echo "MULTIPART :"."$multipart"."<br>" ; } return $multipart.= "--\n" ; } /* * string get_mail() * returns the constructed mail */ function get_mail($complete = true) { $complete = true ; echo "COMPLETE :"."$complete"."<br>" ; ////STAEMENT ADDED TO FORCE IF ($COMPLETE) {} BELOW TO RUN //echo "MESSAGE IN GET MAIL:"."$message"."<br>" ; $mime = "" ; if (!empty($this->from)) $mime .= "From: ".$this->from. "\n" ; echo "MIME 1:"."$mime"."<br>"; if (!empty($this->headers)) $mime .= $this->headers. "\n" ; echo "MIME 2:"."$mime"."<br>"; if ($complete) { echo "MIME 3:"."$mime"."<br>"; if (!empty($this->to)) { $mime .= "To: $this->to\n" ; echo "MIME 4:"."$mime"."<br>"; } if (!empty($this->subject)) { $mime .= "Subject: $this->subject\n" ; echo "MIME 5:"."$mime"."<br>"; } } if (!empty($this->body)) $this->add_attachment($this->body, "", "text/html"); echo "MIME 55:"."$mime"."<br>"; $mime .= "MIME-Version: 1.0\n".$this->build_multipart() ; echo "MIME 6:"."$mime"."<br>"; return $mime; } /* * void send() * Send the mail (last class-function to be called) */ //function send ($message, $data, $fileX, $content_type) function send () { //$bodyY=$this->body ; //echo "BODYY :"."$bodyY"."<br>" ; $mime=$this->get_mail () ; echo "MIME 7:"."$mime"."<br>" ; mail($this->to, $this->subject, "" , $mime) ; //mail($this->to, $this->subject, $this->body, $mime) ; } } ; ////END OF MIME CLASS CODE ///////////////////////////////////////////////////////////////// ?>END CODE: I had another thread about a problem I was having where it's not loading from the DB right aways. My solution is to make an update function and then have the id's calling it on the page. So the thing I am wondering is how to make a working update function. I have this so far: <?php include blah.... $uid = $_SESSION["user"][0]; $avatarid = $_SESSION["user"][12]; function update($str) { global $db_id; $query="select ".$str." from users where id=".$uid; $result=mysql_query($query, $db_id); $row=mysql_fetch_row($result); return $row[0]; } ?> and then it's being called on the profile page with <?php echo update($avatarid); ?>. I want the update() function to select avatar from users where id = userid and then return the value fresh so it's getting it new from the database every time they refresh the page. Then there won't be a problem with updating old avatar stuff. Currently gives me the error: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/root/public_html/func.php on line 69 So what am I doing wrong here? thanks for anyone who can help Hi All, I am a newbie to php and I have this issue. I would appreciate if anyone can help out. I tried a few things but was not able to come up with a solution. From reading few codes and learning from it, I created this function in query.php and am calling this function in uk.php file, but the problem is that it loads and shows the data in table, but then it stops loading page from there on and the footer which is in html code after the place where I am calling this function does not load. I tried removing return false; command, but with that it loads the footer, but it shows the table after the footer. I want the table with data to show in between header and footer. Can you guys let me know what I need to do to achieve that? File Name: query.php
function uk() { $output = ''; $result = db_query("SELECT * FROM lecture where groups='uk'"); if(mysqli_num_rows($result) > 0) { $output .= '<div id="style2" style="overflow-x:auto;"> <table> <tr> <th class="text-center">Date</th> <th class="text-center">Title</th> <th class="text-center">Venue</th> <th class="text-center">Duration</th> <th class="text-center">Size (MB)</th> <th class="text-center">Link</th> </tr>'; while($row = mysqli_fetch_array($result)) { $output .= ' <tr> <td>'.$row["mydate"].'</td> <td>'.$row["title"].'</td> <td>'.$row["venue"].'</td> <td>'.$row["duration"].'</td> <td>'.$row["size"].'</td> <td><a href="../'.$row["path"].$row["file_name"].'">Save</a></td> </tr> '; } echo $output; } else { echo 'Data Not Found'; } }
File Name: uk.php
Header html code here Some body text <?php include '../includes/query.php'; uk(); return false; ?> Footer html code here
Hi all , in my scripts I have a drop list and its <option> values are retrieved from sql database , and once I choose any value from the drop list the value will shown in a textbox . It's functioning well in firefox and opera except IE , is there any way to solve this problem? Code: [Select] <html> <head> <title>Untitled</title> </head> <body> <form name="theform" onsubmit="CheckForm()"> <?php $query="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($query); ?> <select name="myOptions" onchange="document.theform.showValue.value=this.value" > <? while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "<option >$nt[Custgroup]</option>"; } ?> <input type="text" name="showValue"><br> </form> </body> </html> Thanks for every reply . I have this code on my user registration form Code: [Select] <?php $flg = ""; $error = ""; if (isset($HTTP_GET_VARS["flg"])) $flg = $HTTP_GET_VARS["flg"]; switch ($flg) { case "yellow": $error = "<br><font class=\"txt12_red\">That Email Address already exists in our Database.<br>Please Select Another.<BR></font>"; break; case "red": $error = "<br><font class=\"txt12_red\">Please fill out all the required fields.<br>Please Try Again.<BR></font>"; break; case "blue": $error = "<br><font class=\"txt12_red\">Your Session has Expired.<br>Please Login Again.</font><BR>"; break; case "pink": $error = "<br><font class=\"txt12_red\"><BR>The Special Code you entered is not valid.<br>Please Try Again or Leave that field blank. </font><BR>"; break; case "white": $error = "<br><font class=\"txt12_red\"><BR>The fields are too long for our Database.<br>Please correct your data via this form.</font> <BR>"; break; default: $error = ""; } ?> and the registered form / page I have this validation and function Code: [Select] <?php // check to see if these variables have been set... if ((!isset($_SESSION["fname"])) || (!isset($_SESSION["lname"])) || (!isset($_SESSION["email"])) || (!isset($_SESSION["phone"])) || (!isset($_SESSION["city"])) || (!isset($_SESSION["status"])) || (!isset($_SESSION["province"]))) { resendToForm("?flg=red"); } // form variables must have something in them... if ($_SESSION['fname'] == "" || $_SESSION['lname'] == "" || $_SESSION['email'] == "" || $_SESSION['phone'] == "" || $_SESSION['city'] == "" || $_SESSION['status'] == "" || $_SESSION['province'] == "") { resendToForm("?flg=red"); } // make sure fields are within the proper range... if (strlen($_SESSION['fname']) > 35 || strlen($_SESSION['lname']) > 35 || strlen($_SESSION['email']) > 35 || strlen($_SESSION['phone']) > 35 || strlen($_SESSION['city']) > 35 || strlen($_SESSION['status']) > 35 || strlen($_SESSION['province']) > 35 || strlen($_SESSION['password']) > 30) { resendToForm("?flg=white"); } function resendToForm($flags) { reset ($_POST); // store variables in session... while (list ($key, $val) = each ($_POST)) { $_SESSION[$key] = $val; } // go back to the form... //echo $flags; header("Location: ./registration_form.php".$flags); exit; } ?> The validation is working as it goes back to user registration form, the problem is it's not displaying the error on Code: [Select] <?php echo $error; ?> What seems to be the problem? anyone? I am trying to make a ban function and i have the users id being passed through the URL and i can't seem to get it working.
<?php require 'connect.php'; include 'header.php'; error_reporting(E_ALL | E_NOTICE); session_start(); $ban = "SELECT id FROM $tbl_name WHERE id={$_GET['id']} AND active='$active'"; $banres = $con->query($ban); $row = $con->fetch_assoc($banres); $active = $row['active']; if($banres) { $active_update = "UPDATE $tbl_name SET active=0"; } ?> This is the function I wrote function getParagraph($myfile) { while (!feof($myfile)){ $data = fgets($myfile); $paragraph = explode("\n", $data); } return $paragraph; } When I print the array, it's empty. while ($paragraph = getParagraph($file)){ print_r($paragraph); } Prints to my webpage as: Array ( => ) The file is NOT empty, and it is formated by line breaks so I don't know what's not working. I am still new to programming PHP and this is the first time I am creating a function. Here is where I pull the function (scroll down to commented area) <table width="250" border="0" cellpadding="2" cellspacing="0"> <tr> <td width="145"><strong>Province:</strong></td> <td colspan="2" align="right"><? echo $prov ?></td> </tr> <tr> <td><strong>Postal:</strong></td> <td colspan="2" align="right"><? echo $postal ?></td> </tr> <tr> <td><strong>Lbs:</strong></td> <td colspan="2" align="right"><? echo $lbs ?></td> </tr> <tr> <td colspan="3"> </td> </tr> </table> <img src="/images/carriers/canpar.png" border="0"/> <table width="250" border="0" cellpadding="2" cellspacing="0"> <?php if ($debugmode == 'on') { ?> <tr> <td><strong>Cost:</strong></td> <td width="14" align="right"><strong>$</strong></td> <td width="71" align="right"><? echo number_format($dzone, 2, '.', '') ?></td> </tr> <?php if ($cp_markup != "") { ?><tr> <td><strong>Markup:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_mark, 2, '.', '') ?></td> </tr><?php } ?> <? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); } Else { ?> <tr> <td><strong>Price:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? $price = ( number_format($cp_mark, 2, '.', '') +number_format($dzone, 2, '.', '') ); echo number_format($price, 2, '.', ''); ?></td> </tr> <? } ?> <?php if ($cp_fuelcharge != "") { ?><tr> <td><strong>Fuel Charge:</strong></td> <td align="right"><strong>$</strong></td> <td align="right"><? echo number_format($cp_fuelcharge, 2, '.', '') ?></td> </tr><?php } ?> <?php taxcalc(); //Here is the function pull echo $taxrow; // this is supposed to be defined in the function ?> <tr> <td class="priceresults"><strong>Total:</strong></td> <td align="right"class="priceresults"><strong>$</strong></td> <td align="right"class="priceresults"><?php $total = ( number_format($price, 2, '.', '') + number_format($tax, 2, '.', '') ); echo number_format($total, 2, '.', ''); ?></td> </tr> </table> Here is my taxcalc() function: function taxcalc() { if ($prov == "AB") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "BC") { $hst = '12%'; $hstcalc = '0.12'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "MB") { $gst = '5%'; $pst = '7%'; $gstcalc = '0.05'; $pstcalc = '0.07'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "ON") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NB") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NL") { $hst = '13%'; $hstcalc = '0.13'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NS") { $hst = '15%'; $hstcalc = '0.15'; $tax = $price * $hstcalc; $taxrow = "<tr><td>HST ($hst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "NU") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } if ($prov == "PE") { $gst = '5%'; $pst = '10%'; $gstcalc = '0.05'; $pstcalc = '0.10'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "QC") { $gst = '5%'; $pst = '7.5%'; $gstcalc = '0.05'; $pstcalc = '0.075'; $gtax = $price * $gstcalc; $ptax = ($price + $gtax) * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "SK") { $gst = '5%'; $pst = '5%'; $gstcalc = '0.05'; $pstcalc = '0.05'; $gtax = $price * $gstcalc; $ptax = $price * $pstcalc; $tax = $gtax + $ptax; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($gtax, 2, '.', '') . "</td></tr><tr><td>PST ($pst):</td><td align='right'><strong>$</strong></td><td>" . number_format($ptax, 2, '.', '') . "</td></tr>"; } if ($prov == "YT") { $gst = '5%'; $gstcalc = '0.05'; $tax = $price * $gstcalc; $taxrow = "<tr><td>GST ($gst):</td><td align='right'><strong>$</strong></td><td>" . number_format($tax, 2, '.', '') . "</td></tr>"; } } I am not getting any errors, just nothing is showing up. My results show up as: Code: [Select] Province: ON Postal: K2C Lbs: 25 Cost: $ 22.57 Markup: $ 0.00 Fuel Charge: $ 5.00 Total: $ 22.57 After Fuel Charge should be my taxes but they do not show up hello. On my function page I have this function. function GetClub($clubs) { $qFindClub = "SELECT * FROM clubs WHERE memberID = '$clubs'"; $rFindClub = mysql_query($qFindClub); $Club = mysql_fetch_array($rFindClub); return $Club; } now when I feed it the variable $myID. If I try to echo say the club name $Clubs = GetClub($myID); echo $Clubs['name']; Nothing happens as its not working properly. Can anybody see what I have done wrong? deleting works, but can't seem to get the add to work???? any ideas Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Search User</title> <link href="stylesheet1.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <style type="text/css"> body { font-size:12px; font-family:Arial, Helvetica, sans-serif; } form { display:block; width:260px; } form .input{ width:120px; float:right; } form label { display:block; width:260px; clear:both; } form textarea { display:block; width:260px; } </style> <script type="text/javascript"> // alert("document loaded 1"); // $(document).ready(function(){ //$("#projectid").html("1"); // alert("document loaded 1"); function userlistgenerate(){ var data = { "operation" : "userlist", "users": [ { "userid" : "usr_id"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('UserSearchPBT.php', { data: dataString}, userlistResult, "text"); $("#selectedUserName").html(""); // $("selectedUserName").hide("fast"); } function userlistResult(res) { var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#userlist").html(obj.ResultData); $("#selectedUserName").html(""); //$("selectedUserName").hide("fast"); } function UserSearchChoose(userid,username ,name,surname,email,phone,mobphone,isactive){ $("#userid").val(userid); $("#username").val(username); $("#name").val(name); $("#surname").val(surname); $("#email").val(email); $("#phone").val(phone); $("#mobphone").val(mobphone); $("#isuseractive").val(isactive); $("#useradd").hide("fast"); } function usersearch() { $("#useradd").show(); var name=$("#name").attr("value"); var surname=$("#surname").attr("value"); var data = { "operation" : "usersearch", "user": [ { "name" : name, "surname" : surname } ] // end of sales array } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, usersearchResult, "text"); } function usersearchResult(res) { var obj = $.evalJSON(res); $("#userlist").html(obj.ResultData); } function userdelete() { var useridval = $("#userid").attr("value"); alert (useridval); var data = { "operation" : "teamdelete", "userid" : useridval } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); } function userdeleteResult(res) { var obj = $.evalJSON(res); $("#successfailmessage").html(obj.SuccFailMessage); userlistgenerate(); } function useradd() { //alert ("team add a geliyor"); var userId = $("#userid").attr("value"); var username = $("#username").attr("value"); var usersurname = $("#surname").attr("value"); var useremail = $("#useremail").attr("value"); var userphone = $("#userphone").attr("value"); var usermob = $("#usermob").attr("value"); var useractive = $("#useractive").attr("value"); // alert ("--".projectId."-".userId."-".rolId."--"); var data = { "operation" : "useradd", "userId" : userId, "username" : username, "useremail" : useremail, "userphone" : userphone, "usermob" : usermob, "useractive" : useractive, "recuser" : 1 } var dataString = $.toJSON(data); $.post('UserSearchPBT.php', { data: dataString}, userdeleteResult, "text"); alert ("user add a geliyor ajax bitti"); } </script> </head> <body> <form id="iletisim"> <div id="formdiv"> <table><tr> <td><span id="successfailmessage"></span></td> <tr><td><span id="userlist"></span> </td></tr> <tr><td><span id="selectedUserName"></span></td></tr> <tr><td><label for="name">User Name<input class="input" name="username" id="username" type="text" value="" /></label></td></tr> <tr><td><label for="name">Name<input class="input" name="name" id="name" type="text" value="" /></label></td></tr> <tr><td><label for="surname">Surname<input class="input" name="surname" id="surname" type="text" value="" /></label><tr> <tr><td><label for="email">Email<input class="input" name="email" id="email" type="text" value="" /></label><tr> <tr><td><label for="phone">Phone<input class="input" name="phone" id="phone" type="text" value="" /></label><tr> <tr><td><label for="phone">Mobile Phone<input class="input" name="mobphone" id="mobphone" type="text" value="" /></label><tr> <tr><td><label for="phone">Is User Active(Y/N)<input class="input" name="isuseractive" id="isuseractive" type="text" value="" /></label></td></tr> <tr><td><a href='#' onclick="javascript:usersearch();">Search User</a> </td></tr><tr> <tr><td><a href='#' id="useradd" onclick="javascript:useradd();">Add</a> </td></tr><tr> <tr><td><a href='#' id="userdelete" onclick="javascript:userdelete();">Delete</a> </td></tr><tr> <tr><td><a href='#' id="userupdate" onclick="javascript:userupdate();">Update</a> </td></tr><tr> </table> <input type="hidden" id = "userid" value="" name="userid" /> </div> </form> </body> </html> Code: [Select] It is not outputting anything after the third echo. This is where it is http://sambender.com/brandon/review.php?subject=Math%20Problems echo "<table border='0'><tr><td><div id='question'><b>Question:</b><br/>$question</div></td></tr>"; echo "<tr><td><div id='answer' style='display:none;'><b>Answer:</b><br/>$answer</div>"; echo "<a href=\"javascript:showdiv('answer')\">Show Answer</a></td></tr>"; echo "<td><tr><a href='submitanswer.php?correct?=yes&correctid=$correctid>I got this correct!</a></tr></td></table>"; It just outputs Code: [Select] <table border='0'><tr><td><div id='question'><b>Question:</b><br/>What is your name?</div></td></tr><tr><td><div id='answer' style='display:none;'><b>Answer:</b><br/>Rooba holabint</div><a href="javascript:showdiv('answer')">Show Answer</a></td></tr><td><tr> Hello, The mail function works on my one website but it won't on my other site. On the site that it won't work on, I'm trying to email the contents of the cart. I tested it out and it diplays the contents of the cart properly if I echo $email. I don't get any errors on the site, it seems to process but I don't receive any emails. here is my code for process.php: Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','1'); require_once("connect.php"); ?> <?php $check=$_POST['check']; /* code that outputs the cart contents and totals up the cart */ $cartOutput=""; $total="0"; // start the foreach loop to go through each item in the cart array $i=0; foreach($_SESSION["cart_array"] as $each_item) { $item_id=$each_item['id']; $prod_id=$each_item['product_id']; // distiguish between a regular item and a gift box switch ($prod_id) { // if it is a gift box case "12": // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic checkout button assembly // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40% valign=center><font face=arial color='#999999'>Wrap my products in a Gift Box</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']." </td> <td width=5%><font color='#999999'>$".$price.".00</font></td> <td width=10%><font color='#999999'>$".$subtotal.".00</font></td> </tr> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is a Reed Diffuser Bottle case "17": // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName, products.productDesc FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; $desc=$row['productDesc']; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic checkout button assembly // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40% valign=center><font face=arial color='#999999'>".$desc."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']."</td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is a salve case "3": $salveId=substr($each_item['id'],2,4); $prodId=substr($each_item['id'],0,1); // Get product name and price $sql=mysql_query("SELECT * FROM salves WHERE productId='$salveId' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $scent=$row['productName']; } $sql=mysql_query("SELECT * FROM products WHERE productId='$prodId' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $price=$row['productPrice']; $product_name=$row['productName']; } if(isset ($_SESSION["cart_array"] )) { $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".$each_item['id']."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40%><font face=arial color='#999999'>".$scent."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']." </td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr></form> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; // if it is not a gift box or sale/clearance item default : $scent=substr($each_item['scent'],0,4); // Get product name and price $sql=mysql_query("SELECT products.productPrice, products.productName FROM products WHERE productId='$prod_id' LIMIT 1"); while ($row=mysql_fetch_array($sql)) { $product_name=$row["productName"]; $price=$row["productPrice"]; } // get scent for regular product $sql2=mysql_query("SELECT productscents.scentName FROM productscents WHERE scentId='$scent' LIMIT 1"); while ($row2=mysql_fetch_array($sql2)) { $scent=$row2['scentName']; } $subtotal=$price*$each_item['quantity']; $total=$subtotal + $total; if(isset ($_SESSION["cart_array"] )) { // dynamic cart item display $cartOutput.="<tr align=center> <td width=5%><font face=arial color='#999999'>".substr($each_item['id'],0,7)."</font></td> <td width=25%><font face=arial color='#999999'>".$product_name."</font></td> <td width=40%><font face=arial color='#999999'>".$scent."</font></td> <td valign=center width=5%><font face=arial color='#999999'>".$each_item['quantity']."</td> <td width=5%><font face=arial color='#999999'>$".$price.".00</font></td> <td width=10%><font face=arial color='#999999'>$".$subtotal.".00</font></td> </tr></form> <tr> <td colspan=6><hr size=1 width=50% color='#CBB659'/></td></tr>"; } // end if statement to see if cart is empty break; } // end switch } // end foreach that goes through each item in the cart /* Code that generates the email */ $ans=$_SESSION['check']; $check=$_POST['check']; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // customer information $firstName = strip_tags($_POST['firstName']); $lastName = strip_tags($_POST['lastName']); $address = strip_tags($_POST['address']); $city = strip_tags($_POST['city']); $prov = strip_tags($_POST['prov']); $postalCode = strip_tags(strtoupper($_POST['postal'])); $emailAddress = strip_tags($_POST['email']); $payment = $_POST['payment']; $ship = $_POST['shipping']; // email subject $subject= "Online Order Request"; // email address the form will be submitted to $myemail="orders@coppercreekbathandbody.ca"; if ($firstName!="" && $lastName!="" && $address!="" && $city!="" && $prov!="" && $postalCode!="" && $emailAddress!="" && $ans==$check) { $email="<html><center> <table border=0 width=100% cellspacing=0 cellpadding=5 style='background:#1d1d1d' > <tr> <td colspan=6><center><h2><font color=#999999>$subject</font></h2></center></td> </tr> <tr valign=center > <td colspan=6 align=center valign=center><font face=arial color=#999999> $firstName $lastName<br> $address<br> $city, $prov $postalCode<br> $emailAddress </font><br><br> </td> </tr> <tr align=center style='background: #333'> <td width=8%><font face=arial color=#999999>Item #</font></td> <td width=25%><font face=arial color=#999999>Product</font></td> <td width=40%><font face=arial color=#999999>Description</font></td> <td width=4%><font face=arial color=#999999>Quantity</font></td> <td width=4%><font face=arial color=#999999>Price</font></td> <td width=10%><font face=arial color=#999999>Total Cost</font></td> </tr> <tr><font face=arial> $cartOutput </font></tr> <tr style='background: #333'> <td colspan=5 align=right><font face=arial color=#999999>Total Price:</font></td> <td align=center><font face=arial color=#999999>$".$total.".00 </font></td> </tr> <tr> <td colspan=4 align=right valign=center> <font face=arial color=#999999>Payment Method: </font> </td> <td colspan=2 align=right valign=center> <font face=arial color=#999999>$payment</font> </td> </tr> <tr> <td colspan=4 align=right valign=center> <font face=arial color=#999999>Shipping: </font> </td> <td colspan=2 align=right valign=center> <font face=arial color=#999999>$ship</font> </td> </tr> </table></center></body></html>"; mail($myemail, $subject, $email, $headers); unset($_SESSION['check']); header("location: success.php"); } else { unset($_SESSION['check']); } customerInformation.php Code: [Select] <?php session_start(); error_reporting(E_ALL); ini_set('display_errors','1'); require_once("connect.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <script type="text/javascript" src="./js/functions.js"></script> <link rel="stylesheet" type="text/css" href="./css/navigationStyles.css"/> <script language=javascript type=text/javascript> function stopRKey(evt) { var evt = (evt) ? evt : ((event) ? event : null); var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); if ((evt.keyCode == 13) && (node.type=="text")) { return false; } } document.onkeypress = stopRKey; </script> </head> <body> <div id='wrapper'> <div id='main'> <table border=0 width=70% cellspacing=10 cellpadding=5 id=table> <tr> <td colspan=6> <center><img src="./images/customerInfoLogo.gif"><br> <table border=0 width=90%> <tr> <td width=33% align=right> <a href='index.php'>HOME</a> </td> <td width=34%></td> <td width=33% align=left> <a href='cart.php'>VIEW CART</a> </td> </tr> </table> <br><br> </center> </td> </tr> <tr> <td colspan=6 align=center valign=center> <form action="process.php" name='order' method="post" onsubmit="document.getElementById('button').disabled=true; document.getElementById('button').value='Submitting, please wait...';"> <!-- REQUEST ORDER TABLE --> <table width=90% border=0 cellspacing=5 cellpadding=5> <!-- CLIENT NAME --> <tr valign=center> <td width=50% align=right> First Name: </td> <td width=50% align=left> <input type=text maxlength=40 width=40px class=contactBox id=firstName name="firstName" onBlur="validate(this.id);"> </td> </tr> <tr valign=center> <td width=50% align=right> Last Name: </td> <td width=50% align=left> <input type=text maxlength=40 width=40px onBlur='validate(this.id);' class=contactBox id=lastName name="lastName"> </td> </tr> <!-- ADDRESS --> <tr valign=center> <td width=50% align=right> Address: </td> <td width=50% align=left> <input type=text width=40px id=address class=contactBox name="address" onBlur='validate(this.id);'> </td> </tr> <!-- CITY --> <tr valign=center> <td width=50% align=right> City: </td> <td width=50% align=left> <input type=text width=40px id=city class=contactBox name="city" onBlur='validate(this.id);'> </td> </tr> <!-- Province --> <tr valign=center> <td width=50% align=right> Province: </td> <td width=50% align=left> <select name="prov"> <option value="AB">Alberta</option> <option value="BC">British Columbia</option> <option value="MB">Manitoba</option> <option value="NB">New Brunswick</option> <option value="NL">Newfoundland & Labrador</option> <option value="NT">Northwest Territories</option> <option value="NS">Nova Scotia</option> <option value="NU">Nunavut</option> <option value="ON">Ontario</option> <option value="PE">Prince Edward Island</option> <option value="QC">Quebec</option> <option value="SK" selected>Saskatchewan</option> <option value="YT">Yukon</option> </select> </td> </tr> <!-- POSTAL CODE --> <tr valign=center> <td width=50% align=right> Postal Code: </td> <td width=50% align=left> <input type=text width=40px id=postal class=contactBox name="postal" maxlength=7'> </td> </tr> <!-- EMAIL ADDRESS --> <tr valign=center> <td width=50% align=right> Email: </td> <td width=50% align=left> <input type=text width=60px id=email class=contactBox name="email" onBlur='validateEmail(this.id);'> </td> </tr> <!-- PAYMENT TYPE --> <tr valign=center> <td width=50% align=right> Payment Type: </td> <td width=50% align=left> <select name="payment"> <option value="Email Money Transfer" selected>Email Money Transfer</option> <option value="Cash">Cash</option> <option value="Money Order">Money Order</option> </select> </td> </tr> <!-- SHIPPING --> <tr valign=center> <td width=50% align=right> Need your order shipped: </td> <td width=50% align=left> <select name="shipping"> <option value="Don't Ship" selected>Don't Ship</option> <option value="Ship Order">Ship Order</option> </select> </td> </tr> <tr> <td colspan=2> <img src='captcha.php'> <input type='text' class=cap size=4 width=3 maxlength=4 onKeyPress='return check_qty(event);' name='check'> </td> </tr> <tr> <td colspan=2 valign=top> <input type=submit value='SEND ORDER' class='updateButton' id=button> <input type=reset value='CANCEL ORDER' class='updateButton' id=button onClick="location.href='home.php'"> </td> </tr> </table> </form> </td> </tr> </table> </div> <div id="sidebar" > <?php require ("menu.html"); ?> </div> </div> </body> </html> I have no idea what is happening. It should be displaying an html formatted email. Any help is greatly appreciated. I thought this was pretty straight forward, but it is not working. Titlecase is supposed to capitalize the first letter of every with except for certain words in $smallarr. Instead, it capitalizes every word. What's wrong here? //==================================================== function crTitlecase($s) /* Capitalize every word in a sentence except certain small words. */ { //Keep $smallarr in alpha order! //Do not capitalize these words. $smallarr=array('a','above','and','an','at','by','for','if'); $smallarr=array($smallarr,'into','is','it','of','off'); $smallarr=array($smallarr,'on','or','over','the','to'); $smallarr=array($smallarr,'with','without'); //$smallarr=($smallarr,); $t=strtolower($s); //First change all ltrs to lowercase. $words = explode(' ', $t); foreach ($words as $mykey => $word) { //if ((!$mykey) or (!in_array($word, $smallarr)) ) if ( (!in_array($word, $smallarr)) ) { $s='mykey='.$mykey.', word='.$words[$mykey]; crDebug($s); $words[$mykey] = ucwords($word); } } $newtitle = implode(' ', $words); return $newtitle; } Whenever try to use the PHP mail function on my local server it also fails but then when I upload my scripts to my webspace they work fine. I think there must be something wrong with my php.ini file. Below I have copied the mail function section of my php.ini file. [mail function] ; For Win32 only. SMTP = localhost smtp_port = 25 ; For Win32 only. ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). sendmail_path = sendmail -t -i ; Force the addition of the specified parameters to be passed as extra parameters ; to the sendmail binary. These parameters will always replace the value of ; the 5th parameter to mail(), even in safe mode. ;mail.force_extra_parameters = Thanks for any help. im trying to return the highest value in my table from the season_id column this is the code i have: Code: [Select] $test = mysql_query("SELECT * FROM `$show` WHERE [season_id]=(SELECT Max([season_id]) FROM `$show`)"); please advise? Hi, I'm making an RSS feed http://dev.subverb.net/mixes_rss.php and as you see the date('r', $row['date']) function is not converting it. I've echo'd $row['date'] into the description to show what format the date is in (just mysql datetime. Am I missing something? Thanks |