943,534 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 814
  • PHP RSS
Dec 3rd, 2008
0

generating random id and save it into db

Expand Post »
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:

php Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mm2409 is offline Offline
6 posts
since Dec 2008
Dec 3rd, 2008
0

Re: generating random id and save it into db

Why don't you generate some MD5 hash for random numbers yourself ?
Reputation Points: 11
Solved Threads: 3
Junior Poster in Training
chrisranjana is offline Offline
82 posts
since Jul 2005
Dec 3rd, 2008
0

Re: generating random id and save it into db

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.


Why don't you generate some MD5 hash for random numbers yourself ?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mm2409 is offline Offline
6 posts
since Dec 2008
Dec 3rd, 2008
0

Re: generating random id and save it into db

you should try echoing the query first just to check that it really works out

php Syntax (Toggle Plain Text)
  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. .")"
Reputation Points: 10
Solved Threads: 1
Newbie Poster
xarz is offline Offline
24 posts
since Nov 2008
Dec 4th, 2008
0

Re: generating random id and save it into db

i did ..it gives result object id #2
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mm2409 is offline Offline
6 posts
since Dec 2008
Dec 4th, 2008
0

Re: generating random id and save it into db

have you to tried to check the mysql errors?

php Syntax (Toggle Plain Text)
  1. echo mysql_error();

or an alternative to the insert statement

php Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
xarz is offline Offline
24 posts
since Nov 2008
Dec 4th, 2008
0

Re: generating random id and save it into db

i spotted something also which perhaps can solve your problem
php Syntax (Toggle Plain Text)
  1. $que_id = uniqid(que);

should be

php Syntax (Toggle Plain Text)
  1. $que_id = uniqid($que);
Reputation Points: 10
Solved Threads: 1
Newbie Poster
xarz is offline Offline
24 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Gaming basics
Next Thread in PHP Forum Timeline: Dynamic Title Generation using PHP and MySql





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC