aconite Posted March 15, 2007 Share Posted March 15, 2007 im tryin to insert a row into a table named transaction.the specification for this table are if (mysql_query("CREATE TABLE transaction (id INT(4) AUTO_INCREMENT NOT NULL PRIMARY KEY, source INT(7) UNSIGNED, destination INT(7) UNSIGNED, amount INT(3) NOT NULL, date DATE , strt_time TIME , end_time TIME , status ENUM(\"TRUE\",\"FALSE\") NOT NULL)") ) { echo("created transaction table"); } the php file is <?php $con = mysql_connect("127.0.0.1","root","12345"); if (!$con) { die('Could not connect: ' . mysql_error()); } else echo "connected"; if(!mysql_select_db("mydatabase")) { die('Could not select database: mydatabase ' . mysql_error()); } $tranSource=5487335; $thePswd=1111; $theDest=1234567; $theAmmount = 60; $today = getdate(); $year = $today['year']; $month = $today['mon']; $mday = $today['mday']; // zero-substitutes MONTH if less than 10, concatenates 'mon' var if ($month < 10) { $month = "0"; $month .= $today['mon']; } // concatenates date in MySQL date format YYYY-MM-DD $date = $year; $date .= "-"; $date .= $month; $date .= "-"; $date .= $mday; echo " "; echo $date; echo " "; $hour1 = $today['hours']; $minute1 = $today['minutes']; $second1 = $today['seconds']; $time1 = $hour1; $time1 .= "-"; $time1 .= $minute1; $time1 .= "-"; $time1 .= $second1; echo " "; echo $time1; echo " "; $today2 = getdate(); $hour2 = $today2['hours']; $minute2 = $today2['minutes']; $second2 = $today2['seconds']; $time2 = $hour2; $time2 .= "-"; $time2 .= $minute2; $time2 .= "-"; $time2 .= $second2; echo " * "; echo $time2; echo " * "; /*qq="insert into transaction(source,destination,amount,date,strt_time,end_time,status) values($tranSource,$theDest,$theAmmount,$date,$time1,$time2,'TRUE')"; mysql_query($qq) or die (mysql_error());*/ mysql_close($con); ?> this gives the output connected 2007-03-15 19-20-7 * 19-20-7 * but if i uncomment the query part i get no output. i cant figure out what is the problem with my query. ???helpppp Link to comment https://forums.phpfreaks.com/topic/42848-solved-error-in-insert-query/ Share on other sites More sharing options...
fenway Posted March 15, 2007 Share Posted March 15, 2007 Echo $qq. Link to comment https://forums.phpfreaks.com/topic/42848-solved-error-in-insert-query/#findComment-208028 Share on other sites More sharing options...
aconite Posted March 15, 2007 Author Share Posted March 15, 2007 i found why there was no output.A really stupid mistake. while defining the query i was using qq instead of $qq. and to use time format i had to use : and not - Link to comment https://forums.phpfreaks.com/topic/42848-solved-error-in-insert-query/#findComment-208087 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.