spark Posted February 20, 2008 Report Share Posted February 20, 2008 Here is the code. When I run it I don't get any error messages. I also don't get the values inserted into a record.Here is the code: <?php$itemNum = '123456789';$title = 'test title';$strtime = 'FEB-23-08 12:02:02';$user="tim";$password="supers";$database="silver";$db = mysql_connect(localhost,$user,$password);mysql_select_db($database,$db) or die( "Unable to select database");$query ="INSERT INTO `silver`.`horse` SET`id` = '' ,`itemNum` = '$itemNum' ,`title` = 'this is y',`strDate` = '1:05' "; mysql_query($query,$db);mysql_close(); ?> When I put the value of $itemNum (123456789) in the query works and makes a new record. I have tried $itemNum without the single qoutes , '{$itemNum}' , '@$itemNum','@itemNum', without sucess. I have seen the form'$itemNum' , on the internet , but it doesn't seem to work for me. I would like to use all php variables in the sql querry. Thanks for the help. Quote Link to comment Share on other sites More sharing options...
olajideolaolorun Posted February 21, 2008 Report Share Posted February 21, 2008 Try: '.$itemNum.', Notice the dots. Quote Best Regards Olajide Olaolorun The Uniform Server Development Team Link to comment Share on other sites More sharing options...
spark Posted February 21, 2008 Author Report Share Posted February 21, 2008 Try: '.$itemNum.', Notice the dots. Thanks for your time. I changed the code a little but still get the same results , It works if I subsitute the value for $itemNum. the code: <?php$itemNum = '123456789';$title = 'test title';$strtime = 'FEB-23-08 12:02:02';$user="tim";$password="supers";$database="silver";$db = mysql_connect(localhost,$user,$password);mysql_select_db($database,$db) or die( "Unable to select database");$query ="INSERT INTO horse SET id = '' , itemNum = '.$itemNum.' , title = 'this is y', strDate = '1:05' "; echo $query;mysql_query($query,$db);mysql_close(); ?> I put the echo statement in to see $query, here is what it prints: INSERT INTO horse SET id = '' , itemNum = '.123456789.' , title = 'this is y', strDate = '1:05' Magic dots do not seem to work for me..... Quote Link to comment Share on other sites More sharing options...
spark Posted February 22, 2008 Author Report Share Posted February 22, 2008 Thanks for your time. I figured out the problem !!! It wasn't in the code.I had the data type set wrong for itemNum in the database. The orginal code works fine now . Thanks again for uniform server . Boy am I sure learning alot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.