generating random id and save it into db

Reply

Join Date: Dec 2008
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

 
0
  #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 6:53 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 78
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

 
0
  #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 Quick reply to this message  
Join Date: Dec 2008
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

 
0
  #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 Quick reply to this message  
Join Date: Nov 2008
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

 
0
  #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 Quick reply to this message  
Join Date: Dec 2008
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

 
0
  #5
Dec 4th, 2008
i did ..it gives result object id #2
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
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

 
0
  #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 Quick reply to this message  
Join Date: Nov 2008
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

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC