|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
#1 |
|
Member (6 bit)
Join Date: May 2003
Location: Leeds, West Yorkshire, UK
Posts: 56
|
Hi All,
having major problems with the following code. The code wont insert the info into the database however I know it connecting to the database because it displays how many rows are in the database and I can enter data using PHPMyAdmin... print ("'$ProdID', '$Type', '$Cat', '$Name', '$ProdDesc', '$Temp', '$Size', '$Price', '$Stock'"); /* Start of PHP3 Script */ /* Data of SQL-server */ $server= "xxxxxx"; /* Address of 1&1 database server */ $user= "xxxxxx"; /* FTP-username */ $password= "xxxxxx"; /* FTP-Password */ $database= "xxxxxx"; /* name of database */ $table= "ORCProducts"; /* Name of table, you can select that */ /* Accessing SQL-Server and querying table */ $Link = MYSQL_CONNECT($server, $user, $password) or die ( " Server unreachable");MYSQL_SELECT_DB($database) or die ( " Database non existent");MYSQL_QUERY( "INSERT INTO $table VALUES('$ProdID', '$Type', '$Cat', '$Name', '$ProdDesc', '$Temp', '$Size', '$Price', '$Stock')"); /* Display number of entries */ $number=MYSQL_NUMROWS(MYSQL_QUERY( "SELECT * FROM $table")); if ($number==0): echo "database empty"; elseif ($number > 0): echo "$number rows in database"; endif; /* Close SQL-Connection */ MYSQL_CLOSE(); ?> The new product has been added to the database Any ideas what might be wrong because im stumped at the mo? Thanks Adrian |
|
|
|
|
|
#2 |
|
Member (6 bit)
Join Date: May 2003
Location: Leeds, West Yorkshire, UK
Posts: 56
|
Will try and enter it right this time. sorry...
PHP Code:
|
|
|
|
|
|
#3 |
|
Staff
Premium Member
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
|
Unless you are accessing the MySQL server from a different domain than the one that it is on, $server should be localhost. If you are accessing it from another domain, make sure that your host has added the domain that you are coming from to the users table in MySQL.
|
|
|
|
|
|
#4 |
|
Member (6 bit)
Join Date: May 2003
Location: Leeds, West Yorkshire, UK
Posts: 56
|
Thanks,
Worked out what the problem was. turned out to be just 2 more fields that needed data and becasue they were missed off the INSERT it wouldnt accept any. Adrian |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|