PHP Help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: PHP Help (
/showthread.php?tid=538996)
PHP Help -
TonyNames - 25.09.2014
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
Re: PHP Help -
LivingLikeYouDo - 25.09.2014
Might help.
http://php.net/manual/en/function.mysql-connect.php
Re: PHP Help -
TonyNames - 25.09.2014
still not working
Re: PHP Help -
BlackBank - 25.09.2014
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.
Re: PHP Help -
TonyNames - 25.09.2014
What's the different with MySQLi and MySQL?
Re: PHP Help -
BlackBank - 25.09.2014
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
Re: PHP Help -
TonyNames - 25.09.2014
Awesome but when i search on Table how do i connect it with my table? I searched it around that PHP instructions
Re: PHP Help - Guest4390857394857 - 25.09.2014
Why still using MySQL start using MySQLi. They are much better!
Re: PHP Help -
TonyNames - 25.09.2014
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