Also, if you are receiving an SQL error, it may not necessarily be output to screen. Try this after you run your query:
if( $result == false )
{
echo mysql_error( $link );
}
Again, $link isn't completely necessary, but just in case...
Also, if you are receiving an SQL error, it may not necessarily be output to screen. Try this after you run your query:
if( $result == false )
{
echo mysql_error( $link );
}
Again, $link isn't completely necessary, but just in case...
1) Are you sure about spelling of "varchar"?
2) Have echoed query that is $update variable before executing then exectuted in phpmyadmin sql section?Do not use dummy resolve actual query by echoing $update before exeuting in php.
1. I believe that is the name of his database, not a type of field.
2. I believe in his first post he has listed the actual query.
4. I did not test "$result=true". Should I do this? I was under the impression that if "$result was not = true I would have thrown a php or sql error.
Yes, the documentation does seem to imply that. Maybe just try it to make sure?
This is certainly very strange. Maybe try explicitly stating the connection when you call mysql_query, like so:
$result = mysql_query( $update, $link );
Technically, $link isn't required usually, but maybe something weird is happening between the time you connect and the time you run your query. Sorry I can't be more help but as I say your code looks fine.
Hi cvarcher / Rick and welcome to DaniWeb :)
All of your code looks ok to me, so I am going to ask a few obvious questions:
Firstly, is there a record in the jos_membership table with the supplied ID? Is ID the entire Primary Key of the table? - if so, you don't need LIMIT 1 at the end of your table. Are you refreshing the table data in phpMyAdmin? Is $result true?
Check out the documentation for the strftime function. What you want to do is get the current timestamp ( use time() ) and the timestamp for your time in 7 days (use strtotime() ), get their difference and then use the strftime function to get the string in the form you want.
Try to avoid using port numbers < 1024 unless for their original purpose. They are loosely called "reserved port numbers" because they are used for very specific purposes. Technically you can use them, but you will be blocking what might be an important service from operating while you do.
EDIT: I often use port 8080 for an http-style service as most routers will allow this by default, not that RDP is one but thought I'd add it as an example.
Hi debeginin and welcome to DaniWeb :)
I'm pretty sure MS SQL Server 2000 is a stand-alone install. I know later versions require the .NET Framework, but from memory you should be able to just install SQL and away you go. If you are asking what program do you run, the Management Studio came in in 2005, from memory the 2000 version is called Query Analyzer or something similar.
HTH,
d
Hey javaman2,
What happens with your program if you have $10.30 minus $5.60? What result do you get?
No problem. Set the thread to 'solved' if you don't have any more questions. And Darkagn, you should have let him work through it by himself.
Well I thought I was doing that, eventually after (s)he couldn't get what I was trying to say I decided to do half of it so that they could do the rest, hopefully understanding it in the process.
Are period and month the same thing? What do you define as a working day? Are you wanting to only use MySQL to do this or are you combining with another programming language such as PHP?
But if the data is imported into the first two tables, I don't think you need the third table. Table 2 has the information that you require in Table 3, so you would just be duplicating data.
It needs to match the column name for the ID of the comment being replied to.
Ok, I can see you are trying, I will show you what I would do for your add methods, then you can write the minus methods.
public static Money add(Money m1, Money m2)
{
int dollars1 = m1.getDollars();
int dollars2 = m2.getDollars();
int cents1 = m1.getCents();
int cents2 = m2.getCents();
// now we have all of the info we need to add the two together
int sumDollars = dollars1 + dollars2;
int sumCents = cents1 + cents2;
// now we need to check if we have too many cents
if( sumCents > 100 )
{
sumDollars = sumDollars +1;
sumCents = sumCents - 100;
}
Money output = new Money( sumDollars, sumCents );
return output;
}
public void add(Money m)
{
int dollars1 = this.getDollars();
int dollars2 = m.getDollars();
int cents1 = this.getCents();
int cents2 = m.getCents();
// now we have all our info
int sumDollars = dollars1 + dollars2;
int sumCents = cents1 + cents2;
// again, check to see if we have too many cents
if( sumCents > 100 )
{
sumDollars = sumDollars + 1;
sumCents = sumCents - 100;
}
// now the purpose of this method is to update the caller's values of dollars and cents with new values
this.setDollars( sumDollars );
this.setCents( sumCents );
}
Have a go at the minus methods and let me know if you don't understand what I have done.
That looks ok, except that the add2 and minus2 methods should not return anything (ie void instead of int). Yes, you need to put something in your add and minus methods, but you need to figure out what. I wanted to give you a hint, and let you actually write the method yourself. I would change your toString method too:
public String toString() {
return ("$" + getDollars() + "." + getCents() );
}
Now when you print your Money object it will be in the form of $5.30 for example. You may need to change it for situations where cents < 10 so that it has a leading 0.
No, it is your constructor with two parameters. You call it by saying new.
EDIT: Your constructor methods look ok, by the way. You just need to change your add and minus methods.
echo "<form method=\"post\" action=\"./index.php?act=test&id=".$row['id']."&reply_id=".$row['id']."\">\n";
I believe your problem lies here. You are in effect setting $_GET to $_GET, which in turn sets $reply_id to $tid when the page is refreshed after the submit of the form.
Please use code tags when posting your code.
You have missed the point of my last post. You don't pass in two ints to your static add method, you pass in two objects of type Money, each of whom contain two int fields that need to be added together and returned as a Money object. The test for this would be like so:
Money m1 = new Money(5,30); // this one = $5.30
Money m2 = new Money(6,90); // this one = $6.90
Money m3 = Money.add(m1,m2); // m3 should = $12.20
For the non-static method, you need to create two Money objects and call the add method to add one to the other. The test would look like this:
Money m4 = new Money(5,30); // m4 = $5.30
Money m5 = new Money(6,90); // m5 = $6.90
m4.add(m5); // now m4 should = $12.20
Hint: Your method signature for the add method should look like this:
public static Money add(Money m3, Money m4)
The method should add the dollars and cents of each Money object and return another Money object. You will need to take into account what happens when you add 90 cents to 50 cents to the dollars and cents of the returned object.
A similar approach is required for your static minus method.
EDIT:
For the non-static methods, the following method signature is what is required:
public void add(Money m)
This method should add the dollars and cents values of m to the caller's dollars and cents. Similar for minus.
Have a go, repost if you need further help :)
I believe that the Dude was banned some time last week for posting spam outside the Geeks Lounge which he had been warned about many times before. Not sure what happened to RF though...
Hard to say what is happening in the mss function without seeing the code, however I notice that you use the mss function twice with different parameters:
$msg = mss($_POST['reply']);
$tid = mss($_GET['id']);
Does it return two different things based on what is passed in?
Does mss give you the right id according to the data that you have in the database? That is, is it the mss function or the data in the database that is wrong?
mss function should get the 'ID' of the topic from forum_topics!!!!
I don't think it is returning the right value here. Try echoing $tid just before you run your sql, or better yet, echo the sql to the screen and check that it has the right variables.
What does the mss function do? I think that it is returning nothing whereas it should return the id of the topic...
Sorry I haven't seen a query is empty error before - maybe start a new thread to ask someone else?
The $reply_id is just the ID of the message being replied to. I thought you said before that you were able to retrieve this when the reply button was pressed?
Hi zammari10 and welcome to DaniWeb :)
Your issue is a different one to this thread. I suggest you start a new topic so that more people will read your question and hopefully someone will have an answer for you.
actually the two tables are imported and want to insert the data into third tablei.e pid from first table and cid from second table
By "imported" do you mean that they are in a different database? Is the database on another MySQL server?
So you need to filter your SQL statement according to the dates entered. This is done like so:
$sql="SELECT * FROM visitors WHERE date_visited > '$startdate' AND date_visited < '$enddate'";
where date_visited is the date column in your visitors table and $startdate and $enddate are the dates that the user has selected.
$sql4 = "INSERT INTO forum_replies (tid,uid,message,date,time,reply_id,pid) VALUES($tid,$_SESSION['uid'],'".$msg."','".$date."','".$time."',$reply_id,$pid)";
You need to work out how to find $pid in your php code...
Ah, ok, you need to move your calcarea method inside the class.
EDIT: No wait, it is inside the class. This exception is usually raised when you miss closing a bracket or brace or miss a semi-colon. Double check your code to make sure that hasn't happened. Also "Double" should be "double" in the calcarea signature.
Which line is line 36 of your file?
I assume you want $nowdate to be a string. String concatenation in PHP uses a period character to join strings. This **should** work:
$nowdate = date('Y') . "-" . (date('Y') + 1);
You need to remember the topic id of the post being replied to as well as its ID. The new reply will have a new ID, the same topic id as the post it replied to and a parent id equal to the ID of the post being replied to.
Have you made the necessary change to the forum_replies table? That is, have you added a column to store the parent_id? If so, take a look at my earlier reply (#10) which gives you the SQL you need to insert a new record into the database if it is a reply to a reply. The parent_id of the new record is the id of the comment being replied to, which you are saying you can see...
area = (radius * 3.14)^2;
Two things: first, the area of a circle is PI * r^2 not (r * PI)^2. Secondly, the java compiler doesn't recognise the ^. You need to use the Math.pow method to raise something to a power, but in this case it is easier to just multiply PI by radius by radius.
If it's working as you would like, then it is correct :P
Try testing a few situations to make sure though. What happens if you post a no-message response now? Try it in different browsers if possible, especially IE and FF.
I still have concerns about your html, you don't close the form tag and your newlines might behave strangely. But if it's working then cool! :)
Not sure about this one mate.
Possibly, the html code doesn't have a closing </form>
tag. Also, I notice that you use \n
for a new line in your html, you should use <br>
tags instead for cross platform and browser compatability.
Otherwise, I am not too sure. Try printing out your $_POST
array and checking that there is an entry for 'reply'. Use the print_r
function to do that, like so:
echo "<pre>";
print_r($_POST);
echo "</pre><br>";
private methods are called in exactly the same way as public methods with one difference - you can only call them from within the class that owns them. So , to call the sumString method from the main method for example, you can do the following:
public static void main(String[] args)
{
// ...
String myString = sumString(3,5);
// ...
}
So does dreamweaver put the entire page into one big table when it generates the HTML? I just was wanting to understand exactly why this has worked for you as I will soon be using DW to create a website and have never used the tool before.
Mate, I am going to follow your technique.....as it makes sense.
Now at the moment I have a reply box at the bottom of each thread. which is basically replying directly to the topic instead to the comment.
I have two ideas.....
1. Remove the reply box from the bottom of the page and have a reply button which when clicked on directs to the page to the reply page with the reply box.
2. Now, to reply to a comment have a reply or quote button after each comments
What do you recon how should I do it.......?
Thanks
Yep, that's exactly what I would do. Maybe start with the reply button after each post and worry about the quote button when this is all working. Don't forget that you will need to remember the ID of the post that is being replied to (and later quoted).
(Please see attached.)
How can I adjust my SQL so that when its reply to a reply it will update the parent_id.
Thanks
It's just a matter of adjusting your insert statement so that the parent id is inserted. When the reply button is pressed, you will need to remember the ID of the post being replied to. Let's say it is stored in a variable $pid, then your insert statement becomes:
$sql3 = "INSERT INTO forum_replies (tid,uid,message,date,time,pid) VALUES ($tid,$uid,'$message','$date','$time',$pid)";
Ah ok, sorry I misunderstood your intent. So in order to loop through each product, I would use a CURSOR. Basically a cursor provides a way to loop through objects in a table. Here's a simple example:
-- declare some variables to store the info for each product
DECLARE @ProdID int,
@Description varchar(30),
@Price smallmoney
-- create the cursor
DECLARE ProductCsr CURSOR FOR
SELECT ProdID, Description, Price FROM Products
-- start the cursor and fetch the first record
OPEN ProductCsr
FETCH NEXT ProductCsr INTO @ProdID, @Description, @Price
-- Note that the order of values in the INTO part must match the order in the SELECT statement of the Cursor
-- loop through each record until we get to the end
WHILE @@FETCH_STATUS = 0
BEGIN
-- here is where you do whatever you want to the data
-- for example to update each record with a new price we could
UPDATE Products SET Price = @Price + 1.50 WHERE ProdID = @ProdID AND Description = @Description
-- fetch another record
FETCH NEXT ProductCsr INTO @ProdID, @Description, @Price
END
-- cleanup after yourself
CLOSE ProductCsr
DEALLOCATE ProductCsr
This is a very simple example of how to loop through every record in a table. Cursors can be used for many different things, I think your situation would suit its purpose. Just remember to backup the database beforehand!
This looks to be more of a PHP question than a MySQL question, but I think I can help. I would assign the results to variables in php and then simply add them. Like so:
$w = $row_standings['w'];
$d = $row_standings['d'];
$sum = $w + $d;
echo "$w + $d = $sum";
This can work with multiplication too, just change the + to a *.
Hope this helps,
darkagn :)
Hi srpa01red and welcome to DaniWeb,
This is certainly doable. But I have to ask, if the third table only contains those two fields, is it necessary to create the third table? From the looks of the structure of the second table, you already have that information in that table. Or am I misunderstanding what you are trying to accomplish here?
@arinkverma: th tags are only used for column headings in a table, so they probably should be bold.
@mrniceguy: sorry I am out of ideas, maybe someone else with a bit more knowledge of dreamweaver can help you.
So if I replied to the topic, replying to the post with message "hey", ParentID of my post would be 33, yes. But the ID of my post would not be 33, it would be something else. If auto_increment for example, mine would have ID of 34. So after I replied to that post the tables would look like this:
forum_replies
id - tid - uid - message - date - time - edit_time - parent_id
33 10 4 hey 20/03/2009 1237593182 0 NULL
34 10 6 hey yourself 21/03/2009 1237563999 0 33
forum_topics
id - cid - title - uid - date - time - message
10 9 hello 4 21/03/2009 1237593999 hiya
That's how I would do it anyway. There may be a better solution out there...
All I meant by that was that any post, whether it be a reply to an existing post or one that starts a new topic, should be inserted in this table. If it starts a new topic (as opposed to a reply) I would set a ParentID column to null. If it is a reply to a specific post (as opposed to a topic) I would set ParentID to be the ID of the post that was replied to. TopicID would still house the ID of the thread that was replied to, but in this way you can tell which post has been replied to.
I hope this makes sense, but reading back on it I think I have made myself a bit confused. Let me know...
Hmm, that all looks ok. Try opening the css/styles.css
file and checking it. In particular, check the entry for body, and see if bold has been applied to its style.
In order to tell what parameters you need to pass to the method, you can look at the method signature. In your Pizza class, let's look at how the setSize method is described:
public void setSize (int diameter)
Let's break this signature up into each part so that we can describe what the signature does:
Sorry peedi, I just realised that your setSize method also takes a parameter (as most set methods do). So the call should look like this:
PizzaInfo.setSize(10);
// although a better call would be PizzaInfo.setSize(inches)
// but I wanted you to see what I was doing
Similarly, setCost needs a parameter to tell it what to set the cost to.
You didn't read my note about setCost...
What are the tid and uid columns used for? I think I would have a column for ID of the reply, TopicID for the ID of the thread that it was posted to and a column for ParentID for the ID of the reply that it was posted against. This would mean that every post should be stored in this table, and the first post of a topic would have a NULL ParentID. So instead of forum_replies I would name the table forum_posts.