5 Replies - 1992 Views - Last Post: 27 July 2012 - 06:32 AM Rate Topic: -----

#1 dave_francis1982  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-July 12

cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:01 AM

wondered if anyone can help me please, i am a complete beginner and ive been following tutorials on youtube. I have installed xxamp and everything has worked okay for checking my php pages, i am now trying to insert a data base to mySQL using PHP.

here is my code:
------------------------------------------------------------------------------------------
<?php


$accounts = mysql_connect("localhost" , "****", "*********") 
or die (mysql_error());


mysql_select_db("accounts" , $accounts);

$sql = "CREATE TABLE users2
{
id int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (id),
user name varchar (20),
password varchar (20) ,
first name varchar (20),
last name varchar (20),

}
";

mysql_query($sql, $accounts);
?>
 
---------------------------------------------------------------------
I dont recieve any error messages on my browser which is normally the case if their is a syntax error and everything apperars to work (i.e it has connected to mysql) except no table is inserted when i go into phpmyadmin ? any ideas anyone ? thought maybe it might be something to do with xxamp being installed wrongly as i have the following error messages on my xxamp control pannel:

2:00:26 PM [main] You are not running with administrator rights! This will work for
2:00:26 PM [main] most application stuff but whenever you do something with services
2:00:26 PM [main] there will be a security dialogue or things will break! So think
2:00:26 PM [main] about running this application with administrator rights!
2:00:26 PM [main] XAMPP Installation Directory: "c:\program files (x86)\xampp\"
2:00:26 PM [main] WARNING: Your install directory contains spaces. This may break programs
2:00:26 PM [main] WARNING: Your install directory contains special characters. This may break programs
2:00:26 PM [main] Initializing Modules
2:00:26 PM [apache] Apache Service Detected With Wrong Path
2:00:26 PM [apache] Uninstall the service manually first
2:00:26 PM [apache] Possible problem detected!
2:00:26 PM [apache] Port 80 in use by "httpd.exe"!
2:00:26 PM [apache] Possible problem detected!
2:00:26 PM [apache] Port 443 in use by "httpd.exe"!
2:00:26 PM [mysql] MySQL Service Detected With Wrong Path
2:00:26 PM [mysql] Uninstall the service manually first
2:00:26 PM [mysql] Possible problem detected!
2:00:26 PM [mysql] Port 3306 in use by "mysqld.exe"!
2:00:26 PM [filezilla] FileZilla Service Detected With Wrong Path
2:00:26 PM [filezilla] Uninstall the service manually first

This post has been edited by JackOfAllTrades: 27 July 2012 - 06:08 AM
Reason for edit:: Added code tags


Is This A Good Question/Topic? 0
  • +

Replies To: cant insert data to mysql using php, HELP !

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9086
  • View blog
  • Posts: 34,132
  • Joined: 12-June 08

Re: cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:05 AM

First - stop using the mysql_ stuff.. use pdo.

Why are you inserting tables from your PHP? Typically you would set it up on the mysql admin side and just insert *DATA* to the tables.
Was This Post Helpful? 1
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:10 AM

2:00:26 PM [apache] Apache Service Detected With Wrong Path
2:00:26 PM [apache] Uninstall the service manually first
2:00:26 PM [apache] Possible problem detected!
2:00:26 PM [apache] Port 80 in use by "httpd.exe"!
2:00:26 PM [apache] Possible problem detected!
2:00:26 PM [apache] Port 443 in use by "httpd.exe"!
2:00:26 PM [mysql] MySQL Service Detected With Wrong Path
2:00:26 PM [mysql] Uninstall the service manually first
2:00:26 PM [mysql] Possible problem detected!
2:00:26 PM [mysql] Port 3306 in use by "mysqld.exe"!
2:00:26 PM [filezilla] FileZilla Service Detected With Wrong Path
2:00:26 PM [filezilla] Uninstall the service manually first 


Yes, it appears your installation is somehow hosed. Maybe you have two versions of XAMPP running? Or maybe some other web server, like WAMP was installed and is running?
Was This Post Helpful? 0
  • +
  • -

#4 dave_francis1982  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-July 12

Re: cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:14 AM

View Postmodi123_1, on 27 July 2012 - 06:05 AM, said:

First - stop using the mysql_ stuff.. use pdo.

Why are you inserting tables from your PHP? Typically you would set it up on the mysql admin side and just insert *DATA* to the tables.


thanks for your reply, please bear in mind i know sweet FA about programming ! ive been creating a mock website just to learn and i wanted to have a page where users could submit their info into a database that i can access so i trailed through the web and eventually found a tutorial on php and im currently stuck on creating tables and inserting data, i thought i would need to learn this in order to create the page i wanted.
Was This Post Helpful? 0
  • +
  • -

#5 dave_francis1982  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-July 12

Re: cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:25 AM

View PostJackOfAllTrades, on 27 July 2012 - 06:10 AM, said:

[code]

Yes, it appears your installation is somehow hosed. Maybe you have two versions of XAMPP running? Or maybe some other web server, like WAMP was installed and is running?


Yeah im trying to teach mysef web design/programming and ive been using different sites to learn this, so i went about it all wrong, i installed, apache, php and mysql manually. before discovering apache friends. i thought i had uninstalled everything before but obviouslly havn't so i probably do need to just wipe everything off and start again, only im not sure where i saved all the files ! :withstupid:
Was This Post Helpful? 0
  • +
  • -

#6 dave_francis1982  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-July 12

Re: cant insert data to mysql using php, HELP !

Posted 27 July 2012 - 06:32 AM

SORRY !! I MEANT :stupid:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1