AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   is there anyone skilled in php (https://forums.alliedmods.net/showthread.php?t=339005)

Alahmoh 08-09-2022 07:37

is there anyone skilled in php
 
anyone is skilled in php?
i want him to make a simple index.php file that makes the other plugin read from it the menus.

bigdaddy424 08-09-2022 18:24

Re: is there anyone skilled in php
 
Do you want to read <tr> inside <table> ?

wilian159 08-09-2022 20:53

Re: is there anyone skilled in php
 
Quote:

Originally Posted by Alahmoh (Post 2785968)
anyone is skilled in php?
i want him to make a simple index.php file that makes the other plugin read from it the menus.

explain more

fysiks 08-09-2022 23:08

Re: is there anyone skilled in php
 
How is this related to plugins? If it's not then you'll want to search online for PHP info.

MrPickles 08-10-2022 01:48

Re: is there anyone skilled in php
 
Quote:

Originally Posted by fysiks (Post 2786056)
How is this related to plugins? If it's not then you'll want to search online for PHP info.

i think that he need learn php first, cause he wants to communicate a PLUGIN with a PHP

Alahmoh 08-10-2022 11:03

Re: is there anyone skilled in php
 
so im using a plugin to store player played time in MySql server which is currently working,
the only problem i have is with the php files not being able to read the data from MySql server.

here is MySql info:
SQL_HOST = 127.0.0.1
SQL_PORT = 8080
SQL_USER = lmao
SQL_PASS = husam123Hane
SQL_DB = bym_cod

the data of players time played are stored in mysql without any problem
i just need the php to fetch there data and store them in a MOTD.

here is the php files i am using(not working):-
https://pastebin.com/2a0R2HV4

// btw sorry for being late in answers its because I am busy looking for universities to study in because I just finished high school. \\

fysiks 08-11-2022 01:10

Re: is there anyone skilled in php
 
FYI, you have an SQL Injection security vulnerability in your code. You need to use prepared queries.

While I commend you for posting your code, you should also have the list or errors that you get when you run your code.

I noticed a couple things in your code after looking at it briefly. 1) You have a SQL Injection vulnerability and you should switch to prepared queries to resolve it. 2) You're hard coding your database connection info in the PDO constructor instead of using your $GLOBALS variable. This is how I do it:

PHP Code:

new PDO(sprintf("mysql:host=%s;dbname=%s;charset=utf8"$dbconfig['host'], $dbconfig['dbname']), $dbconfig['user'], $dbconfig['pass']); 

P.S. If the data in your $GLOBALS variable is your real data, you need to change them. If you write your PDO constructor arguments like I've shown, you'll never need to post the $GLOBALS variable when asking for help.

Some other tips: get the actual query string and test it in your database using something like phpMyAdmin to make sure that it works. It looks like it should work but you should verify the actual string that gets passed (i.e. your $_GET parameter might not be what you're expecting).

Alahmoh 08-11-2022 06:20

Re: is there anyone skilled in php
 
Quote:

Originally Posted by fysiks (Post 2786169)
FYI, you have an SQL Injection security vulnerability in your code. You need to use prepared queries.

While I commend you for posting your code, you should also have the list or errors that you get when you run your code.

I noticed a couple things in your code after looking at it briefly. 1) You have a SQL Injection vulnerability and you should switch to prepared queries to resolve it. 2) You're hard coding your database connection info in the PDO constructor instead of using your $GLOBALS variable. This is how I do it:

PHP Code:

new PDO(sprintf("mysql:host=%s;dbname=%s;charset=utf8"$dbconfig['host'], $dbconfig['dbname']), $dbconfig['user'], $dbconfig['pass']); 

P.S. If the data in your $GLOBALS variable is your real data, you need to change them. If you write your PDO constructor arguments like I've shown, you'll never need to post the $GLOBALS variable when asking for help.

Some other tips: get the actual query string and test it in your database using something like phpMyAdmin to make sure that it works. It looks like it should work but you should verify the actual string that gets passed (i.e. your $_GET parameter might not be what you're expecting).

my bad the error im getting is :[Error] Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`Id' at line 1

fysiks 08-11-2022 23:07

Re: is there anyone skilled in php
 
I would recommend using something like phpMyAdmin to build a query for you and then you can replace the search criteria with your variable (hopefully via prepared queries).

Alahmoh 08-12-2022 05:06

Re: is there anyone skilled in php
 
Quote:

Originally Posted by fysiks (Post 2786249)
I would recommend using something like phpMyAdmin to build a query for you and then you can replace the search criteria with your variable (hopefully via prepared queries).

hmmmm what is that supposed to mean???


All times are GMT -4. The time now is 06:24.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.