0
<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>
3
Contributors
8
Replies
40
Views
4 Years
Discussion Span
Last Post by SirMahlon
0

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

0

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

0

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.

0

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

Edited by code_rum

0

<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?

0
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)');

Edited by code_rum

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.