NeonSteamPunk Posted October 23, 2019 Share Posted October 23, 2019 (edited) 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 October 23, 2019 by NeonSteamPunk Link to comment Share on other sites More sharing options...
Scaler Rexen Posted October 23, 2019 Share Posted October 23, 2019 (edited) 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 October 24, 2019 by Scaler Rexen Link to comment Share on other sites More sharing options...
NeonSteamPunk Posted October 24, 2019 Author Share Posted October 24, 2019 Figure it out while ($result_list = mysqli_fetch_array($result, MYSQLI_ASSOC)) echo ("".$result_list["SC"].",".$result_list["PC"].",".$result_list["CC"]); took me all day of reading and trial and error but I finally got it. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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