Posts: 497
Threads: 68
Joined: Jul 2013
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
Posts: 354
Threads: 16
Joined: Jun 2014
Posts: 497
Threads: 68
Joined: Jul 2013
Posts: 508
Threads: 9
Joined: Dec 2010
Reputation:
0
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.
Posts: 497
Threads: 68
Joined: Jul 2013
What's the different with MySQLi and MySQL?
Posts: 497
Threads: 68
Joined: Jul 2013
Awesome but when i search on Table how do i connect it with my table? I searched it around that PHP instructions
Guest4390857394857
Unregistered
Why still using MySQL start using MySQLi. They are much better!
Posts: 497
Threads: 68
Joined: Jul 2013
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