Simple Php Connect

Kenbob

New Member
Messages
18
Reaction score
0
Points
0
took this straight from
http://www.w3schools.com/php/php_mysql_connect.asp

In the following example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails:

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}// some code

This is bogus code --- when you run it it says
Parse error: syntax error, unexpected T_STRING in /home/kenbob/public_html/form/db_create_table.php on line 9

It does not DIE and print off the script code "could not connect"

Does this site use a different PHP verison?
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Look again closely and you'll see you misquoted your mysql_connect statement.
 

Kenbob

New Member
Messages
18
Reaction score
0
Points
0
I had the other quote in there ====== anyone help!
Edit:
took this straight from
http://www.w3schools.com/php/php_mysql_connect.asp

In the following example we store the connection in a variable ($con) for later use in the script. The "die" part will be executed if the connection fails:

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}// some code

This is bogus code --- when you run it it says
Parse error: syntax error, unexpected T_STRING in /home/kenbob/public_html/form/db_create_table.php on line 9

It does not DIE and print off the script code "could not connect"

Does this site use a different PHP verison?
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Nothing is wrong with it, I use similar code on almost all my sites.
 
Top