Jump to content
The Uniform Server Community

another newbee question.


spark
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.....

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...