PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I figured it might have something to do with the space in the name so i tried to use text as the field for unitname. I can insert other $string just fine, or just plain text. However it will not input the unitname from the $tring when i try this code. any ideas?
Thanks,
Nick
<?php
$ini = parse_ini_file('Aloha.ini');
$unitname=$ini['UNITNAME'];
$connection=mysql_connect("localhost","tech303_bec","password") or die("Could not connect to the database server");
$db= mysql_select_db("tech303_bec",$connection) or die ("Unable to select database.");
$sql="INSERT INTO customer (unitname) VALUES ('$unitname')";
mysql_query($sql,$connection) or die ('Could not insert data');
echo('Data inserted successfully.');
mysql_close($connection);
?>
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
$keyresult is a reference to an internal resource. In order to retrieve information from that resource, you must use one of the fetch functions provided by the MySQL API. There are several to choose from: mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_assoc() and mysql_fetch_row(). There's also mysql_result(), but I can rarely recommend using that over one of the other fetch functions.