jlgray48 Posted April 22, 2007 Share Posted April 22, 2007 Here is my code..... I have a database named uah and and a table within uah named yahoo with id and name as fields. <? $name = "Kim"; $id = "44"; $conn=mysql_connect("127.0.0.1", "odbc", ""); mysql_select_db("uah",$conn); $sql = "Insert into yahoo values('$id', '$name')"; mysql_query($sql,$conn); $result = mysql_query($sql,$conn); ?> Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/ Share on other sites More sharing options...
Glyde Posted April 22, 2007 Share Posted April 22, 2007 Try this <? $name = "Kim"; $id = "44"; $conn = mysql_connect("127.0.0.1", "odbc", ""); mysql_select_db("uah", $conn); $sql = "INSERT INTO yahoo VALUES('$id', '$name')"; $result = mysql_query($sql, $conn) or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/#findComment-235280 Share on other sites More sharing options...
jlgray48 Posted April 22, 2007 Author Share Posted April 22, 2007 Still no changes..... Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/#findComment-235285 Share on other sites More sharing options...
Glyde Posted April 22, 2007 Share Posted April 22, 2007 Are you sure that your username and password are correct? Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/#findComment-235287 Share on other sites More sharing options...
jlgray48 Posted April 22, 2007 Author Share Posted April 22, 2007 Someone had sent this code earlier and I used odbc for the username and no password and it works fine. Also if I type status it has odbc as the username. I'm working ont this for a final and I'm wondering if it is just a case of 2 different versions of php or mysql? I'm getting pretty frustrated at this point. [/code] <?php //MySQL information MODIFY IT HERE. $host = "";//Host $db_name = "";//Database $db_user = "";//Username $db_password = "";//Password //Connect to the database $dbnews = @mysql_connect("$host", "$db_user", "$db_password"); if (!$dbnews) { die(" <center>Could not connect to MySQL Server($host). " . mysql_error() . "</center> "); } //Select the database if (!@mysql_select_db("$db_name")) { die(" <center>Could not select MySQL Database($db_name) " . mysql_error () . "</center> "); } mysql_query("create table yahoo(id int, name char(10), primary key(id))", $link); ?> Try that and see how it works out. Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/#findComment-235293 Share on other sites More sharing options...
jlgray48 Posted April 22, 2007 Author Share Posted April 22, 2007 Just ran the code from above and it works fine, just can't figure out the difference. jg Link to comment https://forums.phpfreaks.com/topic/48142-unable-to-change-sql-database-with-php-script/#findComment-235306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.