Astronaut Farmer, the
Just another eblog.lt – nemokamas BLOGas weblog

The Echo

February 4th 2010 in Uncategorized

The Echo
The Echo (2008)

IMDB rating: 6.70

Plot: An ex-con moves into an old apartment building, where he encounters a domestic problem involving a police officer, his wife, and their daughter. When he tries to intervene, however, a mysterious curse entraps him.

buy and download The Echo

Directors: Laranas Yam

Actors: Alianak Hrant,Bradford Jesse,Carmody Brendan,Durand Kevin,Hinz Marvin,Lee Paul Sun-Hyung,Leon Carlos,Morse Robert,Santino George,Stevens Courtenay J.,Vince Pruitt Taylor,Drama,Horror,Mystery,Thriller,

Can not connect to MYSQL database through PHP.?
The following php program is not connecting with mysql.It display the word welcome and the variable in echo but the connection is not getting established.Solve this.

<?php
$u=$_POST[username];
$p=$_POST[password];
echo "Welcome ,$u";

$conn = mysql_connect ("localhost","root","password");

$db = mysql_select_db("empdb", $conn) or die("Couldn’t select database.");

$sql = "insert into employee (username) values("$u")";

$sql_result = mysql_query($sql,$conn) or die("Couldn’t execute query.");

?>


change $sql = "insert into employee (username) values("$u")";

to $sql = "insert into employee (username) values("’.$u.’)";

Or better yet

$sql = sprintf("insert into employee (username) values(%s)",
mysql_real_escape_string($u));
Jason W-S | Feb 01, 2010


<?php
$u=$_POST[username];
$p=$_POST[password];
echo "Welcome ,$u";

$conn = mysql_connect ("localhost","root","password");

mysql_select_db("empdb", $conn) or die("Couldn’t select database.");

$sql = "insert into employee (username) values("’".$u."’")";

mysql_query($sql) or die("Couldn’t execute query.");

?>
kimcord_99 | Feb 01, 2010


Okay, my simple suggestion is to connect to mysql using the command line, with that username and password with that database

mysql -D empdb -u root -p

If you can’t do that, then clearly you have a problem with mysql itself.
You’ll need to install mysql of course, have a schema called empdb,
and a user called root (almost always there, but bad practice to use this account daily)
with the correct password

also, as pointed out prior, the $sql query itself looks like a syntax error.
Pete S | Feb 01, 2010


Jason and Pete offer some good suggestion. But it would help if we had a better understanding of your problem. You state that the code displays the output of your echo statement, but you do not tell us if any errors are getting displayed (this would be helpful to know if there are any). Then you state a connection is not getting made.

If it is true that the connection is not made, then the point where your code fails first is on the mysql_connect statement. In order to verify this, you should modify your connect statement to handle the connection error. So the statement should be written like so:

$conn = mysql_connect ("localhost","root","password") or die("Could not connect to db.");

If you see the "Could not connect to db" message after modifying the connect statement and executing your code, then you definitely are not connecting to MySQL. Assuming the user credentials are correct for a localhost connection, the first thing I would check is to see if PHP is configured to talk to MySQL. You can do this by creating a page that contains the statement:

<?php
phpinfo();
?>

Executing the above statement will display your PHP configuration information. Search for a section titled mysql. If you can’t find this section, then PHP does not have the necessary extension to talk to MySQL. So you will have to locate your php.ini file (usually found in the php directory) and add the following to the end of the file:

[PHP_MYSQL]
extension=php_mysql.dll

This assumes PHP is installed on a Windows machine, that the extension_dir is set, and php_mysql.dll resides in the extension directory. Once you have made the changes you must restart your web server for the changes to take affect (just restart your computer if you don’t know how to restart the web server).

The missing extension is a common mistake for new users who have installed PHP and MySQL for the first time. If none of the suggestions work, contact me and I will try to help you get your code working.
rbjolly | Feb 01, 2010




required



required - won't be displayed


Your Comment:

Wrestling

Wrestling (2008)
IMDB rating: 4.30
Plot: In the summer between high school and college, wrestling tells the story of a group of kids forced to face the challenges of growing up and moving on. Somewhere between Larry Clark’s dark, disturbing Kids and the glossy Can’t Hardly Wait, wrestling exposes the complexities embracing suburban teen life.

Directors: O’Keefe Jeremy
[...]

WrestlingPrevious Entry

Game, The

Game, The (1997)
IMDB rating: 7.60
Plot: Nicholas Van Orton is a very wealthy San Francisco banker, but he is an absolute loner, even spending his birthday alone. In the year of his 48th birthday (the age his father committed suicide) his brother Conrad, who has gone long ago and surrendered to addictions of all kinds, suddenly [...]

Game, TheNext Entry

Recent Comments
  • No comments
Categories