Search Results

Search found 11280 results on 452 pages for 'zend newbie dev'.

Page 153/452 | < Previous Page | 149 150 151 152 153 154 155 156 157 158 159 160  | Next Page >

  • got undefined variable in php code

    - by Newbie New
    I got a error message when I run my php however the result is come out this is my code function cart() { foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == 'cart_'){ $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT id, name, price FROM products WHERE id=' .mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)){ $sub = $get_row['price'] * $value; echo $get_row['name'].' x '.$value.' @ &pound'.number_format($get_row['price'], 2).' = &pound'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ; } } $total += $sub; } } echo $total; } ?> I got a error message Notice: Undefined variable: total in C:\xampp\htdocs\shoppingcart\cart.php on line 54 which line 54 is echo $total; what's wrong with my code?? I think I have defined the code in $total += $sub; thanks for helping me :)

    Read the article

  • What is best practice in converting XML to Java object?

    - by newbie
    I need to convert XML data to Java objects. What would be best practice to convert this XML data to object? Idea is to fetch data via a web service (it doesn't use WSDL, just HTTP GET queries, so I cannot use any framework) and answers are in XML. What would be best practice to handle this situation?

    Read the article

  • how to go through a string array and apply functions for different strings?

    - by Newbie
    Ok, this may be really noobish question, but i am wishing there is something i dont know yet. I go through a file, and check which string each line has, depending on the string value i execute a different function for it (or functions). This is how i do it now: if(str == "something"){ // do stuff }else if(str == "something else"){ // do stuff }else if(str == "something more"){ // do stuff }else if(str == "something again"){ // do stuff }else if(str == "something different"){ // do stuff }else if(str == "something really different"){ // do stuff } I am afraid this will become "slow" after i have to repeat those else if lines a lot... I tried to use switch() statement, but obviously it doesnt work here, is there something similar to switch() to use here?

    Read the article

  • Is it possible to create the following XML using Xdocument(C#3.0)

    - by Newbie
    <?xml version='1.0' encoding='UTF-8'?> <StockMarket> <StockDate Day = "02" Month="06" Year="2010"> <Stock> <Symbol>ABC</Symbol> <Amount>110.45</Amount> </Stock> <Stock> <Symbol>XYZ</Symbol> <Amount>366.25</Amount> </Stock> </StockDate> <StockDate Day = "03" Month="06" Year="2010"> <Stock> <Symbol>ABC</Symbol> <Amount>110.35</Amount> </Stock> <Stock> <Symbol>XYZ</Symbol> <Amount>369.70</Amount> </Stock> </StockDate> </StockMarket> My approach so far is XDocument doc = new XDocument( new XElement("StockMarket", new XElement("StockDate", new XAttribute("Day", "02"),new XAttribute("Month","06"),new XAttribute("Year","2010")), new XElement("Stock") ) ); Since I am new to Linq to XML, I am presently struggling a lot and henceforth seeking for help. Using C#3.0 . Thanks

    Read the article

  • how to maintain session in cURL in php?

    - by newbie programmer
    how can we maintain session in cURL? i'am having a code the sends login details of a site and logs in successfully i need to get the session maintained at the site to continue. here is my code that used to login to the site using cURL <?php $socket = curl_init(); curl_setopt($socket, CURLOPT_URL, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_REFERER, "http://www.XXXXXXX.com"); curl_setopt($socket, CURLOPT_POST, true); curl_setopt($socket, CURLOPT_USERAGENT, $agent); curl_setopt($socket, CURLOPT_POSTFIELDS, "form_logusername=XXXXX&form_logpassword=XXXXX"); curl_setopt($socket, CURLOPT_COOKIESESSION, true); curl_setopt($socket, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($socket, CURLOPT_COOKIEFILE, "cookies.txt"); $data = curl_exec($socket); curl_close($socket); ?>

    Read the article

  • Can we avoid multiple if''s?

    - by Newbie
    I tried my level best to write an improved version but failed. inFiles.ToList().ForEach(i => { filePath = inFolder + "\\" + i.Value; if (i.Key.Equals(replacementFile)) { replacementCollection = GetReplacementDataFromFile(filePath); } else if (i.Key.Equals(standardizationFile)) { standardizationCollection = GetStandardizationDataFromFile(filePath); } }); The problem is that I cannot use a switch case over here because the comparison variables are not constant. Kindly help to improve this code. I am using C#(3.0). Thanks

    Read the article

  • Change the for loop with lambda(C#3.0)

    - by Newbie
    Is it possible to do the same using Lambda for (int i = 0; i < objEntityCode.Count; i++) { options.Attributes[i] = new EntityCodeKey(); options.Attributes[i].EntityCode = objEntityCode[i].EntityCodes; options.Attributes[i].OrganizationCode = Constants.ORGANIZATION_CODE; } I mean to say to rewrite the statement using lambda. I tried with Enumerable.Range(0,objEntityCode.Count-1).Foreach(i=> { options.Attributes[i] = new EntityCodeKey(); options.Attributes[i].EntityCode = objEntityCode[i].EntityCodes; options.Attributes[i].OrganizationCode = Constants.ORGANIZATION_CODE; }); but not working I am using C#3.0

    Read the article

  • How to get latest files in C#

    - by Newbie
    I have some files with same name but with different dates. Basically we are finding the files with most recent dates The file patterns are <FileNames><YYYYMMDD><FileExtension> e.g. test_20100506.xls indicates <FileNames> = test_ <YYYYMMDD> = 20100506 <FileExtension> = .xls Now in the source folder, the files are standardization_20100503.xls, standardization_20100504.xls, standardization_20100305.xls, replacement_20100505.xls As can be seen that, standardization_.xls are 3 in numbers but replacement_.xls is only 1. The output will be a list of file names whose content will be standardization_20100504.xls and replacement_20100505.xls Because among all the standardization_.xls is the most recent one and replacement_.xls is also the same. I have tried with my own logic but somehow failed. My idea is as under private static void GetLatestFiles(ref List<FileInfo> validFiles) { List<FileInfo> validFilesTemp = new List<FileInfo>(); for (int i = 0; i < validFiles.Count; i++) { for (int j = i+1; j < validFiles.Count; j++) { string getFileTextX = ExtractText(validFiles[i].Name); string getFileTextY = ExtractText(validFiles[j].Name); if (getFileTextX == getFileTextY) { int getFileDatesX = Convert.ToInt32(ExtractNumbers(validFiles[i].Name)); int getFileDatesY = Convert.ToInt32(ExtractNumbers(validFiles[j].Name)); if (getFileDatesX > getFileDatesY) { validFilesTemp.Add(validFiles[i]); } else { validFilesTemp.Add(validFiles[j]); } } } } validFiles.Clear(); validFiles = validFilesTemp; } The ExtractNumbers is: public static string ExtractNumbers(string expr) { return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[^\\d]")); } and the ExtractText is public static string ExtractText(string expr) { return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[\\d]")); } I am using c#3.0 and framework 3.5 Help needed .. it's very urgent Thanks .

    Read the article

  • Convert the code into lambda/LINQ(C#3.0)

    - by Newbie
    How to convert the below code into lambda if (ds != null && ds.Tables.Count > 0) { dtAsset = ds.Tables["AssetData"]; dtCharecteristics = ds.Tables["CharacteristicsData"]; for (int i = 0; i < dtAsset.Rows.Count; i++) { for (int j = 0; j < dtCharecteristics.Rows.Count; j++) { if (dtAsset.Rows[i]["AssetId"].Equals(dtCharecteristics.Rows[j]["AssetId"])) { objAttributesCollection.Add(new Attributes { AttributeCode = Convert.ToString(dtCharecteristics.Rows[j]["AttributeCode"]), TimeSeriesData = fn(Convert.ToDateTime(dtCharecteristics.Rows[j]["StartDate"]), Convert.ToString(dtCharecteristics.Rows[j]["Value"])) }); } } objAssetCollection.Add(new Asset { AssetId = Convert.ToInt32(dtAsset.Rows[i]["AssetId"]), AssetType = Convert.ToString(dtAsset.Rows[i]["AssetCode"]), AttributeCollection = objAttributesCollection }); objAttributesCollection = new List<Attributes>(); } } I am using C#3.0 There is nothing wrong in the code but for the sake of learning I want to do this. Thanks

    Read the article

  • How to rewrite the following?(C#3.0)

    - by Newbie
    I am trying to write the following double sum_res = 0.0; double yhat = 0; double res = 0; int n = 0; for(int i=0;i<x.Count;i++) { yhat = inter + (slp*x[i]); res = yhat - y[i]; n++; } using lambda but somehow not able to get it work(compile time error) Enumerable.Range(0, x.Count).Select(i => { yhat = inter + (slp * x[i]); res = yhat - y[i]; sum_res += res * res; n++; }); Error: The type arguments for method 'System.Linq.Enumerable.Select(System.Collections.Generic.IEnumerable, System.Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly. Help needed. Thanks

    Read the article

  • problem with sql statement using vb.net

    - by newBie
    hi i got some problem i got this 3 line statement: Dim infoID As Integer = objCommand1.ExecuteScalar() Dim strSQL2 As String = "insert into feedBackHotel (infoID, feedBackView) values(" + infoID + ",'" + FeedBack + "')" Dim objCommand2 As New SqlCommand(strSQL2, conn) objCommand2.ExecuteNonQuery() the problem here is..the strSQL2 can capture the infoID from previous statement, but it didnt insert into the database. it will pop out this error "Conversion from string "insert into feedBackHotel (infoI" to type 'Double' is not valid." in both table related, use same data type (int) but for the feedBackHotel's infoID i allow it to be null..bcoz if i make it not null, it will show another error.. im using vb.net ..can anyone help?

    Read the article

  • regex problem with url

    - by newBie
    i need to find regex that suitable with this.. [url]%252FShowOneUserReview-g298570-d301416-r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie%3DUTF-8 its situated in is it possible for me to find only [url]...-8?

    Read the article

  • Problem in appending a string to a already filled string builder(at the beginning by using INSERT) a

    - by Newbie
    I have a string builder like StringBuilder sb = new StringBuilder("Value1"); sb.AppendLine("Value2"); Now I have a string say string str = "value 0"; I did sb.Insert(0,str); and then string[] strArr = sb.ToString().Trim().Replace("\r", string.Empty).Split('\n'); The result I am getting as (Array size of 2 where I should get 3) [0] value 0 Value1 [1] value2 But the desired output being [0] Value 0 [1] Value1 [2] Value2 Where I am going wrong? I am using C#3.0 Please help.. It 's urgent Thanks

    Read the article

  • How to debug properly and find causes for crashes?

    - by Newbie
    I dont know what to do anymore... its hopeless. I'm getting tired of guessing whats causing the crashes. Recently i noticed some opengl calls crashes programs randomly on some gfx cards. so i am getting really paranoid what can cause crashes now. The bad thing on this crash is that it crashes only after a long time of using the program, so i can only guess what is the problem. I cant remember what changes i made to the program that may cause the crashes, its been so long time. But luckily the previous version doesnt crash, so i could just copypaste some code and waste 10 hours to see at which point it starts crashing... i dont think i want to do that yet. The program crashes after i make it to process the same files about 5 times in a row, each time it uses about 200 megabytes of memory in the process. It crashes at random times while and after the reading process. I have createn a "safe" free() function, it checks the pointer if its not NULL, and then frees the memory, and then sets the pointer to NULL. Isn't this how it should be done? I watched the task manager memory usage, and just before it crashed it started to eat 2 times more memory than usual. Also the program loading became exponentially slower every time i loaded the files; first few loads didnt seem much slower from each other, but then it started rapidly doubling the load speeds. What should this tell me about the crash? Also, do i have to manually free the c++ vectors by using clear() ? Or are they freed after usage automatically, for example if i allocate vector inside a function, will it be freed every time the function has ended ? I am not storing pointers in the vector. -- Shortly: i want to learn to catch the damn bugs as fast as possible, how do i do that? Using Visual Studio 2008.

    Read the article

  • XML serialization of hash table(C#3.0)

    - by Newbie
    Hi I am trying to serialize a hash table but not happening private void Form1_Load(object sender, EventArgs e) { Hashtable ht = new Hashtable(); DateTime dt = DateTime.Now; for (int i = 0; i < 10; i++) ht.Add(dt.AddDays(i), i); SerializeToXmlAsFile(typeof(Hashtable), ht); } private void SerializeToXmlAsFile(Type targetType, Object targetObject) { try { string fileName = @"C:\testtttttt.xml"; //Serialize to XML XmlSerializer s = new XmlSerializer(targetType); TextWriter w = new StreamWriter(fileName); s.Serialize(w, targetObject); w.Flush(); w.Close(); } catch (Exception ex) { throw ex; } } After a google search , I found that objects that impelment IDictonary cannot be serialized. However, I got success with binary serialization. But I want to have xml one. Is there any way of doing so? I am using C#3.0 Thanks

    Read the article

  • Getting certain rows from list of rows(C#3.0)

    - by Newbie
    I have a datatable having 44 rows. I have converted that to list and want to take the rows from 4th row till the last(i.e. 44th). I have the below program IEnumerable<DataRow> lstDr = dt.AsEnumerable().Skip(4).Take(dt.Rows.Count); But the output is Enumeration yielded no results I am using c#3.0 Please help.

    Read the article

  • Problem in converting ToDictionary<Datetime,double>() usinh LINQ(C#3.0)

    - by Newbie
    I have written the below return (from p in returnObject.Portfolios.ToList() from childData in p.ChildData.ToList() from retuns in p.Returns.ToList() select new Dictionary<DateTime, double> () {p.EndDate, retuns.Value }).ToDictionary<DateTime,double>(); Getting error No overload for method 'Add' takes '1' arguments Where I am making the mistake I am using C#3.0 Thanks

    Read the article

  • Can this extension method be improve

    - by Newbie
    I have the following extension method public static class ListExtensions { public static IEnumerable<T> Search<T>(this ICollection<T> collection, string stringToSearch) { foreach (T t in collection) { Type k = t.GetType(); PropertyInfo pi = k.GetProperty("Name"); if (pi.GetValue(t, null).Equals(stringToSearch)) { yield return t; } } } } What it does is by using reflection, it finds the name property and then filteres the record from the collection based on the matching string. This method is being called as List<FactorClass> listFC = new List<FactorClass>(); listFC.Add(new FactorClass { Name = "BKP", FactorValue="Book to price",IsGlobal =false }); listFC.Add(new FactorClass { Name = "YLD", FactorValue = "Dividend yield", IsGlobal = false }); listFC.Add(new FactorClass { Name = "EPM", FactorValue = "emp", IsGlobal = false }); listFC.Add(new FactorClass { Name = "SE", FactorValue = "something else", IsGlobal = false }); List<FactorClass> listFC1 = listFC.Search("BKP").ToList(); It is working fine. But a closer look into the extension method will reveal that Type k = t.GetType(); PropertyInfo pi = k.GetProperty("Name"); is actually inside a foreach loop which is actually not needed. I think we can take it outside the loop. But how? PLease help. (C#3.0)

    Read the article

  • PotgreSQL 2D array to rows

    - by PostGreSQL newbie
    Hello, I am new to PostgreSQL array's. I am trying to a write a procedure to convert array-into-rows, and wanted following output: alphabet | number ---------+---------- A | 10 B | 10 C | 6 D | 9 E | 3 from following: id | alphabet_series -------+-------------------------------------------------------------------------------------------------- 1 | {{A,10},{B,10},{C,6},{D,9},{E,3},{F,9},{I,10},{J,17},{K,16},{L,17},{M,20},{N,13},{O,19}} I have searched for array-to-rows functions, but they all seems to accept 1-d array. but in this case, it is 2-d array. Any pointers will be appreciated. Many thanks.

    Read the article

  • how to download page from source code

    - by newBie
    i need to download page from source code..for example Cellini's Italian Restaurant i want to download the "/len/aaproximat...php"..i didnt find the suitable regex for it..and i need to download that page..can anyone help? im using vb.net

    Read the article

  • How do I show all group headers in Access 2007 reports?

    - by Newbie
    This is a question about Reports in Access 2007. I'm unsure whether the solution will involve any programming, but hopefully someone will be able to help me. I have a report which lists all records from a particular table (call it A), and groups them by their associated record in a related table (call it B). I use the 'group headers' to add the information from table-B into the report. The problem occurs when I filter the records from table-A that are shown in the report. If I filter out all table-A records that relate to a particular record (call it X) in table-B, the report no longer shows the record-X group header. As a possible workaround, I have tried to ensure that I have one empty record in table-A for each of the records in table-B. That way I can specify NOT to filter out these empty records. However, the outcome is ugly one-record-high blank spaces at the start of each group in the report. Does anyone know of an alternative solution?

    Read the article

  • How to specify comma , space unicode value in app.config(C#3.0)

    - by Newbie
    In the app.config file if I use <add key = "FileDelimeter" value ="&#2c;"/> as unicode for COMMA, it is throwing error Invalid character in a decimal number 'c' For SPACE, <add key = "FileDelimeter" value ="&#20;"/> the error is Character'', hex value 0*14 is illegal in xml while <add key = "FileDelimeter" value ="&#09;"/> for "\t" worked. Where is the mistake? Kindly give a generic solution. Thanks

    Read the article

< Previous Page | 149 150 151 152 153 154 155 156 157 158 159 160  | Next Page >