Go Back   Runner > Coding Corner > Php

Php PHP is a general-purpose scripting language especially suited to web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-31-2020, 01:49 PM
Runner's Avatar
Runner Runner is online now
Administrator
 
Join Date: Nov 2020
Location: Moose Jaw
Posts: 221
Send a message via Skype™ to Runner
Default Working on php script to write a text to certain are in My Sql Data Base

i am trying to get my script to read User id Domain than write to that user id domain in my sql data base i can get my code to execute but not write to proper domain or user
Any Ideas ?



Code:
  <?php
    
    if(isset($_GET['names']))
    {
        $name=$_GET['names'];
        $c=mysql_connect("xxxx","xxxx","xxxx");
        mysql_select_db("xxxx");
        $ins=mysql_query("INSERT INTO `x_vhosts`  
                          (`vh_php_tx`)
                          VALUES ('$name')",$c) or die(mysql_error());
                          
        if($ins)
        {
                    echo "<br>".$name."inserted";
        }

    }
?>
Reply With Quote
  #2  
Old 12-31-2020, 01:50 PM
Runner's Avatar
Runner Runner is online now
Administrator
 
Join Date: Nov 2020
Location: Moose Jaw
Posts: 221
Send a message via Skype™ to Runner
Default Using form to do the submit

Using form to do the submit
Reply With Quote
  #3  
Old 01-16-2021, 02:04 PM
Runner's Avatar
Runner Runner is online now
Administrator
 
Join Date: Nov 2020
Location: Moose Jaw
Posts: 221
Send a message via Skype™ to Runner
Default

This reads my array and post proper output to columns



Code:
<?php
   
    if(isset($_GET['names']))
    {
               $name=$_GET['names'];
               $id=$_GET['id'];

$servername = "localhost";
$username = "xxxx";
$password = "xxxxxxx";
$dbname = "xxxxxxx";

try {
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  $sql = "UPDATE x_vhosts SET vh_php_tx='$name' WHERE vh_id_pk=$id";

  // Prepare statement
  $stmt = $conn->prepare($sql);

  // execute the query
  $stmt->execute();

  // echo a message to say the UPDATE succeeded
  echo $stmt->rowCount() . "";
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}
 if($name)
        {
                       echo "<br>".$name."";
        }
           return true;
    }
  
$conn = null;

?>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:05 PM.


Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright ©2020 - 2021, Runner
Ad Management plugin by RedTyger