1

I am using Ubuntu 12.10 and i have installed LAMP. While i was learning PHP i came across a topic of connecting mysql and php. This is the code i learn

<?php

$db = mysql_connect('localhost','root','dbpass') or die('Unable to connect. Check your connection ');

$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query,$db) or die(mysql_error($db));

mysql_select_db('moviesite',$db) or die(mysql_error($db));

$query2 = 'CREATE TABLE movie (movie_id integer not null, moviename varchar(255) not null, movierating integer not null)';

mysql_query($query,$db) or die(mysql_error($db));

echo "movie database succecfully created ";

?>

When i try this in my windows environment (i have dual boot windows and ubuntu) , it works fine. In windows i am using eastPHP. But in ubuntu it doesn't shows anything. I have tried to find syntax errors but its just the same given in a book. So what can be the problem ?

1 Answer 1

1

If you get a blank page in the browser, you probably have a fatal error or a server configuration issue. Assuming you use Apache, look in the Apache error logs for some clues. On Ubuntu, it would be in /var/log/apache2/error.log per default.

Sign up to request clarification or add additional context in comments.

2 Comments

It says - : "[Tue Oct 23 13:50:15 2012] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function mysql_connect() in /var/www/dbcon2.php on line 8 " But isn't my function correct ?
In that case, you probably need to install the mysql extension. Try with sudo apt-get install php5-mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.