PHP4 UPDATE

This is PHP4 Code! $result = @mysql_query("UPDATE some_table SET image_filename = '', something_else = 4 WHERE indexer = $destid "); Example Update From An HTML Form <!——————————–> <!——————————–> <!—– ADD TO DATABASE FORM —–> <!——————————–> <!——————————–> <h2>Add To Database</h2> <?php if ( (isset($_POST[‘action’])) && ($_POST[‘action’] == "add_to_database") ) { $field1 = @mysql_real_escape_string($_POST['field1']); $field2 = @mysql_real_escape_string($_POST['field2']); […]

Read More

PHP4 INSERT

This is PHP4 Code! $result = @mysql_query("INSERT INTO text_messages ( some_id, email_address ) VALUES ( $some_id, '$email' )"); DateTime Now Now(),   Get Auto ID Of New Record $sql = "INSERT INTO some_table (list_name, user_id) VALUES ('$list_name', $user_id)"; @mysql_query($sql); $my_variable = mysql_insert_id(); The mysqli_insert_id() function returns the ID generated by a query on a table […]

Read More

Creating a S3 bucket

Bucket name This name will be part of the url of objects stored in the bucket, e.g. https://s3-eu-west-1.amazonaws.com/mybucketname/myfile.jpg Public read access You can set this to not public and still mark objects in the bucket as publicly readable as they are stored. Users Just the main AWS account holder / you is fine. Creating a user […]

Read More

PHP4 .SELECT General

This is PHP4 Code! w3schools.com SQL Guide Simple Get A Result $query = @mysql_query("SELECT user_name, password FROM member_profile WHERE email_address = '$user_name_login' AND password = '$password_login'"); $result = @mysql_fetch_array($query); $result_display_username = $result[‘user_name’]; $result_username = strtolower($result[‘user_name’]); Does Record Exist $query = @mysql_query("SELECT * FROM my_table WHERE some_field = $some_field AND some_field2 = $some_field2 AND some_field3 = […]

Read More

PHP4 DELETE

$result = @mysql_query("DELETE FROM some_table WHERE email_address='$email'"); Delete old records by date $result = @mysql_query("DELETE FROM messages_sent WHERE created_date < DATE_SUB(NOW(), INTERVAL 30 DAY)"); //Also: //INTERVAL 1 MONTH //INTERVAL 1 HOUR //etc Delete table Truncate is the fastest method to delete all data in a table as the table is dropped and re-creaed. $result = […]

Read More

PHP7 updating old database code

Database connections Need updating to the method here Functions using the database connection or mysql_real_escape_string Any functions using the database connection will need “global $dblink;” as shown here mysqli_real_escape_string “mysql_real_escape_string(” all need updating to “mysqli_real_escape_string($dblink, ” as shown here mysql_query For queries which have no result output, they are just do actions then replace “@mysql_query(” with “mysqli_query($dblink, […]

Read More