Troubles with PHP code - trying to post to mySQL
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Troubles with PHP code - trying to post to mySQL
That function is used to get the last id that was inserted. If the id in that table is an auto increment then you don't supply it. Remove that line and remove the id references in your query.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Troubles with PHP code - trying to post to mySQL
Excellent, I did that. Does anyone know of the code I would need to add to get what I requested on my last post?
Re: Troubles with PHP code - trying to post to mySQL
Just checked...the form is no longer giving me errors, but at the same time, it's also not posting to my SQL Database. Any reasons this would be happening?
Code:
Code:
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$username = $_POST['username'];
$password = $_POST['pwd'];
$hear = $_POST['hear'];
$empbus = $_POST['empbus'];
$favtravel = $_POST['favtravel'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$resourceId = mysql_connect('localhost','root','probiz123');
mysql_select_db('blueplanet',$resourceId);
$query = "INSERT INTO users (`username`,`password`,`address1`,`address2`,`city`,`state`,`zip`,`email`,`hear`,`empbus`,`favtravel`,`phone`) VALUES ('$username','$password','$address1','$address2','$city','$state','$zip','$email','$hear','$empbus','$favtravel','$phone')";
mysql_query($query);
mysql_close();
?>- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Troubles with PHP code - trying to post to mySQL
Code: Select all
$result = mysql_query($query) or die(mysql_error());mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Troubles with PHP code - trying to post to mySQL
I did this, but it's still simply not posting to MySQL, and I am getting the following error:
"Out of range value for column 'phone' at row 1"
What would be the cause of this?
"Out of range value for column 'phone' at row 1"
What would be the cause of this?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Troubles with PHP code - trying to post to mySQL
The data type and/or the length of the `phone` column is not big enough to hold what you are trying to insert.etech wrote:I did this, but it's still simply not posting to MySQL, and I am getting the following error:
"Out of range value for column 'phone' at row 1"
What would be the cause of this?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Troubles with PHP code - trying to post to mySQL
I've got everything working now! But one more question, how do I have the form do a check against the database for similar usernames and email addresses?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Troubles with PHP code - trying to post to mySQL
Do a select query for the username OR email. If it returns rows then they already exist and you can display an error or something.etech wrote:I've got everything working now! But one more question, how do I have the form do a check against the database for similar usernames and email addresses?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.