RSS Forums RSS

generating random id and save it into db

Reply
Posts: 6
Reputation: mm2409 is an unknown quantity at this point 
Solved Threads: 0
mm2409 mm2409 is offline Offline
Newbie Poster

generating random id and save it into db

  #1  
Dec 3rd, 2008
dear frnds,

i hace wrote this code to generate unique id for questionnaire and a query to save it into database with two more value (response id and date)

individually i have checked and unique id function is working.
even insert query is also executing correctly.

but when i put it whole into my php file it doesnt save values into DB.

please help to sort it out. i m in hurry.

code is here:

  1. $que_id = uniqid(que);
  2. echo $que_id;
  3. echo "<br>";
  4.  
  5. $db->query("INSERT INTO tbl_CT_Responses (Response_ID,Questionnaire_ID,Response_Date)
  6. VALUES (".GetSQLValueString("",`int`).","
  7. .GetSQLValueString($que_id,`int`).","
  8. .GetSQLValueString(date('Y-m-d'),`date`)
  9. .")");
  10.  
  11. echo "The questionnaire ID is inserted successfully";
  12. ?>
Last edited by peter_budo : Dec 3rd, 2008 at 5:53 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
AddThis Social Bookmark Button
Reply With Quote  
Posts: 72
Reputation: chrisranjana is an unknown quantity at this point 
Solved Threads: 3
chrisranjana chrisranjana is offline Offline
Junior Poster in Training

Re: generating random id and save it into db

  #2  
Dec 3rd, 2008
Why don't you generate some MD5 hash for random numbers yourself ?
Chris, Director, Chrisranjana.com
Web developers and software programmers.
Reply With Quote  
Posts: 6
Reputation: mm2409 is an unknown quantity at this point 
Solved Threads: 0
mm2409 mm2409 is offline Offline
Newbie Poster

Re: generating random id and save it into db

  #3  
Dec 3rd, 2008
i can use MD5 hash for random numbers (even i m using it ) but the problem is data is not inserting into db.also not showing any error.

till now cudnt find the reason.


Originally Posted by chrisranjana View Post
Why don't you generate some MD5 hash for random numbers yourself ?
Reply With Quote  
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: generating random id and save it into db

  #4  
Dec 3rd, 2008
you should try echoing the query first just to check that it really works out

  1. echo "INSERT INTO tbl_CT_Responses (Response_ID,Questionnaire_ID,Response_Date)
  2. VALUES (".GetSQLValueString("",`int`).","
  3. .GetSQLValueString($que_id,`int`).","
  4. .GetSQLValueString(date('Y-m-d'),`date`)
  5. .")"
:: xarz ::
Reply With Quote  
Posts: 6
Reputation: mm2409 is an unknown quantity at this point 
Solved Threads: 0
mm2409 mm2409 is offline Offline
Newbie Poster

Re: generating random id and save it into db

  #5  
Dec 4th, 2008
i did ..it gives result object id #2
Reply With Quote  
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: generating random id and save it into db

  #6  
Dec 4th, 2008
have you to tried to check the mysql errors?

  1. echo mysql_error();

or an alternative to the insert statement

  1. $db->query("INSERT INTO tbl_CT_Responses
  2. SET
  3. Response_ID=".GetSQLValueString("",`int`).",
  4. Questionnaire_ID=".GetSQLValueString($que_id,`int`).",
  5. Response_Date=".GetSQLValueString(date('Y-m-d'),`date`)."
  6. ");

hope it will work out for you.
:: xarz ::
Reply With Quote  
Posts: 24
Reputation: xarz is an unknown quantity at this point 
Solved Threads: 1
xarz's Avatar
xarz xarz is offline Offline
Newbie Poster

Re: generating random id and save it into db

  #7  
Dec 4th, 2008
i spotted something also which perhaps can solve your problem
  1. $que_id = uniqid(que);

should be

  1. $que_id = uniqid($que);
:: xarz ::
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 499 | Replies: 6 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:26 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC