Search Results

Search found 3286 results on 132 pages for 'arthur br'.

Page 26/132 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • How to optimize this algorithm?

    - by Bakhtiyor
    I have two sets of arrays like this for example. $Arr1['uid'][]='user 1'; $Arr1['weight'][]=1; $Arr1['uid'][]='user 2'; $Arr1['weight'][]=10; $Arr1['uid'][]='user 3'; $Arr1['weight'][]=5; $Arr2['uid'][]='user 1'; $Arr2['weight'][]=3; $Arr2['uid'][]='user 4'; $Arr2['weight'][]=20; $Arr2['uid'][]='user 5'; $Arr2['weight'][]=15; $Arr2['uid'][]='user 2'; $Arr2['weight'][]=2; The size of two arrays could be different of course. $Arr1 has coefficient of 0.7 and $Arr2 has coefficient of 0.3. I need to calculate following formula $result=$Arr1['weight'][$index]*$Arr1Coeff+$Arr2['weight'][$index]*$Arr2Coeff; where $Arr1['uid']=$Arr2['uid']. So when $Arr1['uid'] doesn't exists in $Arr2 then we need to omit $Arr2 and vice versa. And, here is an algorithm I am using now. foreach($Arr1['uid'] as $index=>$arr1_uid){ $pos=array_search($arr1_uid, $Arr2['uid']); if ($pos===false){ $result=$Arr1['weight'][$index]*$Arr1Coeff; echo "<br>$arr1_uid has not found and RES=".$result; }else{ $result=$Arr1['weight'][$index]*$Arr1Coeff+$Arr2['weight'][$pos]*$Arr2Coeff; echo "<br>$arr1_uid has found on $pos and RES=".$result; } } foreach($Arr2['uid'] as $index=>$arr2_uid){ if (!in_array($arr2_uid, $Arr1['uid'])){ $result=$Arr2['weight'][$index]*$Arr2Coeff; echo "<br>$arr2_uid has not found and RES=".$result; }else{ echo "<br>$arr2_uid has found somewhere"; } } The question is how can I optimize this algorithm? Can you offer other better solution for this problem? Thank you.

    Read the article

  • How to handle ASP.NET application error that occurs on application start and transfer & display erro

    - by Soul_Master
    I know that ASP.NET MVC has error filter attribute to handle specified error type. However, this feature cannot catch any error that occurs when application start. Therefore, I need to add some code to “Application_Error” method for handling this error like the following code. public void Application_Error(object sender, EventArgs e) { // At this point we have information about the error var ctx = HttpContext.Current; var exception = ctx.Server.GetLastError(); var errorInfo = "<br>Offending URL: " + ctx.Request.Url + "<br>Source: " + exception.Source + "<br>Message: " + exception.Message + "<br>Stack trace: " + exception.StackTrace; ctx.Response.Write(errorInfo); Server.ClearError(); } Although, this code will works fine, when normal application error occurs like error that occurs in view page. Nevertheless, it does not work when error occurs on application starting because request and response objects are always null. Next, I try to solve this question by setting default redirect in custom errors like the following code. <customErrors mode="On" defaultRedirect="Scripts/ApplicationError.htm"></customErrors> Unfortunately, it does not work because when application receive redirected request, it try to start application again and it throw exception again. How do to solve this problem? Alternatively, Do you have other idea for handling this error. Thanks, PS. The main reason for creating this handler because I want to display error when application cannot connect to other service like database for caching data on application start.

    Read the article

  • Getting Selected Dropdown content to show in a form-generated email

    - by fmz
    I have a small contact form: <form method="post" action="contact.php" name="contactform" id="contactform"> <fieldset> <legend>Please fill in the following form to contact us</legend> <label for="name"><span class="required">*</span> Your Name</label> <input name="name" type="text" id="name" size="30" value="" /> <br /> <label for="company"><span class="required">*</span> Company</label> <input name="company" type="text" id="name" size="30" value="" /> <br /> <label for="email"><span class="required">*</span> Email</label> <input name="email" type="text" id="email" size="30" value="" /> <br /> <label for="phone"><span class="required">*</span> Phone</label> <input name="phone" type="text" id="phone" size="30" value="" /> <br /> <label for="purpose"><span class="required">*</span> Purpose</label> <select id="purpose" style="width: 300px; height:35px;"> <option value="I am interested in your services">I am interested in your services!</option> <option value="I am interested in a partnership">I am interested in a partnership!</option> <option value="I am interested in a job">I am interested in a job!</option> </select> <br /> <label for=comments><span class="required">*</span> Comments</label> <textarea name="comments" cols="40" rows="3" id="comments" style="width: 350px;"></textarea> <p><span class="required">*</span> Please help us control spam.</p> <label for=verify accesskey=V>&nbsp;&nbsp;&nbsp;3 + 1 =</label> <input name="verify" type="text" id="verify" size="4" value="" style="width: 30px;" /><br /><br /> <input type="submit" class="submit" id="submit" value="Submit" /> </fieldset> </form> I want to send the results of the form in a php generated email. Everything is coming through except the selected contents of the "purpose" drop down. Here is the PHP: <?php if(!$_POST) exit; $name = $_POST['name']; $company = $_POST['company']; $email = $_POST['email']; $phone = $_POST['phone']; $purpose = $_POST['purpose']; $comments = $_POST['comments']; $verify = $_POST['verify']; if(trim($name) == '') { echo '<div class="error_message">Attention! You must enter your name.</div>'; exit(); } else if(trim($company) == '') { echo '<div class="error_message">Attention! Please enter your company name.</div>'; exit(); } else if(trim($email) == '') { echo '<div class="error_message">Attention! Please enter a valid email address.</div>'; exit(); } else if(trim($phone) == '') { echo '<div class="error_message">Attention! Please enter a valid phone number.</div>'; exit(); } else if(!isEmail($email)) { echo '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>'; exit(); } if(trim($comments) == '') { echo '<div class="error_message">Attention! Please enter your message.</div>'; exit(); } else if(trim($verify) == '') { echo '<div class="error_message">Attention! Please enter the verification number.</div>'; exit(); } else if(trim($verify) != '4') { echo '<div class="error_message">Attention! The verification number you entered is incorrect.</div>'; exit(); } if($error == '') { if(get_magic_quotes_gpc()) { $comments = stripslashes($comments); } // Configuration option. // Enter the email address that you want to emails to be sent to. // Example $address = "[email protected]"; $address = "[email protected]"; // Configuration option. // i.e. The standard subject will appear as, "You've been contacted by John Doe." // Example, $e_subject = '$name . ' has contacted you via Your Website.'; $e_subject = 'You\'ve been contacted by ' . $name . '.'; // Configuration option. // You can change this if you feel that you need to. // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here. $e_body = "You have been contacted by $name.\r\n\n"; $e_content = "Comments: \"$comments\"\r\n\n"; $e_company = "Company: $company\r\n\n"; $e_purpose = "Reason for contact: $purpose\r\n"; $e_reply = "You can contact $name via email, $email or via phone $phone"; $msg = $e_body . $e_content . $e_company . $e_purpose . $e_reply; if(mail($address, $e_subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n")) { // Email has sent successfully, echo a success page. echo "<fieldset>"; echo "<div id='success_page'>"; echo "<h1>Email Sent Successfully.</h1>"; echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>"; echo "</div>"; echo "</fieldset>"; } else { echo 'ERROR!'; } } function isEmail($email) { // Email address verification, do not edit. return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email)); } ?> What am I missing? Thanks.

    Read the article

  • Reliable strtotime() result for different languages

    - by Maksee
    There was always a strange bug in Joomla when adding new article with back-end displayed with a language other than English (for me it's Russian). The field "Finish Publishing" started to be current date instead of "Never" equivalent in Russian. For a site in php4 finally found that strtotime function returns different results for arbitrary words. For "Never" it always -1 and joomla relies on this result in the JDate implementation. But in other case it sometimes returns a valid date. For russian translation of Never (???????) it is the case, but also for single "N" it is the case, so if one decided to change the string to some other he or she would face the same issue. So the code below <?php echo "Res:".strtotime("N")."<br>"; echo "Res:".strtotime("Nev")."<br>"; echo "Res:".strtotime("Neve")."<br>"; echo "Res:".strtotime("Never")."<br>"; ?> Outputs: Res:1271120400 Res:-1 Res:-1 Res:-1 So what are the solutions would be in this case? I would like not to write language-specific date.php handler, but to modify date method of JDate class, but what are language-neutral changes would be in order to detect invalid string. Thank you

    Read the article

  • C# Error reading two dates from a binary file

    - by Jamie
    Hi all, When reading two dates from a binary file I'm seeing the error below: "The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'. Parameter name: chars" My code is below: static DateTime[] ReadDates() { System.IO.FileStream appData = new System.IO.FileStream( appDataFile, System.IO.FileMode.Open, System.IO.FileAccess.Read); List<DateTime> result = new List<DateTime>(); using (System.IO.BinaryReader br = new System.IO.BinaryReader(appData)) { while (br.PeekChar() > 0) { result.Add(new DateTime(br.ReadInt64())); } br.Close(); } return result.ToArray(); } static void WriteDates(IEnumerable<DateTime> dates) { System.IO.FileStream appData = new System.IO.FileStream( appDataFile, System.IO.FileMode.Create, System.IO.FileAccess.Write); List<DateTime> result = new List<DateTime>(); using (System.IO.BinaryWriter bw = new System.IO.BinaryWriter(appData)) { foreach (DateTime date in dates) bw.Write(date.Ticks); bw.Close(); } } What could be the cause? Thanks

    Read the article

  • How to parse text fragments located outside tags (inbetween tags) by simplehtmldom?

    - by moogeek
    Hello! I'm using simplehtmldom to parse html and I'm stuck in parsing plaintext located outside of any tag (but between two different tags): <div class="text_small"> <b>?dress:</b> 7 Hange Road<br> <b>Phone:</b> 415641587484<br> <b>Contact:</b> Alex<br> <b>Meeting Time:</b> 12:00-13:00<br> </div> Is it possible to get these values of Adress, Phone, Contact, Meeting Time? I wonder if there is a opportunity to pass CSS Selectors into nextSibling/previousSibling functions... foreach($html->find('div.text_small') as $div_descr) { foreach($div_descr->find('b') as $b) { if ($b->innertext=="?dress:") {//someaction } if ($b->innertext=="Phone:") { //someaction } if ($b->innertext=="Contact:") { //someaction } if ($b->innertext=="Meeting Time:") { //someaction } } } What I should use instead "someaction" ? upd. Yes, I don't have an access for editing the target page. Otherwise, would it be worth to? :)

    Read the article

  • Problem locating file in a classpath

    - by Gandalf StormCrow
    I'm trying to read in file content, ex : public void myMethod(){ FileInputStream fstream = new FileInputStream(fileLocation); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; while ((strLine = br.readLine()) != null) { .... .... ..... end while end method And I have at the begining of the class body private String fileLocation; and at the end of a class I have a getter and setter for it. Now I'm trying inject this file location from spring inside bean from this class and I specify the init-method of this class. But I get error cannot find the specified file as if its not on a classpath but it is inside war file? I'm building the project with maven and I put file in src/main/resources This is the error I get when trying to read file : Error: src\main\resources\ids.txt (The system cannot find the path specified) That is when I tried this : FileInputStream fstream = new FileInputStream("src\\main\\resources\\ids.txt"); how to reference the properly from the classpath? EDIT When I edit my code according to @BalusC solution , here is how it looks but I still get null error : ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); InputStream input = classLoader.getResourceAsStream("src/main/resources/ids.txt"); // Get the object of DataInputStream BufferedReader br = new BufferedReader(new InputStreamReader(input)); String strLine; while ((strLine = br.readLine()) != null) { .... .... ..... end while end method

    Read the article

  • Asp.net PopupControlExtender inside UpdatePabel

    - by user296422
    Hi, So i use PopupControlExtender (to edit some of the fields) inside ListViewControl which itself is embeded inside an UpdatePanel. The problem is as follows whenever you cause partail postback the popup panels are created client side outside the updatepanel. And you get more clientside controls with the same clientside ID. When you postback with popup panel the server side control eg. Texbox has Text = clientsidecontrol1.text, clientsidecontrol2.text, clientsidecontrol.text3 Is there a way to prevent this. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Secure_Test" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %> <!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 runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </cc1:ToolkitScriptManager> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="InputLabel" runat="server" Text="Whatever you put in the textbox"></asp:Label> <br /> <asp:Label runat="server"> <%= DateTime.Now.ToString() %></asp:Label> <br /> <asp:Button ID="Button1" runat="server" Text="Refresh" /> <br /> <asp:LinkButton ID="PopupLB" runat="server">Popup</asp:LinkButton> <br /> <cc1:PopupControlExtender ID="PopupControlExtender1" runat="server" PopupControlID="Panel1" TargetControlID="PopupLB" CommitProperty="Value"> </cc1:PopupControlExtender> <asp:Panel ID="Panel1" runat="server"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:TextBox ID="InputTB" runat="server"></asp:TextBox> <asp:Button ID="SubmitBTN" runat="server" Text="Submit" onclick="SubmitBTN_Click" UseSubmitBehavior="false" /> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using AjaxControlToolkit; public partial class Secure_Test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void SubmitBTN_Click(object sender, EventArgs e) { PopupControlExtender pce = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page); pce.Commit("Popup"); InputLabel.Text = InputTB.Text; } } To make it easier to test i post the code of an example page i used for testing. To make myself clear here is an example: i click Popup. Type "asdf" in the textbox and click Submit. InputPanel dispalys "asdf" i click Popup again. Type "qwerty" in the textbox and click Submit. InputPanel now displays "qwerty,asdf" When you check it the firebug you get this: <form id="form1" action="Test.aspx" method="post" name="form1"> <div> <input type="hidden" value=";;AjaxControlToolkit, Version=3.0.30930.21526, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e:pl-PL:c83bc095-c5d9-40da-b175-dc46338fcc3a:865923e8:91bd373d:596d588c:411fea1c:e7c87f07:bbfda34c:30a78ec5:42b7c466;" id="ToolkitScriptManager1_HiddenField" name="ToolkitScriptManager1_HiddenField"> </div> <script type="text/javascript"> //&lt;![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]&gt; </script> <script type="text/javascript" src="/WebResource.axd?d=B2RAZw_YugtketKJqWIbXA2&amp;t=634051184591131846"></script> <script type="text/javascript" src="/ScriptResource.axd?d=zifZiisoqXYJSwLXuAZ4DmtrWVvn9x0W1r7qfDo40UU7q9QYoa5ChdBZD6dDL66f0flKVDmPL2woIPesut_FUpsFZUN2A5sDN7IOqPUOZO41&amp;t=1a45d080"></script> <script type="text/javascript"> //&lt;![CDATA[ if (typeof(Sys) === 'undefined') throw new Error('Ladowanie struktury strony klienta ASP.NET Ajax nie powiodlo sie.'); //]]&gt; </script> <script type="text/javascript" src="/ScriptResource.axd?d=zifZiisoqXYJSwLXuAZ4DmtrWVvn9x0W1r7qfDo40UU7q9QYoa5ChdBZD6dDL66fyxEJaYB3uJEQ0r_TmOPczeBZ1gpFH5a6x4ug130lptsKAcGA3S1vt08sHQo5sFtH0&amp;t=1a45d080"></script> <script type="text/javascript" src="/Secure/Test.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField&amp;_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d3.0.30930.21526%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3apl-PL%3ac83bc095-c5d9-40da-b175-dc46338fcc3a%3a865923e8%3a91bd373d%3a596d588c%3a411fea1c%3ae7c87f07%3abbfda34c%3a30a78ec5%3a42b7c466"></script> <div> </div> <script type="text/javascript"> //&lt;![CDATA[ Sys.WebForms.PageRequestManager._initialize('ToolkitScriptManager1', document.getElementById('form1')); Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1','tUpdatePanel2'], [], [], 90); //]]&gt; </script> <div> <div id="UpdatePanel1"> <span id="InputLabel">qwerty,asdf</span> <br> <span>2010-06-15 18:26:50</span> <br> <input type="submit" id="Button1" value="Refresh" name="Button1"> <br> <a href="javascript:__doPostBack('PopupLB','')" id="PopupLB">Popup</a> <br> </div> </div> <script type="text/javascript"> //&lt;![CDATA[ (function() {var fn = function() {$get('ToolkitScriptManager1_HiddenField').value = '';Sys.Application.remove_init(fn);};Sys.Application.add_init(fn);})();Sys.Application.initialize(); Sys.Application.add_init(function() { $create(AjaxControlToolkit.PopupControlBehavior, {"CommitProperty":"Value","PopupControlID":"Panel1","dynamicServicePath":"/Secure/Test.aspx","id":"PopupControlExtender1"}, null, null, $get("PopupLB")); }); //]]&gt; </script> <div id="Panel1" style="position: absolute; left: 8px; top: 73px; z-index: 1000; display: none; visibility: hidden;"> <div id="UpdatePanel2"> <input type="text" id="InputTB" name="InputTB"> <input type="button" id="SubmitBTN" onclick="javascript:__doPostBack('SubmitBTN','')" value="Submit" name="SubmitBTN"> </div> </div><span style="display: none ! important;"><input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value=""></span><span style="display: none ! important;"><input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value=""></span><span style="display: none ! important;"><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTkwNzc2NzAzD2QWAgIDD2QWAgIDD2QWAmYPZBYCAgEPDxYCHgRUZXh0BQtxd2VydHksYXNkZmRkZApLPc2nZUC+UkZsCrByuofHMah5"></span><span style="display: none ! important;"><input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBQLi2qWdAwKM54rGBgKIkJujDQKbjp+pDQKc7v+tArliNtJzeG8HrfsGBBXIViJAUGMz"></span><div id="Panel1" style="visibility: hidden; position: absolute; left: 8px; top: 73px; z-index: 1000; display: none;"> <div id="UpdatePanel2"> <input type="text" id="InputTB" value="asdf" name="InputTB"> <input type="button" id="SubmitBTN" onclick="javascript:__doPostBack('SubmitBTN','')" value="Submit" name="SubmitBTN"> </div> </div><div id="Panel1" style="display: none; visibility: hidden; position: absolute;"> <div id="UpdatePanel2"> <input type="text" id="InputTB" value="qwerty,asdf" name="InputTB"> <input type="button" id="SubmitBTN" onclick="javascript:__doPostBack('SubmitBTN','')" value="Submit" name="SubmitBTN"> </div> </div></form> InputTB and Panel1 where generated 3 time.

    Read the article

  • Inserting an image into sqlserver gives an "operand type clash"

    - by Termedi
    I'm trying to save an image in a sql server 2000 database. The data type of the column is image. Here is the code: Image Upload: <?php include('config.php'); if(is_uploaded_file($_FILES['userfile']['tmp_name'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $size = filesize($tmpName); set_magic_quotes_runtime(0);//to desactive the default escape spacials caracters made by PHP in the externes files $img_binaire = base64_encode(fread(fopen(str_replace("'","''",$tmpName), "r"), $size)); $query = "INSERT INTO test_image (image_name, image_content, image_size) ". "VALUES ('{$fileName}','{$img_binaire}', '{$size}')"; odbc_exec($conn, $query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; echo "<br>File Size: $fileSize <br>"; } ?> Image Show: <?php include('config.php'); $sql = "select * from test_image where id =2"; $rsl = odbc_exec($conn, $sql); $image_info = odbc_fetch_array($rsl); //$count = sizeof($image_info['image_content']); //header('Accept-Ranges: bytes'); //header('Content-Length: '.$image_info['image_size']); //header("Content-length: 17397"); header('Content-Type: image/jpeg'); echo base64_decode($image_info['image_content']); //echo bindec($image_info['image_content']); ?> It gives the following error: Error: Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: text is incompatible with image, SQL state 22005 in SQLExecDirect in C:\xampp\htdocs\test\upload.php on line 25 Error, query failed What do I need to do differently?

    Read the article

  • How do I set default search conditions with Searchlogic?

    - by Danger Angell
    I've got a search form on this page: http://staging-checkpointtracker.aptanacloud.com/events If you select a State from the dropdown you get zero results because you didn't select one or more Event Division (checkboxes). What I want is to default the checkboxes to "checked" when the page first loads...to display Events in all Divisions...but I want changes made by the user to be reflected when they filter. Here's the index method in my Events controller: def index @search = Event.search(params[:search]) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @events } end end Here's my search form: <% form_for @search do |f| %> <div> <%= f.label :state_is, "State" %> <%= f.select :state_is, ['AK','AL','AR','AZ','CA','CO','CT','DC','DE','FL','GA','HI','IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MI','MN','MO','MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VA','VT','WA','WI','WV','WY'], :include_blank => true %> </div> <div> <%= f.check_box :division_like_any, {:name => "search[:division_like_any][]"}, "Sprint", :checked => true %> Sprint (2+ hours)<br/> <%= f.check_box :division_like_any, {:name => "search[:division_like_any][]"}, "Sport" %> Sport (12+ hours)<br/> <%= f.check_box :division_like_any, {:name => "search[:division_like_any][]"}, "Adventure" %> Adventure (18+ hours)<br/> <%= f.check_box :division_like_any, {:name => "search[:division_like_any][]"}, "Expedition" %> Expedition (48+ hours)<br/> </div> <%= f.submit "Find Events" %> <%= link_to 'Clear', '/events' %> <% end %>

    Read the article

  • does php mysql_fetch_array works with html input box?

    - by dexter
    this is my entire PHP code: <?php if(empty($_POST['selid'])) {echo "no value selected"; } else { $con = mysql_connect("localhost","root",""); if(mysql_select_db("cdcol", $con)) { $sql= "SELECT * FROM products where Id = '$_POST[selid]'"; if($result=mysql_query($sql)) { echo "<form name=\"updaterow\" method=\"post\" action=\"dbtest.php\">"; while($row = mysql_fetch_array($result)) { echo "Id :<input type=\"text\" name=\"ppId\" value=".$row['Id']." READONLY></input></br>"; echo "Name :<input type=\"text\" name=\"pName\" value=".$row['Name']."></input></br>"; echo "Description :<input type=\"text\" name=\"pDesc\" value=".$row['Description']."></input></br>"; echo "Unit Price :<input type=\"text\" name=\"pUP\" value=".$row['UnitPrice']."></input></br>"; echo "<input type=\"hidden\" name=\"mode\" value=\"Update\"/>"; } echo "<input type=\"submit\" value=\"Update\">"; echo "</form>"; } else {echo "Query ERROR";} } } ?> PROBLEM here is, ....if the value i am getting from database using mysql_fetch_array($result) is like:(say Description is:) "my product" then; in input box it shows only "my" the word(or digit) after "SPACE"(ie blank space) doesn't get displayed? can input box like above can display the data with two or more words(separated by blank spaces)?

    Read the article

  • PHP Parse Error Help Needed

    - by adcmarti
    I am receiving this PHP parse error on the last line of this php file. What am I missing? Here is the last 15 lines or so. <div id="footer"> <br /> <p><b>Member Total:</b><?php echo $database->getNumMembers(); ?> <br>There are <?php echo $database->num_active_users; ?> registered members and <?php $database->num_active_guests; ?> guests viewing the site.<br><br> <?php include("include/view_active.php"); ?> </p> </div><!-- #footer --> <? } ?> </div><!-- #main --> <?php include("_footer.html"); ?> Any help would be appreciated. Thank you!

    Read the article

  • CSS: "float:left" doesn't work as expected

    - by Patrick
    hi, I want to display 2 columns of images using "float:left", and I dunno why the 3rd image is on the right. See screenshot:http://dl.dropbox.com/u/72686/imagesFloat.png See HTML: <div class="field-item odd"> <img alt="" class="filefield-imagecache-galleryImage" src="http://localhost/bernardi/sites/default/files/Picture%202.png" title=""><br> <span>description1</span> </div> <div class="field-item even"> <img alt="" class="filefield-imagecache-galleryImage" src="http://localhost/bernardi/sites/default/files/Picture%203.png" title=""><br> <span>description2</span> </div> <div class="field-item odd"> <img alt="" class="filefield-imagecache-galleryImage" src="http://localhost/bernardi/sites/default/files/Picture%204.png" title=""><br> <span>description3</span> </div> <div class="field-item even"> <img alt="" class="filefield-imagecache-galleryImage" src="http://localhost/bernardi/sites/default/files/Picture%205.png" title=""><br> <span></span> </div> see CSS: .field-field-image .odd { padding-right:20px; } .field-field-image .even { padding-left:20px; } .field-field-image .field-item { float:left; } thanks

    Read the article

  • Drupal db_query_range sql query

    - by hfidgen
    Hiya, I'm trying to get this working and the query executes but nothing comes back.. I've tried everything I can think of, can you spot what I'm doing wrong? Thanks in advance! $nido = $node->nid; $result = db_query_range(' SELECT i.nid, i.iid, a.fid, p.filename, p.filepath FROM {drup_image_attach} i LEFT JOIN {drup_image} a ON i.iid = a.nid LEFT JOIN {drup_files} p ON a.fid = p.fid WHERE i.nid = %d AND p.filename = "recipe_thumb"', $nido, 0, 10); echo "Filepath = " . $result ->filepath. "<br>"; echo "Filepath = " . $result ->filename . "<br>"; echo "IID = " . $result ->iid. "<br>"; echo "NID = " . $result ->nid . "<br>"; } EDIT - sorted out a couple of bits, but the output is still empty!

    Read the article

  • Urgent: Sort HashSet() function data in sequence

    - by vincent low
    i am new to java, the function i like to perform is something like: i will load a series of data from a file, into my hashSet() function. the problem is, i able to enter all the data in sequence, but i cant retrieve it out in sequence base on the account name in the file. any 1 can help to give a comment? below is my code: public Set retrieveHistory(){ Set dataGroup = new HashSet(); try{ File file = new File("C:\\Documents and Settings\\vincent\\My Documents\\NetBeansProjects\\vincenttesting\\src\\vincenttesting\\vincenthistory.txt"); BufferedReader br = new BufferedReader(new FileReader(file)); String data = br.readLine(); while(data != null){ System.out.println("This is all the record:"+data); Customer cust = new Customer(); //break the data based on the , String array[] = data.split(","); cust.setCustomerName(array[0]); cust.setpassword(array[1]); cust.setlocation(array[2]); cust.setday(array[3]); cust.setmonth(array[4]); cust.setyear(array[5]); cust.setAmount(Double.parseDouble(array[6])); cust.settransaction(Double.parseDouble(array[7])); dataGroup.add(cust); //then proced to read next customer. data = br.readLine(); } br.close(); }catch(Exception e){ System.out.println("error" +e); } return dataGroup; } public static void main(String[] args) { FileReadDataModel fr = new FileReadDataModel(); Set customerGroup = fr.retrieveHistory(); System.out.println(e); for(Object obj : customerGroup){ Customer cust = (Customer)obj; System.out.println("Cust name :" +cust.getCustomerName()); System.out.println("Cust amount :" +cust.getAmount()); }

    Read the article

  • Java resource closing

    - by Bob
    Hi, I'm writing an app that connect to a website and read one line from it. I do it like this: try{ URLConnection connection = new URL("www.example.com").openConnection(); BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream())); String response = rd.readLine(); rd.close(); }catch (Exception e) { //exception handling } Is it good? I mean, I close the BufferedReader in the last line, but I do not close the InputStreamReader. Should I create a standalone InputStreamReader from the connection.getInputStream, and a BufferedReader from the standalone InputStreamReader, than close all the two readers? I think it will be better to place the closing methods in the finally block like this: InputStreamReader isr = null; BufferedReader br = null; try{ URLConnection connection = new URL("www.example.com").openConnection(); isr = new InputStreamReader(connection.getInputStream()); br = new BufferedReader(isr); String response = br.readLine(); }catch (Exception e) { //exception handling }finally{ br.close(); isr.close(); } But it is ugly, because the closing methods can throw exception, so I have to handle or throw it. Which solution is better? Or what would be the best solution?

    Read the article

  • jquery appendTo form

    - by user313271
    jquery $(function(){ $('#4').click(function() { $('<input name="if4" type="text" value="other price>"').appendTo('form'); }); }); html <form> < input name="name" type="text" value="Enter your name" /><br /> < input name="contacts" type="text" value="Contact info" /><br /> < select name="services"> < option value="1">1</option> < option value="2">2</option> < option value="3">3</option> < option id="4" value="Other">4</option> < /select><br /> < textarea name="description">Description</textarea><br /> < /form> What i want to do: When i press on option value nr 4, there appears is new input field, this thing works fine. But how can I to change order where input field gonna appear, because now it appears after textfield, how can i put it after ? Thank you

    Read the article

  • Updating extra attributes in a has_many, :through relationship using Rails

    - by Robbie
    I've managed to set up a many-to-many relationship between the following models Characters Skills PlayerSkills PlayerSkills, right now, has an attribute that Skills don't normally have: a level. The models look something like this (edited for conciseness): class PlayerSkill < ActiveRecord::Base belongs_to :character belongs_to :skill end class Skill < ActiveRecord::Base has_many :player_skills has_many :characters, :through => :player_skills attr_accessible :name, :description end class Character < ActiveRecord::Base belongs_to :user has_many :player_skills has_many :skills, :through => :player_skills end So nothing too fancy in the models... The controller is also very basic at this point... it's pretty much a stock update action. The form I'm looking to modify is characters#edit. Right now it renders a series of checkboxes which add/remove skills from the characters. This is great, but the whole point of using has_many :through was to track a "level" as well. Here is what I have so far: - form_for @character do |f| = f.error_messages %p = f.label :name %br = f.text_field :name %p = f.label :race %br = f.text_field :race %p = f.label :char_class %br = f.text_field :char_class %p - @skills.each do |skill| = check_box_tag "character[skill_ids][]", skill.id, @character.skills.include?(skill) =h skill.name %br %p = f.submit After it renders "skill.name", I need it to print a text_field that updates player_skill. The problem, of course, is that player_skill may or may not exist! (Depending on if the box was already ticked when you loaded the form!) From everything I've read, has_many :through is great because it allows you to treat the relationship itself as an entity... but I'm completely at a loss as to how to handle the entity in this form. As always, thanks in advance for any and all help you can give me!

    Read the article

  • AJAX CascadingDropDown ViewState Problem

    - by Steven
    Question: How do I maintain both the contents (from queries) and selected value of both dropdowns after postback? Source Code: Download my source code from this link (link now works). Just add a reference to your AjaxControlToolkit User Action: Select a value from each dropdown. Click Submit. After Postback: StatesDrop: (Selected value), CitiesDrop "Select a City" Before and after: I believe that when the first dropdown gets its selected value, the second dropdown refreshes and therefore loses its selected value. C# answers also welcome. Default.aspx Active States<br /><asp:DropDownList ID="StatesDrop" runat="server" /><br /> Active Cities<br /><asp:DropDownList ID="CitiesDrop" runat="server" /><br /> <ajax:CascadingDropDown ID="StatesCasc" TargetControlID="StatesDrop" ServicePath="WebService1.asmx" ServiceMethod="GetActiveStates" Category="States" runat="server" PromptText="Select a State" PromptValue="?" /> <ajax:CascadingDropDown ID="CitiesCasc" TargetControlID="CitiesDrop" ServicePath="WebService1.asmx" ServiceMethod="GetActiveCities" Category="Cities" runat="server" ParentControlID="StatesDrop" PromptText="Select a City" PromptValue="?" /> WebService1.asmx.vb Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel Imports System.Web.Script.Services Imports AjaxControlToolkit <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ <System.Web.Services.WebServiceBinding _ (ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class WebService1: Inherits System.Web.Services.WebService <WebMethod()> _ Public Function GetActiveStates (ByVal knownCategoryValues As String, _ ByVal category As String) As CascadingDropDownNameValue() Dim values As New List(Of CascadingDropDownNameValue)() 'Fill values array' Return values.ToArray() End Function <WebMethod()> _ Public Function GetActiveCities (ByVal knownCategoryValues As String, _ ByVal category As String) As CascadingDropDownNameValue() Dim values As New List(Of CascadingDropDownNameValue)() Dim kv As StringDictionary = _ CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues) Dim SelState As String = "" If kv.ContainsKey("State") Then SelState = kv("State") 'Fill values array' Return values.ToArray() End Function End Class Default.aspx.vb Imports System.Web.Services Imports System.Web.Script.Services Imports AjaxControlToolkit Partial Public Class _Default Inherits System.Web.UI.Page Protected Sub Submit_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles SubmitBtn.Click ResultsGrid.DataBind() End Sub End Class

    Read the article

  • javascript: what does this syntax means?

    - by user1067138
    it is like this: (function () { //codes here })(); here is an example: (function () { var D = TED.EditorCore, E = TED.extend, A = TED.EditorInstanceManager, B = TED.augmentObject; window.TED["SimpleEditor"] = C; function C(F) { C.superclass.call(this, F) } C.defaultConfig = { height: "100px", width: "400px", //blablabla... flashNumLimit: 10, didaDelay: 300, imageWidthLimit: 570 }; E(C, D, { getContentLength: function () { return Math.ceil(this.filteHTML(this.editArea.innerHTML, ["img", "br"]).replace(/<img[^>]*>/gi, "mm").replace(/<br[^>]*>/gi, "m").replace(/&nbsp;/gi, "m").replace(/[^\x00-\xff]/g, "mm").length / 2) }, filteEditHTML: function () { return html = this.editArea.innerHTML.replace(/_moz_dirty=""/gi, "").replace(/\[/g, "[[-").replace(/\]/g, "-]]").replace(new RegExp("<\\/?(?:br[^>]*)>", "gi"), "[$1]").replace(new RegExp('<span([^>]*class="?at"?[^>]*)>', "gi"), "[span$1]").replace(new RegExp('<img([^>]*class="?(?:' + this.config.emptyClassName + "|" + this.config.smileyClassName + ')"?[^>]*)>', "gi"), "[img$1]").replace(/<[^>]*>/g, "").replace(/\[\[\-/g, "[").replace(/\-\]\]/g, "]").replace(new RegExp("\\[(/?(?:br|img|span)[^\\]]*)\\]", "gi"), "<$1>") }, filteSubmitHTML: function () { this.reLayout(); var G = this.editArea.innerHTML.replace(/_moz_dirty=""/gi, "").replace(/\[/g, "[[-").replace(/\]/g, "-]]").replace(new RegExp("<(/?(?:" + this.submitValidHTML.join("|") + ")[^>]*)>", "gi"), "[$1]").replace(new RegExp('<img([^>]*class="?(?:' + this.config.imageClassName + "|" + this.config.smileyClassName + "|" + this.config.flashClassName + "|" + this.config.musicClassName + ')"?[^>]*)>', "gi"), "[img$1]").replace(/<[^>]*>/g, "").replace(/\[\[\-/g, "[").replace(/\-\]\]/g, "]").replace(new RegExp("\\[(/?(?:" + this.submitValidHTML.join("|") + "|img)[^\\]]*)\\]", "gi"), "<$1>"); var F = document.createElement("div"); F.innerHTML = G; this.parseURL(F); return F.innerHTML } }); B(C, A) })(); what exactly does (funtion (){})(); do?

    Read the article

  • JQuery printfunction: no content, no view

    - by Joris
    I got a JQuery printfunction: function doPrintPage() { myWindow = window.open('', '', 'titlebar=yes,menubar=yes,status=yes,scrollbars=yes,width=800,height=600'); myWindow.document.open(); myWindow.document.write(document.getElementById("studentnummer").value); myWindow.document.write(document.getElementById("Voornaam").value + " " + document.getElementById("Tussenvoegsel").value + " " + document.getElementById("Achternaam").value); myWindow.document.write("</br>"); myWindow.document.write("Result"); myWindow.document.write(document.getElementById('tab1').innerHTML); myWindow.document.write("</br>"); myWindow.document.write("Tree"); myWindow.document.write(document.getElementById('tab2').innerHTML); myWindow.document.write("</br>"); myWindow.document.write("Open"); myWindow.document.write(document.getElementById('tab3').innerHTML); myWindow.document.write("</br>"); myWindow.document.write("Free"); myWindow.document.write(document.getElementById('tab4').innerHTML); myWindow.document.close(); myWindow.focus(); } There are 3 gridviews (elements in "tab#"), and on the page that is generated by this script, eacht gridview gets a header (Results, Tree, Open, Free). It is possible that there is no gridview for "Tree". It would be nice if the "tree" header wouldn't be shown either. EDIT: I tried this: if ($('tab4')[0]) {myWindow.document.write("Free"); myWindow.document.write(document.getElementById('tab4').innerHTML); but it seems not to work either... Anyone knows the solution?

    Read the article

  • Yahoo BOSS Question

    - by Fincha
    Hello everyone, I wonna to echo totalresults but somethink is wrong. // Get search results from Yahoo BOSS as an XML* $API = 'http://boss.yahooapis.com/ysearch/web/v1/'; $request = $API . $query .'?format=xml&appid='. APP_ID.'&start='.$start."0"; $ch = curl_init($request); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $xml = simplexml_load_string(curl_exec($ch)); echo $xml->resultset_web->totalhits; // Display search results - Title, Date and URL. foreach ($xml->resultset_web->result as $result) { $ausgabe .= '<a href="'.$result->clickurl.'">'.$result->title.'</a><br />'; $ausgabe .= $result->abstract."<br>"; $ausgabe .= '<a href="'.$result->clickurl.'">'.$result->url."</a> - ".round(($result->size/1024), 2)." Kb<br><br>"; } Can someone help me

    Read the article

  • Jquery get each div's sub child divs and grab info into an array

    - by McNabbToSkins
    I have a some html that looks like this <div id="main"> <div id="sub_main_1" class="sub_main"> <input type="text" class="sub_name_first" /><br /> <input type="text" class="sub_name_second" /><br /> </div> <div id="sub_main_2" class="sub_main"> <input type="text" class="sub_name_first" /><br /> <input type="text" class="sub_name_second" /><br /> </div> </div> I would like to pull out each sub_main divs information into an array in javascript. So far I have this as my jquery code $('#main').find('.sub_main').each( function() { alert('hi'); }); The alert is just a test that it should show "hi" twice. But this is not working. I am also not clear on how I can store the two inputs in a javascript array. Any help would be great! Thanks,

    Read the article

  • Table HTML problem..

    - by Azzyh
    hello i am trying to setup tables so the result outcomes like this: code: <table width="60%" cellpadding="0" cellspacing="1" id="theBoxer"> <tr style="background: #686868 ;"> <td align="center" valign="top" width="240" height="25" style="border:1px #FFF solid;">About me</td> </tr> <tr> <td align="left" valign="top" width="250" height="112" style=""> Points:<br> Lalala: <br> Lalala: <br> </td> <td align="left" valign="top" width="250" height="112" style=""> Lalala: <br> Lalala: </tr> </table> cant get it to work like how i wanted. the problem i get with my code is that "About me" only covers for the first td and not the other

    Read the article

  • Send email in wordpress

    - by jul
    hi, I'm trying to send an email using PHP mail() in a wordpress site. I created an empty page http://www.exam-vision.com/request-flip-up-instructions which template includes the php code shown below. When I post the data, isset($_REQUEST['email']) is false, while I can in firebug that the data have been posted correctly. What can be wrong? thanks <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = $_REQUEST['subject'] ; $message = $_REQUEST['message'] ; mail( "<someemail>", "Subject: $subject", $message, "From: $email" ); echo "Thank you for using our mail form"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='http://www.exam-vision.com/request-flip-up-instructions'> Email: <input name='email' type='text' /><br /> Subject: <input name='subject' type='text' /><br /> Message:<br /> <textarea name='message' rows='15' cols='40'> </textarea><br /> <input type='submit' /> </form>"; } ?>

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >