Why and not ?
Friday, December 28th, 2007Curious question, this: I've been using <strong> and <em> for ages now, but I never fully understood why they switched to this from <b> and <i>. Anybody got an easy-to-understand explanation?
Curious question, this: I've been using <strong> and <em> for ages now, but I never fully understood why they switched to this from <b> and <i>. Anybody got an easy-to-understand explanation?
I'm looking for Good Book On PHP & MySQL which will to learn from novice to professional.
This recommendation will help who are seeking or looking for good book on
PHP & MySQL
Hello, I have been trying to produce a simple Blog editor for my own site but as soon as I get close to the end, There is a problem. This time I have tried to put a bit of a javascript function in the posts and they run of of a PHP echo so trying to get it to work is a problem. It might just be easier to show you.
echo '<div id="floater">';
echo '<a href="javascript:change();"><img src="information.png" alt="-" /></a>';
echo '<div id="floating_box">';
echo "<b>Title:</b> ".$row['ATitle']. "<br />";
echo "<b>Author:</b> ".$row['AAuthor']. "<br />";
echo "<b>Date:</b> ".$row['ADate']. "<br />";
echo "<b>Tags:</b> ".$row['AATags']. "<br />";
echo '</div>';
echo '</div>';
I can't find a way to run the function where it doesn't interfere with itself. Because the java-script selects the element by id, I can't do too much with it. I was hoping there would be a way to run it as a child of the link so I could run it as a:
document.child.getElementById('Floating_box').style;
Even though that isn't probably the real function. But I do need to run it so there can be multiple of these boxes on the page. Thank-you.
I am doing a query for some data, if the query is empty or returns no data because there is none. How do I show that the query was empty?
Here I am finding Todo’s via params[:id]
@todo = Todo.find(params[:id])
Now if this comes back with some data it will list out what is in the database. But if it returns nothing how do I show this?
if @todo == nil
@todo = "Sorry No Todo's!"
end
I have tried an if statement (above) but it does not work... How do I show the following text? “Sorry No Todo’s” if there is nothing in the database?
I'm not a hardcore Javascript guy but I certainly have done my fair share of coding in the past, with and without Ajax, with and without libraries, etc.
One thing that's always racked my brain is that on a page that loads multiple pieces of content in via Ajax at the same time, how do you do this without needing multiple copies of the same function? When I've tried this in the past with a function called like this:
loadIntoPage( 'IDofdiv', 'http://ajaxurl.com/returnhtml.php');
The multiple Ajax calls get all tangled up, their variables overlap, and nothing ends up displaying. But if I make multiple copies of that function (one for each Ajax-loaded block) and name all the variables differently, then it works.
I know there's a better way of doing it, so does anyone have some insight?

I am trying to set a cookie in Ruby on Rail as you see below. I have set a session and had it working fine, but now my app is calling for cookies. I know how to set them, I get this crazy error and I don’t have a solution for it. I have searched all over and come up with nothing!
This is the error: private method gsub called for 4:Fixnum
I have never seen the error until I added this line to add a cookie: cookies[:acc] = account.id
Here is the full def:
def login
if session[:user_id]
redirect_to :action => "dash", :controller => "todo"
end
if request.post? and params[:account]
@account = Account.new(params[:account])
account = Account.find_by_email_and_password(@account.email,@account.password)
if account
session[:user_id] = account.id
cookies[:acc] = account.id #<= this is where i added the line
flash[:notice] = "Logged in!"
redirect_to :action => "dash", :controller => "todo"
else
@account.password = nil
flash[:notice] = "Sorry your eamil or password is invalid."
end
end
end
So what am I doing wrong here? I check the browser and it has not set a cookie. Let me know!
Hello, I am newer to rails and I am having a issues with deleting some records in a mysql database. The problem started when I try to delete two items (Lists) and (Todos) the todos are related to the lists so when you delete a list I need the todos to be deleted. This part is working good, but when I try to delete a list with NO todos it gives me an error telling me I have a nil object.
So in trying to fix this I have come up with what I have below. The way I have works BUT I still get an error (The error occurred while evaluating nil.all_hashes). I have checked the MySQL database and the data is gone so it works fine but I just keep getting this error. How can I fix this and do it in a more proper manner then what I have?
def delete
List.find(params[:id]).destroy
@num = Todo.find_by_list_id(params[:id])
if @num == nil
redirect_to :action => "dash"
else
Todo.find_by_sql("DELETE FROM todos WHERE list_id='#{params[:id]}%'")
redirect_to :action => "dash"
end
end
Hey I am newer to rails and have a question again! I am trying to take an id an place it in the database see below:
Controller:
def addtodo
@todo = Todo.new(params[:todo])
@todo.account_id = session[:user_id]
@todo.stat = 1
@todo.list_id = :list_id
if @todo.save
flash[:notice] = 'Your todo was successfully created.'
redirect_to :action => 'list', :id => list
else
flash[:notice] = 'Sorry, we cant add the todo.'
end
end
Also, i am trying to redirect the user back to the list by using
redirect_to :action => 'list', :id => list
I know that is wrong but what is the right way?
The Model:
has_many :todos, :foreign_key => :list_id
Now the link on the page is (/list/2 <-- the id of the list) That id needs to go into the database. I have tried using (params[:id]) to get it but cant! What do I need to do, or what am I doing wrong???