bigmac90
-
Posts
2 -
Joined
-
Last visited
Posts posted by bigmac90
-
-
Hi all
I've got a slight problem adding some XML data to a MySQL database. My code looks like:
// Load XML file$xml = simplexml_load_file('products.xml') or die ("Could not load XML file");// Database variables$host = "localhost";$username = "user_name";$password = "pass_word";$dbname = "database_name";// Foreach piece of XML data - send to MySQL database and put into the xmlFeed_db databaseforeach ($xml->product as $data) {// MySQL connect to database$con = mysql_connect("$host", "$username", "$password") or die ("Unable to connect to database");$select_db = mysql_select_db($dbname) or die ("Unable to select database");// Put all data into numerous variables$id = $data->id;$man = $data->manufacturers;$des = $data->description;$price = $data->price;$sku = $data->sku;$category = $data->category;$subcategory = $data->subcategory;// SQL statement$query = "INSERT INTO tablename VALUES ('$id','$man','$des','$price','$sku','$category','$subcategory')";// Execute SQL statementmysql_query($query) or die ("Insertion Error: " . mysql_error());// Close MySQLmysql_close();When I run this script it only stores 249 rows out of 2000 and then it shows an error stating:"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's)', '117.08','CAB-OCTAL-ASYNC=','Networking','Networking Cables')' at line 1"Does anyone know why this error message is showing? I've looked at my syntax but I can't see a problem. Maybe a fresh pair of eyes can help.Thanks
Cannot connect to SQL Server on local machine using PHP
in Microsoft SQL - MSSQL
Posted
I wonder if anyone can help me. I'm creating an application in PHP and am using a SQL server database on my local computer to develop the application. The only problem is I cannot connect to the database. My code looks like
to connect to the database. However, everytime I run the code I keep getting a 18456 error code. Does anybody know what my problem is and if so, what is the solution???