Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2007, 01:51 PM
Authorized User
 
Join Date: Aug 2006
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL help required

Hi guys

Im a beginner with SQL so forgive me for being stupid. Im trying to insert simple data into a database table, it doesnt seem to work. I am using phpMyAdmin to check the contents of the table but it never seems to include the information sent to it from my website.

The code is as follows:

$dbname= 'database1';
$dbcnx = mysql_connect('111.111.111.111', 'username', 'password');
or die("Connection Failure to Database");
mysql_select_db($dbname, $dbcnx) or die ($dbname . " Database not found. ");
$sql ="INSERT INTO `test` ( `id` , `name` , `answer1` ) VALUES ( NULL , $user , $q1);";
mysql_db_query($dbname, $sql) or die("Failed Query of " . $sql);

Your help would be greatly appreciated.
:D
Cheers in advance

 
Old January 10th, 2007, 02:15 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

Hi,
What is the error you are getting, try with this code,

$dbcnx= mysql_connect('111.111.111.111', 'username', 'password')OR die(mysql_error());
mysql_select_db("database1",$dbcnx)or die("did not select database");
$sql="insert into test(name,answer1) values('$user','$q1')";
mysql_query($sql);

i think in your code following line only some errors
$sql ="INSERT INTO `test` ( `id` , `name` , `answer1` ) VALUES ( NULL , $user , $q1);";

surendran
(Anything is Possible)
http://ssuren.spaces.msn.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL XML Explicit (Output file required) Neal SQL Server 2005 0 August 4th, 2008 03:04 AM
How to write T-SQL to retrieve the required Output anilkumar.dwivedi SQL Language 3 June 26th, 2008 12:37 AM
Help required zaeem SQL Server 2000 2 May 28th, 2008 12:48 AM
help required in C# and SQL server anuMScIT C# 2005 7 December 20th, 2006 07:33 AM
Help required with VB SQL Server 7.0 Book.. danfeather SQL Server 2000 1 September 29th, 2005 08:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.