Search Results

Search found 10196 results on 408 pages for 'article city'.

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

  • php domDocument variables

    - by geoffs3310
    Hi, I have the following code at the moment: $ip = '195.72.186.157'; $xmlDoc = new DOMDocument(); $xmlDoc->loadXML(file_get_contents('http://www.geoffmeierhans.com/services/geo-locator/locate/?ip='.$ip.'&output=xml')); foreach($xmlDoc->getElementsByTagName('city') as $link) { $links = array('text' => $link->nodeValue); } $city = $links['text']; echo $city; Is there a better way to get the city variable? Since there is only one tag called city a loop isn't really needed but I can't get it to work any other way

    Read the article

  • jQuery - field entry - how to duplicate and convert to seo friendly url

    - by Binyamin
    I have two HTML input fields 'article' and 'url'. How to duplicate field 'article' entry to field 'url' to SEO friendly link!? 'url' allowed symbols 'a-z' (capital letters converted to lowercase), 'url' space symbol replace with dash '-', 'url' other symbols ignored. required typing just in field 'article' <input type="text" name="article"> url field is jquery auto generated and updated by field article value <input type="text" name="url">

    Read the article

  • Check variable if explode-able in PHP

    - by ZaneDeFazio
    Not sure if there is a way to check a variable if it is explode-able or not... I have a database of city names some are one word cities and some are multiple word cities EX: Chicago, Los Angeles I keep getting an error when use "implode" when a city name is one word, so I tried using "count" and using an if statement... not having any luck $citi = explode(' ', $row['city']); $count = count($citi); if ($count > 1) { $city = implode('+', $citi); } else { $city = $citi; }

    Read the article

  • mysql_query where statment help

    - by Anders Kitson
    I am retrieving values from the url with the GET method and then using a if statement to determine of they are there then query them against the database to only show those items that match them, i get an unknown error with your request. here is my code $province = $_GET['province']; $city = $_GET['city']; if(isset($province) && isset($city) ) { $results3 = mysql_query("SELECT * FROM generalinfo WHERE province = $province AND city = $city ") or die( "An unknown error occurred with your request"); } else { $results3 = mysql_query("SELECT * FROM generalinfo"); } /*if statement ends*/

    Read the article

  • XSL template structure for choosing latest event.

    - by Deborah Klenke
    I have a list grouped by Region and it currently shows all the items for each city. I want to reduce to only the most recent advisory for each city. I have tried to use an xsl:for-each statement but I am messing up the names/parameters. List is called mlc The list contains the fields: Title City Region Advisory DateCreated TT (calculated number field to find the number of minutes from the DateCreated to end of today which I intended to use the smallest to find the most recent) I have the list grouped by Region and it currently shows all the items for each city. I want to reduce to only the most recent advisory for each city.

    Read the article

  • Codeigniter - Is it ok to add functionality to the constructor in controllers?

    - by Irro
    I'm making a project where I want the user to search for shops in different cities and would like the url to be like this: domain/shop/city/name. So I created a controller in codeigniter called Shop. But I cant create a city function since the city part of the url changes dependent on city name. One easy way to do it would be to add a function called "search" and add the functionality there but then I get url's like: domain/shop/search/city/name which I really would like to avoid. So my question is if it's ok to add my functionality directly into the constructor to avoid that extra "search" part in the url? I'm afraid that there might be some performance tricks involved that potentially keeps the class in memory so the constructor will not be called every time.

    Read the article

  • syntax error, unexpected ',', expecting ')' RoR

    - by McDoku
    I am trying to get a collection select from an another model and I keep getting the above error. Looked everywhere, got rails casts but nothing makes sense. _form.rb <%= f.label :city %><br /> <%= f.collection_select (:share ,:city_id, City.all , :id, :name ) %> It highlights 'form' on the error report <h1>New share</h1> <%= render 'form' %> <%= link_to 'Back', shares_path %> Here are my models... class Share include Mongoid::Document field :name, type: String field :type, type: String field :summary, type: String field :description, type: String field :city, type: String embedded_in :city has_many :category end class City include Mongoid::Document embedded_in :share field :name, type: String field :country, type: String attr_accessible :name, :city_id, :id end Searched everywhere and I cannot figure it out. It must be something silly.

    Read the article

  • ruby on rails photo upload problem

    - by dodo00700
    Hallo rails version 2.3.5 I'm learning rails and I run into a problem. I'm doing some nesting forms from the railscasts tutorials. I changed the text area into a data field to upload photos and everything is working. Now i have to display the uploaded pictures and i simply can't do it. I Tried everything I could find on the net but nothing worked. PROBLEM I have the Article controller which handles the article CRUD. inside the article new form there is nested a form for uploading images. article controller def code_image @image_data = Photo.find(params[:id]) @image = @image_data.binary_data send_data(@image, :type => @image_data.content_type, :filename => @image_data.filename, :disposition => 'inline') end photo model def image_file=(input_data) self.filename = input_data.original_filename self.content_type = input_data.content_type.chomp self.binary_data = input_data.read end articles/show.html.erb <%=h @article.title %> <%=h @article.body %> <% for photos in @article.photos %> <%= image_tag(url_for({:action => 'code_image', :id => @article.photos.id})) -%> <% end %> articles/_formnew.html.erb <% form_for (:article, @article, :url => {:action=>'create'}, :html=> {:multipart=>true}) do |f| %> <%= f.error_messages % <%= f.label :title %><br /> <%= f.text_field :title %><br /><br /> <%= f.label :body %><br /> <%= f.text_area :body, :style => 'width: 600px;' %><br /><br /> <% f.fields_for :photos do |builder|%> <%= builder.label :content, "Photo"%><br /> <%= builder.file_field :image_file %><br /> <% end %> <br /> <%= f.submit "Create" %> <% end % Thanks

    Read the article

  • SQL SERVER – Weekly Series – Memory Lane – #005

    - by pinaldave
    Here is the list of curetted articles of SQLAuthority.com across all these years. Instead of just listing all the articles I have selected a few of my most favorite articles and have listed them here with additional notes below it. Let me know which one of the following is your favorite article from memory lane. 2006 SQL SERVER – Cursor to Kill All Process in Database I indeed wrote this cursor and when I often look back, I wonder how naive I was to write this. The reason for writing this cursor was to free up my database from any existing connection so I can do database operation. This worked fine but there can be a potentially big issue if there was any important transaction was killed by this process. There is another way to to achieve the same thing where we can use ALTER syntax to take database in single user mode. Read more about that over here and here. 2007 Rules of Third Normal Form and Normalization Advantage – 3NF The rules of 3NF are mentioned here Make a separate table for each set of related attributes, and give each table a primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table If attributes do not contribute to a description of the key, remove them to a separate table. Correct Syntax for Stored Procedure SP Sometime a simple question is the most important question. I often see in industry incorrectly written Stored Procedure. Few writes code after the most outer BEGIN…END and few writes code after the GO Statement. In this brief blog post, I have attempted to explain the same. 2008 Switch Between Result Pan and Query Pan – SQL Shortcut Many times when I am writing query I have to scroll the result displayed in the result set. Most of the developer uses the mouse to switch between and Query Pane and Result Pane. There are few developers who are crazy about Keyboard shortcuts. F6 is the keyword which can be used to switch between query pane and tabs of the result pane. Interesting Observation – Use of Index and Execution Plan Query Optimization is a complex game and it has its own rules. From the example in the article we have discovered that Query Optimizer does not use clustered index to retrieve data, sometime non clustered index provides optimal performance for retrieving Primary Key. When all the rows and columns are selected Primary Key should be used to select data as it provides optimal performance. 2009 Interesting Observation – TOP 100 PERCENT and ORDER BY If you pull up any application or system where there are more than 100 SQL Server Views are created – I am very confident that at one or two places you will notice the scenario wherein View the ORDER BY clause is used with TOP 100 PERCENT. SQL Server 2008 VIEW with ORDER BY clause does not throw an error; moreover, it does not acknowledge the presence of it as well. In this article we have taken three perfect examples and demonstrated which clause we should use when. Comma Separated Values (CSV) from Table Column A Very common question – How to create comma separated values from a table in the database? The answer is also very common if we use XML. Check out this article for quick learning on the same subject. Azure Start Guide – Step by Step Installation Guide Though Azure portal has changed a quite bit since I wrote this article, the concept used in this article are not old. They are still valid and many of the functions are still working as mentioned in the article. I believe this one article will put you on the track to use Azure! Size of Index Table for Each Index – Solution Earlier I have posted a small question on this blog and requested help from readers to participate here and provide a solution. The puzzle was to write a query that will return the size for each index that is on any particular table. We need a query that will return an additional column in the above listed query and it should contain the size of the index. This article presents two of the best solutions from the puzzle. 2010 Well, this week in 2010 was the week of puzzles as I posted three interesting puzzles. Till today I am noticing pretty good interesting in the puzzles. They are tricky but for sure brings a great value if you are a database developer for a long time. I suggest you go over this puzzles and their answers. Did you really know all of the answers? I am confident that reading following three blog post will for sure help you enhance the experience with T-SQL. SQL SERVER – Challenge – Puzzle – Usage of FAST Hint SQL SERVER – Puzzle – Challenge – Error While Converting Money to Decimal SQL SERVER – Challenge – Puzzle – Why does RIGHT JOIN Exists 2011 DVM sys.dm_os_sys_info Column Name Changed in SQL Server 2012 Have you ever faced a situation where something does not work? When you try to fix it - you enjoy fixing it and started to appreciate the breaking changes. Well, this was exactly I felt yesterday. Before I begin my story, I want to candidly state that I do not encourage anybody to use * in the SELECT statement. Now the disclaimer is over – I suggest you read the original story – you will love it! Get Directory Structure using Extended Stored Procedure xp_dirtree Here is the question to you – why would you do something in SQL Server where you can do the same task in command prompt much easily. Well, the answer is sometime there are real use cases when we have to do such thing. This is a similar example where I have demonstrated how in SQL Server 2012 we can use extended stored procedure to retrieve directory structure. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: Memory Lane, PostADay, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

  • Breadcrumbs to show Navigation of user

    - by user310916
    My Folder structure in sharepoint is flat one. in the same level I have pages Home, Main Articles, Articles by Category, Article Content aspx pages. A user can navigate like Home Main Articles Articles by Category Article or Home Main Articles Article or Home Article. I want user to see the breadcrumbs as shown above. I created a web.sitemap xml file in my site definition as follows <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" > <siteMapNode url="Landing.aspx" title="Tips from the Top" description="The Tips from the Top Home Page"> <siteMapNode url="MainArticles.aspx" title="All Articles" description="All Articles are available here"> <siteMapNode url="ArticlesbyCategory.aspx" title="Articles by Category" description="Articles on selected category"> <siteMapNode url="CurrentArticleContent.aspx" title="Article Content" description="Article of Interest" /> </siteMapNode> <siteMapNode url="CurrentArticleContent.aspx" title="Article Content" description="Article of Interest" /> </siteMapNode> <siteMapNode url="MainTips.aspx" title="All Business Tips" description="All Business Tips are available here"> <siteMapNode url="TipsbyCategory.aspx" title="Tips by Category" description="Tips on selected category" /> </siteMapNode> </siteMapNode> </siteMap> and also added a web.config file as <siteMap defaultProvider="MapProvider"> <providers> <add name="MapProvider" type="xyz.abc.SiteDefinition.MapProvider,xyz.abc.SiteDefinition" siteMapFile = "Web.Sitemap" /> </providers> </siteMap>

    Read the article

  • Form is submitting when the page loads

    - by RailAddict
    I have a really simple Rails app. Basically an article with comments. I want the article page to show the article, comments underneath and then a textbox to write a comment and a submit button to submit it. I got it all working except for one (big) problem. When the page loads.. example.com/article/1 a blank comment is submitted to the database. I fixed that by including "validates_presence_of :body" in the Comment model. But that results in the following image when the page loads: This is my code by the way: def show @place = Article.find(params[:id]) @comment = Article.find(params[:id]).comments.create(params[:comment]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @article } end end and <% form_for([@article, @comment]) do |f| %> <p> <%= f.label :commenter %><br /> <%= f.text_field :commenter %> </p> <p> <%= f.label :body %><br /> <%= f.text_area :body %> </p> <p> <%= f.submit "Create" %> </p> <% end %>

    Read the article

  • Proper way to use a config file?

    - by user156814
    I just started using a PHP framework, Kohana (V2.3.4) and I am trying to set up a config file for each of my controllers. I never used a framework before, so obviously Kohana is new to me. I was wondering how I should set up my controllers to read my config file. For example, I have an article controller and a config file for that controller. I have 3 ways of loading config settings // config/article.php $config = array( 'display_limit' => 25, // limit of articles to list 'comment_display_limit' => 20, // limit of comments to list for each article // other things ); Should I A) Load everything into an array of settings // set a config array class article_controller extends controller{ public $config = array(); function __construct(){ $this->config = Kohana::config('article'); } } B) Load and set each setting as its own property // set each config as a property class article_controller extends controller{ public $display_limit; public $comment_display_limit; function __construct(){ $config = Kohana::config('article'); foreach ($config as $key => $value){ $this->$key = $value; } } } C) Load each setting only when needed // load config settings only when needed class article_controller extends controller{ function __construct(){} // list all articles function show_all(){ $display_limit = Kohana:;config('article.display_limit'); } // list article, with all comments function show($id = 0){ $comment_display)limit = Kohana:;config('article.comment_display_limit'); } } Note: Kohana::config() returns an array of items. Thanks

    Read the article

  • Rails 1.0 - Using composed_of gives me a wrong number of arguments (1 for 5) error

    - by Tristan Havelick
    I am developing a Rails 1.0 application (I can't upgrade, it's a strange situation) for which I am trying to use the :composed_of functionality. I have a class called StreetAddress: class StreetAddress attr_reader :address, :address2, :city, :state_id, :zip_code def initialize(address, address2, city, state_id, zip_code) @address = address @address2 = address2 @city = city @state_id = state_id @zip_code = zip_code end end and a model class called Hotel class Hotel < ActiveRecord::Base composed_of :street_address # ... end which has columns: "id", "brand_id", "code", "location_name", "address", "address2", "city", "state_id", "zip_code", "phone_number", "phone_ext", "fax_number", "time_zone", "url", "room_service_email", "manager_name", "manager_email" However when I try to access the aggregation I get an error: >> h = Hotel.find(1) => #<Hotel:0x38ad718 @attributes={"fax_number"=>"1-623-420-0124", "city"=>"Twin Falls", "address2"=>"285", "brand_id"=>"1", "code"=>"XZWUXUSZ", "manager_email"= >"[email protected]", "url"=>"http://www.xycdkzolukfvu.hom", "ph one_number"=>"1-805-706-9995", "zip_code"=>"72436", "phone_ext"=>"48060", "id"=> "1", "manager_name"=>"Igor Mcdowell", "room_service_email"=>"Duis.risus@Donecvit ae.ca", "time_zone"=>"America/Boise", "state_id"=>"15", "address"=>"P.O. Box 457 , 7405 Dignissim Avenue", "location_name"=>"penatibus et magnis"}> >> h.street_address ArgumentError: wrong number of arguments (1 for 5) from (eval):3:in `initialize' from (eval):3:in `new' from (eval):3:in `street_address' from (irb):6 Why?

    Read the article

  • Best practice PHP Form Action

    - by Rob
    Hi there i've built a new script (from scratch not a CMS) and i've done alot of work on reducing memory usage and the time it takes for the page to be displayed (caching HTML etc) There's one thing that i'm not sure about though. Take a simple example of an article with a comments section. If the comment form posts to another page that then redirects back to the article page I won't have the problem of people clicking refresh and resending the information. However if I do it that way, I have to load up my script twice use twice as much memory and it takes twice as long whilst i'm still only displaying the page once. Here's an example from my load log. The first load of the article is from the cache, the second rebuilds the page after the comment is posted. Example 1 0 queries using 650856 bytes of memory in 0.018667 - domain.com/article/1/my_article.html 9 queries using 1325723 bytes of memory in 0.075825 - domain.com/article/1/my_article/newcomment.html 0 queries using 650856 bytes of memory in 0.029449 - domain.com/article/1/my_article.html Example 2 0 queries using 650856 bytes of memory in 0.023526 - domain.com/article/1/my_article.html 9 queries using 1659096 bytes of memory in 0.060032 - domain.com/article/1/my_article.html Obviously the time fluctuates so you can't really compare that. But as you can see with the first method I use more memory and it takes longer to load. BUT the first method avoides the refresh problem. Does anyone have any suggestions for the best approach or for alternative ways to avoid the extra load (admittadely minimal but i'd still like to avoid it) whilst also avoiding the refresh problem?

    Read the article

  • Prevent two users from editing the same data

    - by Industrial
    Hi everyone, I have seen a feature in different web applications including Wordpress (not sure?) that warns a user if he/she opens an article/post/page/whatever from the database, while someone else is editing the same data simultaneously. I would like to implement the same feature in my own application and I have given this a bit of thought. Is the following example a good practice on how to do this? It goes a little something like this: 1) User A enters a the editing page for the mysterious article X. The database tableEvents is queried to make sure that no one else is editing the same page for the moment, which no one is by then. A token is then randomly being generated and is inserted into a database table called Events. 1) User B also want's to make updates to the article X. Now since our User A already is editing the article, the Events table is queried and looks like this: | timestamp | owner | Origin | token | ------------------------------------------------------------ | 1273226321 | User A | article-x | uniqueid## | 2) The timestamp is being checked. If it's valid and less than say 100 seconds old, a message appears and the user cannot make any changes to the requested article X: Warning: User A is currently working with this article. In the meantime, editing cannot be done. Please do something else with your life. 3) If User A decides to go on and save his changes, the token is posted along with all other data to update the database, and toggles a query to delete the row with token uniqueid##. If he decides to do something else instead of committing his changes, the article X will still be available for editing in 100 seconds for User B Let me know what you think about this approach! Wish everyone a great weekend!

    Read the article

  • Generating URLs when not using an integer as an id?

    - by Synthesezia
    So I'm building a blog engine which has /articles/then-the-article-permalink as it's URL structure. I need to have prev and next links which will jump to the next article by pub_date, my code looks like this: In my articles#show @article = Article.find_by_permalink(params[:id]) @prev_article = Article.find(:first, :conditions => [ "pub_date < ?", @article.pub_date]) @next_picture = Article.find(:first, :conditions => [ "pub_date > ?", @article.pub_date]) And in my show.html.erb <%= link_to "Next", article_path(@next_article) %> <%= link_to 'Prev', article_path(@prev_article) %> In my articles model I have this: def to_param self.permalink end The specific error message I get is: article_url failed to generate from {:action=>"show", :controller=>"articles", :id=>nil}, expected: {:action=>"show", :controller=>"articles"}, diff: {:id=>nil} Without the prev and next everything is working fine but I'm out of ideas as to why this isn't working. Anyone want to helo?

    Read the article

  • CanCan polymorphic resource access problem

    - by Call 'naive' True
    Hi everybody, i don't quite understand how to restrict access to links in this particular case with CanCan. I always get "Edit" link displayed. So i believe the problem is in my incorrect definition of cancan methods(load_ and authorize_). I have CommentsController like that: class CommentsController < ApplicationController before_filter :authenticate_user! load_resource :instance_name => :commentable authorize_resource :article def index @commentable = find_commentable #loading our generic object end ...... private def find_commentable params.each { |name, value| if name =~ /(.+)_id$/ return $1.classify.constantize.includes(:comments => :karma).find(value) end } end end and i have in comments/index.html.erb following code that render file from other controller: <%= render :file => "#{get_commentable_partial_name(@commentable)}/show.html.erb", :collection => @commentable %> you can think about "#{get_commentable_partial_name(@commentable)}" like just "articles" in this case. Content of "articles/show.html.erb": <% if can? :update, @commentable %> <%= link_to 'Edit', edit_article_path(@commentable) %> | <% end %> my ability.rb: class Ability include CanCan::Ability def initialize(user) user ||= User.new # guest user if user.role? :admin can :manage, :all elsif user.role? :author can :read, [Article, Comment, Profile] can :update, Article, :user_id => user.id end end end relations with models is: class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true, :dependent => :destroy ... end class Article < ActiveRecord::Base has_many :comments, :as => :commentable, :dependent => :destroy ... end i have tried debug this issue like that user = User.first article = Article.first ability = Ability.new(user) ability.can?(:update, article) and i always get "= true" in ability check Note: user.role == author and article.user_id != user.id if you need more information please write thank's for your time && sorry for my english

    Read the article

  • Rails log shows unexpected data as to the time spent on a DB stuff

    - by Arhimed
    I'm running on WinXP + Ruby 1.8.6 + Rails 2.3.5 (frozen to the project) in development environment. Looking at development.log I observe inconsistent data as to the time spent on a database stuff. Example #1 (good): Processing PagesController#index (for 127.0.0.1 at 2010-05-11 12:15:54) [GET] Parameters: {"action"=>"index", "controller"=>"pages"} City Columns (563.0ms) SHOW FIELDS FROM `cities` City Load (15.0ms) SELECT * FROM `cities` WHERE (`cities`.`short_name` = 'NY') LIMIT 1 Redirected to http://xyz:3000/sightings Completed in 953ms (DB: 578) | 302 Found [http://xyz/] Example #2 (unexpected): Processing PagesController#index (for 127.0.0.1 at 2010-05-11 12:15:36) [GET] Parameters: {"action"=>"index", "controller"=>"pages"} City Columns (0.0ms) SHOW FIELDS FROM `cities` City Load (0.0ms) SELECT * FROM `cities` WHERE (`cities`.`short_name` = 'NY') LIMIT 1 Redirected to http://xyz:3000/sightings Completed in 47ms (DB: 32) | 302 Found [http://xyz/] Example #2 shows 32ms were spent on DB while there were just 2 sql querries and both of zero time spent. Example #3 (unexpected): Processing PagesController#index (for 127.0.0.1 at 2010-05-11 11:21:24) [GET] Parameters: {"action"=>"index", "controller"=>"pages"} City Columns (63.0ms) SHOW FIELDS FROM `cities` City Load (62.0ms) SELECT * FROM `cities` WHERE (`cities`.`short_name` = 'NY') LIMIT 1 Redirected to http://xyz:3000/sightings Completed in 1187ms (DB: 297) | 302 Found [http://xyz/] Example #3 shows 297ms while there were querries of 63ms and 62ms (125ms in total). Can't understand it. Could someone explain? Thanks in advance.

    Read the article

  • Database layout for an application with geocoding features using geokit

    - by vooD
    I'm developing a real estate web catalogue and want to geocode every ad using geokit gem. My question is what would be the best database layout from the performance point if i want to make search by country, city of the selected country, administrative area or nearest metro station of the selected city. Available countries, cities, administrative areas and metro sations should be defined by the administrator of catalogue and must be validated by geocoding. I came up with single table: create_table "geo_locations", :force => true do |t| t.integer "geo_location_id" #parent geo location (ex. country is parent geo location of city t.string "country", :null => false #necessary for any geo location t.string "city", #not null for city geo location and it's children t.string "administrative_area" #not null for administrative_area geo location and it's children t.string "thoroughfare_name" #not null for metro station or street name geo location and it's children t.string "premise_number" #house number t.float "lng", :null => false t.float "lat", :null => false t.float "bound_sw_lat", :null => false t.float "bound_sw_lng", :null => false t.float "bound_ne_lat", :null => false t.float "bound_ne_lng", :null => false t.integer "mappable_id" t.string "mappable_type" t.string "type" #country, city, administrative area, metro station or address end Final geo location is address it contains all neccessary information to put marker of the real estate ad on the map. But i'm still stuck on search functionality. Any help would be highly appreciated.

    Read the article

  • C++ File manipulation problem

    - by Carlucho
    I am trying to open a file which normally has content, for the purpose of testing i will like to initialize the program without the files being available/existing so then the program should create empty ones, but am having issues implementing it. This is my code originally void loadFiles() { fstream city; city.open("city.txt", ios::in); fstream latitude; latitude.open("lat.txt", ios::in); fstream longitude; longitude.open("lon.txt", ios::in); while(!city.eof()){ city >> cityName; latitude >> lat; longitude >> lon; t.add(cityName, lat, lon); } city.close(); latitude.close(); longitude.close(); } I have tried everything i can think of, ofstream, ifstream, adding ios::out all all its variations. Could anybody explain me what to do in order to fix the problem. Thanks!

    Read the article

  • Why does this sql statement keep saying it is a boolean and not a paramter? (php/Mysql)

    - by ggfan
    In this statement, I am trying to see if there if the latest posting in the database that has the exact same title, price, city, state, detail. If there is, then it would say to the user that the exact post has been already made; if not then insert the posting into the dbc. (This is one type of check so that users can't accidentally post twice. This may not be the best check, but this statement error is annoying me, so I want it to work :)) Why won't this sql work? I think it's not letting the title=$title and not getting the value in the $title... ERROR: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in postad.php on line 365 //there is a form that users fill out that has title, price, city, etc <form> blah blah </form> //if users click submit, then does all the checks and if all okay, insert to dbc if (isset($_POST['submit'])) { // Grab the pposting data from the POST and gets rid of any funny stuff $title = mysqli_real_escape_string($dbc, trim($_POST['title'])); $price = mysqli_real_escape_string($dbc, trim($_POST['price'])); $city = mysqli_real_escape_string($dbc, trim($_POST['city'])); $state = mysqli_real_escape_string($dbc, trim($_POST['state'])); $detail = mysqli_real_escape_string($dbc, trim($_POST['detail'])); if (!is_numeric($price) && !empty($price)) { echo "<p class='error'>The price can only be numbers. No special characters, etc</p>"; } //Error problem...won't let me set title=$title, detail=$detail, etc. //this statement after all the checks so that none of the variables are empty $query="Select * FROM posting WHERE user_id={$_SESSION['user_id']} AND title=$title AND price=$price AND city=$city AND state=$state AND detail=$detail"; $data = mysqli_query($dbc, $query); if(mysqli_num_rows($data)==1) { echo "You already posted this ad. Most likely caused by refreshing too many times."; } }

    Read the article

  • Rails: RESTful Find, Initialize, or Create

    - by Andrew
    I have an app that has Cities in it. I'm looking for some suggestions on how to RESTfully structure a controller so that I can lookup, initialize, and create city records via AJAX requests. For instance: Given a text field city_name A user enters the name of a City, like "Paris, France" The app checks this location to see if there is such a city in the database already If there is, it returns the city object If there is not, it returns a new record initialized with the name "Paris" and the country "France", and prompts the user to confirm they want to add this city to the database If the user says "Yes" the record is saved. If not the record is discarded and the form is cleared. Now, my first approach was to change the Create action to use find_or_create, so that an AJAX post to cities_path would result in either returning the existing city or creating it and returning it. That works ok... However, it would be better to setup controller actions that would take a string input, find , or else initialize and return, then only create if the user confirms the generated record is correct. The ideal scenario would put this all in one action so AJAX request can go to that url, the server responds with JSON objects, and javascript can handle things from there. I'd like to keep all the user-interaction logic client side, and also minimize the number of requests it takes to achieve this. Any suggestions on the cleanest, most RESTful way to accomplish this?

    Read the article

  • Would you allow this type of query?

    - by user564577
    I'm exploring using an ORM tool in our development shop, and in particular Entity Framework 4.0. Since we work with VERY large databases, I'm a bit concerned about the query's it generates. Doing something simple like getting clients with an address in a state looks like below. As a database developer or admin would you allow this? Is it as bad as it looks? Assume every join is on a clustered index. SELECT [Project2].[ClientKey] AS [ClientKey], [Project2].[FirstName] AS [FirstName], [Project2].[LastName] AS [LastName], [Project2].[IsEnabled] AS [IsEnabled], [Project2].[ChangeUser] AS [ChangeUser], [Project2].[ChangeDate] AS [ChangeDate], [Project2].[C1] AS [C1], [Project2].[AddressKey] AS [AddressKey], [Project2].[ClientKey1] AS [ClientKey1], [Project2].[AddressTypeCode] AS [AddressTypeCode], [Project2].[PrimaryAddress] AS [PrimaryAddress], [Project2].[AddressLine1] AS [AddressLine1], [Project2].[AddressLine2] AS [AddressLine2], [Project2].[City] AS [City], [Project2].[State] AS [State], [Project2].[ZIP] AS [ZIP] FROM ( SELECT [Distinct1].[ClientKey] AS [ClientKey], [Distinct1].[FirstName] AS [FirstName], [Distinct1].[LastName] AS [LastName], [Distinct1].[IsEnabled] AS [IsEnabled], [Distinct1].[ChangeUser] AS [ChangeUser], [Distinct1].[ChangeDate] AS [ChangeDate], [Extent3].[AddressKey] AS [AddressKey], [Extent3].[ClientKey] AS [ClientKey1], [Extent3].[AddressTypeCode] AS [AddressTypeCode], [Extent3].[PrimaryAddress] AS [PrimaryAddress], [Extent3].[AddressLine1] AS [AddressLine1], [Extent3].[AddressLine2] AS [AddressLine2], [Extent3].[City] AS [City], [Extent3].[State] AS [State], [Extent3].[ZIP] AS [ZIP], CASE WHEN ([Extent3].[AddressKey] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1] FROM (SELECT DISTINCT [Extent1].[ClientKey] AS [ClientKey], [Extent1].[FirstName] AS [FirstName], [Extent1].[LastName] AS [LastName], [Extent1].[IsEnabled] AS [IsEnabled], [Extent1].[ChangeUser] AS [ChangeUser], [Extent1].[ChangeDate] AS [ChangeDate] FROM [Common].[Clients] AS [Extent1] INNER JOIN [Common].[ClientAddresses] AS [Extent2] ON [Extent1].[ClientKey] = [Extent2].[ClientKey] WHERE (( CAST(CHARINDEX(UPPER('D'), UPPER([Extent1].[LastName])) AS int)) > 0) AND ([Extent1].[IsEnabled] = 1) AND ([Extent2].[City] IS NOT NULL) AND ((UPPER([Extent2].[City])) = (UPPER('Colorado Springs'))) ) AS [Distinct1] LEFT OUTER JOIN [Common].[ClientAddresses] AS [Extent3] ON [Distinct1].[ClientKey] = [Extent3].[ClientKey] ) AS [Project2] ORDER BY [Project2].[ClientKey] ASC, [Project2].[FirstName] ASC, [Project2].[LastName] ASC, [Project2].[IsEnabled] ASC, [Project2].[ChangeUser] ASC, [Project2].[ChangeDate] ASC, [Project2].[C1] ASC

    Read the article

  • Why does this sql statement keep saying it is a boolean and not a parameter? (php/Mysql)

    - by ggfan
    In this statement, I am trying to see if there if the latest posting in the database that has the exact same title, price, city, state, detail. If there is, then it would say to the user that the exact post has been already made; if not then insert the posting into the dbc. (This is one type of check so that users can't accidentally post twice. This may not be the best check, but this statement error is annoying me, so I want it to work :)) Why won't this sql work? I think it's not letting the title=$title and not getting the value in the $title... ERROR: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in postad.php on line 365 //there is a form that users fill out that has title, price, city, etc <form> blah blah </form> //if users click submit, then does all the checks and if all okay, insert to dbc if (isset($_POST['submit'])) { // Grab the pposting data from the POST and gets rid of any funny stuff $title = mysqli_real_escape_string($dbc, trim($_POST['title'])); $price = mysqli_real_escape_string($dbc, trim($_POST['price'])); $city = mysqli_real_escape_string($dbc, trim($_POST['city'])); $state = mysqli_real_escape_string($dbc, trim($_POST['state'])); $detail = mysqli_real_escape_string($dbc, trim($_POST['detail'])); if (!is_numeric($price) && !empty($price)) { echo "<p class='error'>The price can only be numbers. No special characters, etc</p>"; } //Error problem...won't let me set title=$title, detail=$detail, etc. //this statement after all the checks so that none of the variables are empty $query="Select * FROM posting WHERE user_id={$_SESSION['user_id']} AND title=$title AND price=$price AND city=$city AND state=$state AND detail=$detail"; $data = mysqli_query($dbc, $query); if(mysqli_num_rows($data)==1) { echo "You already posted this ad. Most likely caused by refreshing too many times."; } }

    Read the article

  • Speeding up templates in GAE-Py by aggregating RPC calls

    - by Sudhir Jonathan
    Here's my problem: class City(Model): name = StringProperty() class Author(Model): name = StringProperty() city = ReferenceProperty(City) class Post(Model): author = ReferenceProperty(Author) content = StringProperty() The code isn't important... its this django template: {% for post in posts %} <div>{{post.content}}</div> <div>by {{post.author.name}} from {{post.author.city.name}}</div> {% endfor %} Now lets say I get the first 100 posts using Post.all().fetch(limit=100), and pass this list to the template - what happens? It makes 200 more datastore gets - 100 to get each author, 100 to get each author's city. This is perfectly understandable, actually, since the post only has a reference to the author, and the author only has a reference to the city. The __get__ accessor on the post.author and author.city objects transparently do a get and pull the data back (See this question). Some ways around this are Use Post.author.get_value_for_datastore(post) to collect the author keys (see the link above), and then do a batch get to get them all - the trouble here is that we need to re-construct a template data object... something which needs extra code and maintenance for each model and handler. Write an accessor, say cached_author, that checks memcache for the author first and returns that - the problem here is that post.cached_author is going to be called 100 times, which could probably mean 100 memcache calls. Hold a static key to object map (and refresh it maybe once in five minutes) if the data doesn't have to be very up to date. The cached_author accessor can then just refer to this map. All these ideas need extra code and maintenance, and they're not very transparent. What if we could do @prefetch def render_template(path, data) template.render(path, data) Turns out we can... hooks and Guido's instrumentation module both prove it. If the @prefetch method wraps a template render by capturing which keys are requested we can (atleast to one level of depth) capture which keys are being requested, return mock objects, and do a batch get on them. This could be repeated for all depth levels, till no new keys are being requested. The final render could intercept the gets and return the objects from a map. This would change a total of 200 gets into 3, transparently and without any extra code. Not to mention greatly cut down the need for memcache and help in situations where memcache can't be used. Trouble is I don't know how to do it (yet). Before I start trying, has anyone else done this? Or does anyone want to help? Or do you see a massive flaw in the plan?

    Read the article

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