PHP Help
#1

Hey guys
didnt really know where to ask about this imma just post it here..
Anyways the problem is i keep getting this errors when i trying to enter my UCP
Код:
Parse error: syntax error, unexpected '$_Connection' (T_VARIABLE) in C:\xampp\htdocs\ucpp\connection.php on line 34
Here is my code
Код:
$_Connection = mysql_connect($_Host, $_User, $_Pass);
i also tried to use this
Код:
$_Connection = mysql_connect($_Host, $_User, $_Pass) or die('Could not connect to $_Host with $_User using password $_Pass');
still not working
Reply
#2

Might help.
http://php.net/manual/en/function.mysql-connect.php
Reply
#3

still not working
Reply
#4

Don't use _ character before a variable, it's already used by some other global vars, like for example $_SERVER.
Just use $connection, $host or even beter: $mysql_connection, $mysql_host, etc.

Also a tip, use mysqli instead of those mysql functions.
Reply
#5

What's the different with MySQLi and MySQL?
Reply
#6

Quote:
Originally Posted by TonyNames
Посмотреть сообщение
What's the different with MySQLi and MySQL?
You get alot more handy functions + you can use a class/object now for handling mysql related stuff.

http://en.wikipedia.org/wiki/MySQLi
Reply
#7

Awesome but when i search on Table how do i connect it with my table? I searched it around that PHP instructions
Reply
#8

Why still using MySQL start using MySQLi. They are much better!
Reply
#9

Ye i guess so. Anyways.. I changed my codes to this

Код:
<?php
$mysqli = new mysqli("localhost", "root", "password", "rprp");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo $mysqli->host_info . "\n";

$mysqli = new mysqli("127.0.0.1", "root", "password", "rprp", 3306);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}

echo $mysqli->host_info . "\n";



//conection: 
$link = mysqli_connect("localhost","root","password","rprp") or die("Error " . mysqli_error($link)); 

//consultation: 

$query = "SELECT name FROM users" or die("Error in the consult.." . mysqli_error($link)); 

//execute the query. 

$result = mysqli_query($link, $query); 

//display information: 

while($row = mysqli_fetch_array($result)) { 
  echo $row["name"] . "<br>"; 
} 
?>
And when i logging into my UCP

gives me those info
Код:
localhost via TCP/IP 127.0.0.1 via TCP/IP Tony_Turado
Tony_Turado1
Tony_Test1
Test_Turado
Test_Turado1
Query was empty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)