Forum: MySQL 19 Days Ago |
| Replies: 5 Views: 442 Congrats on solving your problem. I am glad you learnt something new :)
If you post your answer, even others may get to learn something from this thread. |
Forum: MySQL 19 Days Ago |
| Replies: 5 Views: 442 Seems like you didn't read the member rules. (http://www.daniweb.com/forums/faq.php?faq=daniweb_policies)
Ch, ch. Read more on count and group by clauses. After reading them, you will be able to... |
Forum: MySQL 19 Days Ago |
| Replies: 9 Views: 542 Dude, datatype as in int, varchar, date, datetime, etc.
ALTER TABLE clown_contest MODIFY COLUMN `location` varchar(40) AFTER `state`
Clear ? :) |
Forum: MySQL 20 Days Ago |
| Replies: 9 Views: 542 You forgot the datatype! (doh, even I forgot it in the syntax).
Sorry, here is the right syntax.
ALTER TABLE tablename MODIFY COLUMN columnname datatype AFTER columnname
This works for sure! |
Forum: MySQL 20 Days Ago |
| Replies: 9 Views: 542 Hey, sorry. I misunderstood the question.
/*
ALTER TABLE tablename MODIFY COLUMN columnname AFTER columnname
*/
Eg. ALTER TABLE members MODIFY COLUMN date_of_birth date AFTER username
... |
Forum: MySQL 21 Days Ago |
| Replies: 9 Views: 542 Very simple.
ALTER TABLE tablename ADD columnname datatype AFTER columnname |
Forum: MySQL 33 Days Ago |
| Replies: 4 Views: 499 Hi, can you elaborate your question ?
If you are inserting the value to the table from php, you can use substr (http://php.net/manual/en/function.substr.php) to insert only a part of a string. If... |
Forum: MySQL May 22nd, 2009 |
| Replies: 2 Views: 2,286 You should escape ' before adding it to the database.
Use,
$link = mysql_real_escape_string($_POST['link']);
$sql="INSERT INTO catalog (link)
VALUES ('$link')";
You got that error... |
Forum: MySQL Apr 22nd, 2009 |
| Replies: 3 Views: 930 All the directories will be in data folder under mysql directory. If you have installed WAMP, for example, the databases will be in c:\wamp\mysql\data :) Look for data directory. |
Forum: MySQL Apr 22nd, 2009 |
| Replies: 14 Views: 1,489 1. I would never use form element's names like, Y M D, ie., with spaces. Try,
<input id="dmy" name="dmy" type="text" />
And in the php script,
$date =... |
Forum: MySQL Apr 5th, 2009 |
| Replies: 6 Views: 688 You can use @ before mysql statements to supress the warning and error messages.
@mysql_connect(...) |
Forum: MySQL Apr 5th, 2009 |
| Replies: 6 Views: 688 This is a comparison operator and you are comparing if the value of $conn_server is "true". So, you should use == instead of =.
Apart from that, I don't see anything wrong with your code which... |
Forum: MySQL Apr 3rd, 2009 |
| Replies: 1 Views: 504 Please post your code and explain your problem in detail. Use [code] tags to wrap your code. |
Forum: MySQL Apr 3rd, 2009 |
| Replies: 3 Views: 824 |
Forum: MySQL Apr 3rd, 2009 |
| Replies: 3 Views: 824 escape single quotes and forward slashes by using mysql_real_escape_string. This will prevent sql injections as well.
Ie.,
$leavetype = mysql_real_escape_string($leavetype);
$fullday =... |
Forum: MySQL Mar 4th, 2009 |
| Replies: 17 Views: 1,457 Yeah.. 1 solution, good. 2 solutions, better :)
Get some sleep dude! Cheers! |
Forum: MySQL Mar 4th, 2009 |
| Replies: 17 Views: 1,457 @Dickersonka, I have been advised on so many occasions not to use joins. Joins are relatively slower compared to subqueries. This is what I have read. |
Forum: MySQL Mar 4th, 2009 |
| Replies: 17 Views: 1,457 Subqueries are even better.. :)
select `user_id`, (select count(`comment`) from `comments_table` where `comments_table`.`user_id`=`users_table`.`user_id`) AS `xcnt` FROM `users_table`
GROUP BY... |
Forum: MySQL Mar 4th, 2009 |
| Replies: 17 Views: 1,457 I modified your query a little bit and I don't know why it doesn't return users who have post = 0.
SELECT COUNT(
COMMENT ) AS `post_count` , (
SELECT `user_id`
FROM `users_table` u
WHERE... |
Forum: MySQL Mar 4th, 2009 |
| Replies: 17 Views: 1,457 Nice queries.. But still, that wouldn't solve what OP is looking for.. The still doesn't return the count as 0, if a user doesn't have any posts. I created dummy tables to create the same scenario... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 After
$result = mysql_query("SELECT * FROM clients WHERE clientID=$_POST[bookingID]");
Use
if(mysql_num_rows($result) > 0 ) {
// record exists.. Do whatever you want to do with that record... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 Use mysql_num_rows($result)
For example,
$query = "select *from table where id='".$_POST['id']."'";
$result = mysql_query($query);
if(mysql_num_rows($result) > 0 ) {
//record exists
} else... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 Emm.. You can mark this thread as solved if all your questions have been answered. If you are extremely happy with Maxmumford's help, you can add to his reputation. Click on 'Add to MaxMumford's... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 It wont. You have to save it in varchar datatype, which again would cause you problems. For example, you can't sort the fields on date. You can't calculate the difference (or add) x number of days to... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 My suggestion is, store date in YYYY-mm-dd format itself. You can change the format using php's date function. As maxmumford has already mentioned, you can convert that date to unixtimestamp and use... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 Hmm.. Okay! From what I have read so far, this is what STR_TO_DATE do.
STR_TO_DATE(date_string, format);
STR_TO_DATE function will format string and insert it to the date column. The second... |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 echo your query. Execute it in phpmyadmin. See what's the exact error.
P.S. I tried to work with str_to_date and I simply can't get it to work ! :-/ |
Forum: MySQL Mar 2nd, 2009 |
| Replies: 34 Views: 4,376 <?php
// open database connection code and then my code as follows
$sql="UPDATE bookings SET startdate... |
Forum: MySQL Feb 28th, 2009 |
| Replies: 14 Views: 3,781 How does your code look like ?
P.S. I will be out of town for 3 days, so, If not me, someone else will help you with your problem :) |
Forum: MySQL Feb 27th, 2009 |
| Replies: 14 Views: 3,781 First, query the table and get all the details of that particular bookingID and then display it. You can also give an option for the user saying something like, "Are you sure want to delete ?" :)... |
Forum: MySQL Feb 27th, 2009 |
| Replies: 14 Views: 3,781 <?php
// open database connection code and then my code as follows
//$id = mysql_insert_id(); << This line wouldn't work ie., $id will be null because there isn't any insert statement before... |
Forum: MySQL Feb 26th, 2009 |
| Replies: 14 Views: 3,781 I can't explain you any better :( Post all the relevant code here. And please use [code] tags. |
Forum: MySQL Feb 26th, 2009 |
| Replies: 14 Views: 3,781 Well, You can do it in quite easily. Before redirecting them to the page where they book a room, use $last_inserted_mysql_id = mysql_insert_id(); to get their clientID.
After getting their... |
Forum: MySQL Feb 26th, 2009 |
| Replies: 14 Views: 3,781 Where are you inserting the value to client table ? |
Forum: MySQL Feb 26th, 2009 |
| Replies: 14 Views: 3,781 last_insert_id() (http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html) in mysql or mysql_insert_id() (http://in2.php.net/mysql_insert_id) in php gets the value of the autoincrement field... |
Forum: MySQL Feb 26th, 2009 |
| Replies: 4 Views: 487 |
Forum: MySQL Feb 26th, 2009 |
| Replies: 7 Views: 1,129 |
Forum: MySQL Feb 26th, 2009 |
| Replies: 4 Views: 487 You are doing it wrong.. $result = mysql_query($query); This will execute the query and return the result resource. You have to then use mysql_fetch_array... |
Forum: MySQL Feb 26th, 2009 |
| Replies: 7 Views: 1,129 When adding the data to the table, use nl2br (http://in.php.net/nl2br) function (if you are using php). |
Forum: MySQL Feb 4th, 2009 |
| Replies: 1 Views: 532 If you 'investigate' properly in phpmyadmin, there is an option exactly below the table's structure to add a new column. You can specify the columnname, its datatype and mention "auto_increment"... |