Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Can't Make This Query Working.
Feelay
post Jun 10 2008, 11:46 AM
Post #1


Kinda N00B
Group Icon

Group: Members
Posts: 230
Joined: 13-January 08
From: Sweden
Member No.: 27,579



Hi again.

I am trying to make a new Register script. But now, there is only one thing that is not working.. I can't make the following query work.

CODE
mysql_query("INSERT INTO members(username, password, email, register_date) VALUES ('$user','$pass','$email', '$reg_date')") or die("Failed to register.<br> Error:".mysql_error());



this is the current date variable, that is causing the error. (if I remove it from the query, it works just fine)
CODE
$reg_date=date("Y/m/d");


this is the error I am getting:

QUOTE
Error:Data truncated for column 'register_date' at row 1



in the database I gave it the data type int, because the date is only made out of numbers.

Thanks for your help //Feelay

This post has been edited by Feelay: Jun 11 2008, 07:39 AM
Go to the top of the page
 
+Quote Post
TavoxPeru
post Jun 13 2008, 10:13 AM
Post #2


Super Member
Group Icon

Group: [HOSTED]
Posts: 765
Joined: 8-April 06
From: Lima - Peru
Member No.: 12,579



Your query don't work because your variable stores a string like "2008/06/13", the "/" character cause this error to happen.

To fix it simply change your variable's date format to:

CODE
<?php
$reg_date=date("Ymd");
?>

But this can lead to get problems with the register_date field, i'm not sure about this.

A better solution is to change the data type of the register_date field to date and change the sql query to:

CODE
<?php
mysql_query("INSERT INTO members(username, password, email, register_date) VALUES ('$user','$pass','$email', NOW())") or die("Failed to register.<br> Error:".mysql_error());
?>

Best regards,
Go to the top of the page
 
+Quote Post
Feelay
post Jun 13 2008, 11:32 AM
Post #3


Kinda N00B
Group Icon

Group: Members
Posts: 230
Joined: 13-January 08
From: Sweden
Member No.: 27,579



Thanks ^.^

lol tongue.gif I forgot that "/" was in the variable tongue.gif
Anyways.. it is working now =)

Thank you //Feelay
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. How To Make A Text Based Online Game Script ?(23)
  2. How Do I Make A RPG Battle System?(14)
  3. Online Multiplayer Game(16)
  4. Make Your Own FPS Game(32)
  5. System Sounds Not Working(9)
  6. Java Applets(5)
  7. How To Make Your Windows Look Like A Mac(22)
  8. How To Make A Good Sig Image!(6)
  9. Photoshop Tutorial: How To Make A Userbar For Signatures(35)
  10. VB6-MS Access Question(8)
  11. ATI Radeon 9250 Issues(8)
  12. How To Run A Proxy On a Web-Server?(20)
  13. Lock Workstation Shortcut(9)
  14. Help, My Laptop Charger Is Not Working Properly(17)
  15. Real Driving(24)
  1. How To Make Realistic Fire!(15)
  2. How To Make A Private Message System.(9)
  3. Make It Impossible To View Page Source(11)
  4. View New Posts Not Working(12)
  5. Anyone Willing To Make A Text-based Game With Me?(4)
  6. Make Money Online With Cashcrate - A Scam?(4)
  7. Cpanel Isn't Working.(14)
  8. Is It Possible To Make Php Scripts Executed Without A Cron?(2)
  9. Center Update(5)
  10. How To Make Simple Animations In The Gimp(2)
  11. What Are The Ways To Make Your Poems Spread To The Audience?(3)
  12. Make Firefox Look Like Google Chrome(1)
  13. How To Make Both Windows Look Like Active At Same Time(7)


 



- Lo-Fi Version Time is now: 14th October 2008 - 07:31 AM