1
bimmer528
Need Some Help with Insert statement and custom page, custom db table
  • 2006/1/26 17:52

  • bimmer528

  • Just popping in

  • Posts: 19

  • Since: 2002/9/19


foreach($log_files as $i => $file ) {
    
ftp_get($conn_id"tempfile"$fileFTP_ASCII);
    
$fp fopen("tempfile","r");
    
$contents fread($fpfilesize("tempfile") );
    
$contents str_replace("",""$contents);
    
preg_match_all("/TOST Protect: Ident: ([^ ]*) - ([^- ]*) - ([0-9.]*)/"$contents$matches);
    echo 
"
Log File 
$i"
;
  foreach(
$matches[1] as $key => $value) {
       
$playername $matches[1][$key];
$playerip $matches[2][$key];
$playerid $matches[3][$key];
echo 
$playername;
echo 
"
"

echo 
$playerip;
echo 
"
"

echo 
$playerid;
echo 
"
"



global 
$xoopsDB;

$sql "INSERT INTO ".$xoopsDB->prefix('PlayersTOSERV');
$sql .= " ( id, Player, IP, UniqueID ) VALUES ";
$sql .= " ( '',  '$playername', '$playerip' , '$playerid')";
echo 
"SQL insert statement: " $sql "
"
;

$result $xoopsDB->query($sql) or die('SQL Error: ' mysql_error());




  }



The output in the echo statements work great as it preg_match_all each .log file and outputs an example here.

Log File 1
someplayer
someip
someuniqueid

Log File 2
someplayeragain
anotherip
anotherid


I am getting an error when trying to insert this info into the database. I used echo to see what the statement looked like and it looks good.

SQL insert statementINSERT INTO __PlayersTOSERV idPlayerIPUniqueID VALUES '''name''TACO' '209.217.83.000')
SQL Error:


The first field is id which is an auto increment in the table so were leaving that blank.

Tablename is good, no spelling or case sensitive typo's. The sql statement show's good values.

I included the mainfile.php

any answers?

Cheers,

Bimmer

2
Dave_L
Re: Need Some Help with Insert statement and custom page, custom db table
  • 2006/1/26 19:11

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Are you doing the query in response to a GET, or a POST request?

Clicking a link or browsing a URL are normally GET, and form submissions are normally POST.

If it's GET, you'd have to use $xoopsDB->queryF(), instead of $xoopsDB->query(), for a non-SELECT query such as INSERT.

Login

Who's Online

502 user(s) are online (61 user(s) are browsing Support Forums)


Members: 0


Guests: 502


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits