I'm a noob, and I need help

Don’t really know how to explain this, but I sorta need a php script for a project urgently. Unfortunatly, I don’t know php! (I know a bit, but a hardly any). What I am asking is for someone to create a simpe php script for me. What it needs to do: Save url variables to a mysql database. The varible names are: serverver, pluginver and port. Port will be a number such as 25572, serverver will be a number like 9384 and pluginver will be a number like 100. (it must save the ip that the request came from aswell). I also need a seperate script that displays this data in the form of html. (it also must when displaying the data, skip duplicate rows)

Thanks in advance,
elo

I do not think some one will make you a script they might but I doubt it.
Maybe if you put a little effort in to it and try to do what you want then come back when you have something.
This is not a free we will code for free site.

This is a site that will help you with your php problems I understand you know very little but a little is enough to get you started.

Once you have some sort of code then we can help you get the ball rolling so you can figure the script out yourself.

Hope that helps you.

it’s for a free program please help

Elo,

This forum is for individuals to get help with their code. It is not a place to get your coding done for you. I would suggest you try and write the script yourself and then ask us for help with it. We will be more than willing to help you.

If you need some help getting started I suggest you search on how to get someone’s ip address using PHP and then look up storing data in mysql using php. Then getting information from a URL using PHP and so on. This script does not sound hard to write but it is not something that is just magically going to appear out of thin air for you.

-Andrew

please

Seriously?! your going to have to do some work here show some effort I am not going to do it for you for free (and I am fairly sure no one else will). I charge upwards of $50 an hour to do this work. I am willing however to help individuals who are struggling. So start struggling and then ask for help. You already know you need two php files so create them. You already know you need a mysql database access so figure out. You already know you need to get variables from a URL so figure that out.

Or pay upfront to my paypal account I will write it for you.

ok then i’ve made the database how do I get the varibles from the url?

Look up $_GET and HTML Forms

why do I need html form?

you don’t really.

How are you doing with this script? Do you have any questions we can help with?

OK, how do I save it to sql?

I am assuming that you mean how do you get the data into your database. Look up MySQL INSERT querys, it is a very easy command.

i dont gett it

[php] <?php

$mysql_host     = '***';
$mysql_username = '***';
$mysql_password = '***';
$mysql_database = '***';
$mysql_table    = '***';
 
$serverver = @$_GET['serverver'];
$pluginver = @$_GET['pluginver'];
$port      = @$_GET['port'];

    $db = mysql_copnnect($mysql_host, $mysql_username, $mysql_password);
if(!$db) die("Failed to connect to mysql!");
if(! mysql_select_db($mysql_database) ) die("Failed to find database!");
 
     $db = mysql_copnnect($mysql_host, $mysql_username, $mysql_password);
if(!$db) die("Failed to connect to mysql!");
if(! mysql_select_db($mysql_database) ) die("Failed to find database!");
 
 
 
$query = "INSERT INTO `".$mysql_table."` (`serverver`, `pluginver`, `port`) VALUES (".
         "'".mysql_real_escape_string($serverver)."', ".
         "'".mysql_real_escape_string($pluginver)."', ".
         ((int)$port).
         ")";
$result = mysql_query($query);
if(!$result) die("Failed to insert row!");
 
 
 
$query = "UPDATE `".$mysql_table."` SET ".
         "`serverver` = '".mysql_real_escape_string($serverver)."', ".
         "`pluginver` = '".mysql_real_escape_string($pluginver)."', ".
         "`port`      = ".((int)$port).
         " LIMIT 1";
$result = mysql_query($query);
if(!$result) die("Failed to update row!");
 
$query = "SELECT `serverver`, `pluginver`, `port` FROM `".$mysql_table."` LIMIT 1";
$result = mysql_query($query);
if(!$result) die("Failed to query database!");
$row = mysql_fetch_assoc($result);
 
echo 'serverver: '. $row['serverver'] .'<br />';
echo 'pluginver: '. $row['pluginver'] .'<br />';
echo 'port:      '. $row['port']      .'<br />';


echo 201
 
?>

[/php]

Somthing in this code isn’t working, please can you help thanks

At first glance its that last echo 201 line… remove it and see if that helps.

Also you have spelled connect with a p as in copnnect and you have that same line twice for some reason. also your insert and your update statements are using the same variable $query and your duplicating $results as well… below is my cleaned up version.

[php]<?php
$mysql_host = ‘***’;
$mysql_username = ‘***’;
$mysql_password = ‘***’;
$mysql_database = ‘***’;
$mysql_table = ‘***’;

$serverver = @$_GET[‘serverver’];
$pluginver = @$_GET[‘pluginver’];
$port = @$_GET[‘port’];

$db = mysql_copnnect($mysql_host, $mysql_username, $mysql_password);
if(!$db) die(“Failed to connect to mysql!”);
if(! mysql_select_db($mysql_database) ) die(“Failed to find database!”);

$query1 = “INSERT INTO ".$mysql_table." (serverver, pluginver, port) VALUES (”.
“’”.mysql_real_escape_string($serverver)."’, “.
“’”.mysql_real_escape_string($pluginver).”’, ".
((int)$port).
“)”;
$result1 = mysql_query($query1);
if(!$result1) die(“Failed to insert row!”);

$query2 = “UPDATE ".$mysql_table." SET “.
"serverver = '”.mysql_real_escape_string($serverver).”’, “.
"pluginver = '”.mysql_real_escape_string($pluginver)."’, ".
"port = “.((int)$port).
" LIMIT 1”;
$result2 = mysql_query($query2);
if(!$result2) die(“Failed to update row!”);

$query3 = “SELECT serverver, pluginver, port FROM ".$mysql_table." LIMIT 1”;
$result3 = mysql_query($query3);
if(!$result3) die(“Failed to query database!”);
$row = mysql_fetch_assoc($result3);

echo ‘serverver: ‘. $row[‘serverver’] .’
’;
echo ‘pluginver: ‘. $row[‘pluginver’] .’
’;
echo ‘port: ‘. $row[‘port’] .’
’;
?>[/php]

Thankyou but when I run it it doesn’t come up with any errors, it just does nothing. I also tried running it with ?serverver=100&pluginver=938&port=25565 but that didn’t work either. please help

Your Url should end something like this

.php?serverver=123&pluginver=456&port=789

Also i forgot to remove the p in the connect line so see if that fixes it. and the if line just below it has ! mysql… it should be !mysql…

Sponsor our Newsletter | Privacy Policy | Terms of Service