MySQL

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

MySQL

Postby sharavi79 » 20. January 2013 09:59

Hi All,

I am new to MYSQL.
I cannot connect the database with the below code, please help me.

<?php
$dbc=mysql_connect('localhost', 'root', ' ')
or die ('error connecting to MYSQL server');
$query="INSERT INTO qcerror(book_name, Op_name, Page, Errors, email, dispatch)".
"VALUES('srisha', 'sai', '15', '3', 'sharavi@gmail.com', 'No')";
$result=mysql_query($dbc, $query)
or die('error querying database');
mysql_close($dbc);
?>

Thanks,
Ravi
sharavi79
 
Posts: 7
Joined: 23. December 2012 05:02
Operating System: Windows 7

Re: MySQL

Postby Altrea » 20. January 2013 13:17

Hi Ravi,

You should output much more errors with the function mysql_error().
You can use it after many functions, for example in your die() statements after mysql_connect() and mysql_query().
That way you should get a message, that you don't have selected a specific database.

best wishes,
Altrea

P.S.: If you want to post code, please cover it with the specific BBCode the Forum provide:
Code: Select all
[code]
<?php
    //your php code here
?>
[/code]

P.P.S.: mysql functions are getting marked as deprecated in PHP 5.5 and will be replaced in PHP 5.6 or PHP 6. It is recommend to use the chance to be at the beginning and learn connecting to mysql databases with the up to date classes mysqli or PDO
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8294
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: MySQL

Postby sharavi79 » 22. January 2013 05:40

Thnks Altrea
sharavi79
 
Posts: 7
Joined: 23. December 2012 05:02
Operating System: Windows 7


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 1 guest