Stuck for hours: mysql_select error
Posted: Fri Jul 22, 2005 3:28 pm
Guys, I have been stuck working on this for hours. I read a lot of forums before coming on here and I still can't figure out what is wrong. I am a php/mysql noob. I just started learning this and I am making this software for my aunt.
First I have a simple form that is post submitted to this page called storecust.php, which handles storing the data into the mysql data. I echoed all the data and it works. I even tried the query command in mysql command prompt and it works but it doesn't work here. I described the fiels in the customers table.
here is the error i am getting:
INSERT INTO customers (last, first, address, city, state, zip, phone, email) VALUES ('Azurin', 'Miguel', '1234 Bamboo St', 'Austin', 'TX', 78749, '5127654564', 'miguelazurin@hotmail.com')
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\projects\dryclean\storecust.php on line 14
JCART | Please use
First I have a simple form that is post submitted to this page called storecust.php, which handles storing the data into the mysql data. I echoed all the data and it works. I even tried the query command in mysql command prompt and it works but it doesn't work here. I described the fiels in the customers table.
here is the error i am getting:
INSERT INTO customers (last, first, address, city, state, zip, phone, email) VALUES ('Azurin', 'Miguel', '1234 Bamboo St', 'Austin', 'TX', 78749, '5127654564', 'miguelazurin@hotmail.com')
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\AppServ\www\projects\dryclean\storecust.php on line 14
mysql> describe customers;
+-------------+-----------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-----------+------+-----+-------------------+----------------+
| cust_ref | int(11) | | PRI | NULL | auto_increment |
| last | text | | | | |
| first | text | | | | |
| address | text | | | | |
| phone | text | | | | |
| city | text | | | | |
| state | text | | | | |
| zip | int(11) | | | 0 | |
| date_joined | timestamp | YES | | CURRENT_TIMESTAMP | |
| no_visits | int(11) | | | 0 | |
| email | tinytext | YES | | NULL | |
+-------------+-----------+------+-----+-------------------+----------------+
11 rows in set (0.00 sec)
Code: Select all
<?php
include('connectdb.php');
connect_database();
$query = "INSERT INTO customers
(last, first, address, city, state, zip, phone, email) VALUES
('$_POST[newlast]', '$_POST[newfirst]', '$_POST[newaddress]',
'$_POST[newcity]', '$_POST[newstate]', $_POST[newzip],
'$_POST[newphone]', '$_POST[newemail]')";
echo "$query";
$test = mysql_query($query, $conn);
?>Code: Select all
tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]