<html>
<body>
<?php
$username = 'root';
$password = '';
$hostname = 'localhost'; 
//connection to the database
$con = mysql_connect($hostname, $username, $password,'contactmanager') 
 or die('Unable to connect to MySQL');
echo 'Connected to MySQL<br>'.'<p>';
mysql_query($con,'INSERT INTO Personalinformation(Name, YearOfBirth, Email,Location,PhoneNumber)
VALUES(Peter,2008-03-05,peter@hotmail.com,kasland,0269015748)');
mysql_close($con);
?>
</body>
</html>

i keep on getting this error message.can the forum assit me pls.
Warning: mysql_query() expects parameter 1 to be string, resource given in C:\xampp\htdocs\www\getinside.php on line 12

You are missing mysql_select_db('dbname')
and in insert query string values should be in double inverted comma ""
$con not required in mysql_query
mysql_connect should not have dbname

so where am putting $con.can elaborate further.i inserted mysql_select_db('dbname').now i dontget any error but it does not g intothe sql server thou it displays connected to mysql.

remove $con from mysql_query and add $con to mysql_select_db('your-db-name',$con).

Change this

mysql_query($con,'INSERT INTO Personalinformation(Name, YearOfBirth, Email,Location,PhoneNumber)
VALUES(Peter,2008-03-05,peter@hotmail.com,kasland,0269015748)');

to

mysql_query('INSERT INTO Personalinformation(Name, YearOfBirth, Email,Location,PhoneNumber)
VALUES("Peter","2008-03-05","peter@hotmail.com","kasland",0269015748)');

If this doesn't work then paste your updated code

<html>
<body>
<?php
$username = 'root';
$password = '';
$hostname = 'localhost';
//connection to the database
$con = mysql_connect($hostname, $username, $password)
or die('Unable to connect to MySQL');
echo 'Connected to MySQL<br>'.'<p>';
mysql_select_db("contactmanager",$con);
mysql_query('INSERT INTO Personalinformation(Name, YearOfBirth, Email,Location,PhoneNumber);
VALUES("Peter","2008-03-05","peter@hotmail.com","kasland",0269015748)');
mysql_close($con);
?>
</body>
</html>.
did not work.could it be some configuration from mysql phpadmin?

mysql_query('INSERT INTO Personalinformation(Name, YearOfBirth, Email,Location,PhoneNumber);
VALUES("Peter","2008-03-05","peter@hotmail.com","kasland",0269015748)');

above code have no space after Personalinformation(Name...) and there's ; at PhoneNumber); which shuoldn't be there.

Replace by this code

mysql_query('INSERT INTO Personalinformation (Name, YearOfBirth, Email,Location,PhoneNumber)
VALUES("Peter","2008-03-05","peter@hotmail.com","kasland",0269015748)');

thank u very much.it worked for me now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.