Jump to content

PHP help


NeonSteamPunk
 Share

You are about to reply to a thread that has been inactive for 1646 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

trying to finish a system that updates data to a db, I been using a subscription php script I found on market place that I stumble my way thew to make it do what I want.

Far from a PHP master im stumped and could use any help if it;s out there.

here my code

<?php
if(!empty($_POST))
 {
  
    $userKey = $_POST['uid'];
    
  
    $name = $_POST['name'];
    
  
    $SC = $_POST['SC'];

  
    $PC = $_POST['PC'];   

    $CC = $_POST['CC'];
        
 
    $query = "SELECT * FROM tablename WHERE uid = '$userKey'";
    $result = mysqli_query($connection, $query);
    
 
    $row_count = mysqli_num_rows($result);
    

    if(!$row_count)
    {
         
       
        $sql = "INSERT INTO HUD (name, uid, SC, PC, CC) VALUES ('$name','$userKey', '$SC', '$PC','$CC')";
        $result = mysqli_query($connection, $sql);
        if($result)
        {
        
           echo "";
        }
        else
        {
                // Tell the user that there was an issue.
               
                echo "Sorry, there seems to be an issue in getting you set up!\n";
        }
    }
    else
    {
        // this is my problem below
        $query = "UPDATE `dbname`.`tablename` SET SC = '$SC' ,PC = '$PC' , CC = '$CC'            
                     WHERE uid = '$userKey'";                    
               $result = mysqli_query($connection, $query);

        echo "$SC,$PC,$CC";
    }
        

 


 I don't want it to update the table, I want  the script to echo the data SC,PC,CC from the row the uid I POST .

if any one out there can help I really need it.

Edited by NeonSteamPunk
Link to comment
Share on other sites

If you don't want it to update delete everything in the else except for

echo $SC . $PC . $CC;

You don't need to put quotes around the variables and to concatenate you use the period . vs doing + like in LSL

That should resolve that issue - if it still does not work I woul recommend post what the error file. It'll direct you to the exact line that is throwing the error. Also you should look into prepared statements as somebody could destroy your database without any data validation.

Edited by Scaler Rexen
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1646 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...