PHP - Financial Transactions Of A Php Project
Hi all,
I have some financial transactions to perform in my system like cash deposits, withdrawals etc.I have built my system using PHP and MySQL. Can someone explain me how can i use rollback operations if something failure occurs? Heshan, Similar TutorialsThis topic has been moved to PHP Math Help. http://www.phpfreaks.com/forums/index.php?topic=310665.0 Hello all. I have never used transactions before and I'm building a website right now and trying to use one. Now, the question here is do I use it right? I have 3 tables, posts, users and users_to_posts which holds all ids (id, user_id, post_id). Now as I need to get the last insert id from database, I need to lock tables cause when two people post at the same time, it might get all mixed up. Now I use the lock tables statement first time. Anyway, all this story aside, the question. Do I use this block right? if(isset($_SESSION['uID'], $_SESSION['username'])) { // User try { $dbh->beginTransaction(); $stmt = $dbh->exec('LOCK TABLES `posts` WRITE, `users_to_posts` WRITE'); $insert = $dbh->prepare('INSERT INTO `posts` (`content`) VALUES (:content)'); $insert->bindParam(':content', $post, PDO::PARAM_STR, 350); $insert->execute(); $jointbl = $dbh->prepare('INSERT INTO `users_to_posts` (`user_id`, `post_id`) VALUES (:uID, :pID)'); $jointbl->bindParam(':uID', $_SESSION['uID'], PDO::PARAM_INT, 11); $jointbl->bindParam(':pID', $dbh->lastInsertId(), PDO::PARAM_INT, 11); $jointbl->execute(); $unlock = $dbh->exec('UNLOCK TABLES'); $dbh->commit(); } catch(PDOException $e) { echo $e->getMessage(); } } Oh, just in case. There are no errors, it works. I just want to know if it's the right way to use it. How do you guys keep bookkeeping records of transactions?
An example is you pay for a domain name, monthly hosting or anything that you receive an email receipt for and a receipt is stored on the vendors website. Say up to 7 years.
Hello, I would like show entries on a list based on their PayPal status. If it is "pending" I don't want them to show on the list. only if their status is "complete". I just recently switched over to WPForms for WordPress. They offer only a basic PHP file that creates a list but they do not support any modifications to that file. What would I need to do to this code to produce the results I need? Please see attached files and code pasted below. Thanks for your help, Steve
<?php
$data = preg_replace("/[^a-zA-Z' ']/", "", $data); } break;
}
must we always use Transactions in php-mysql applications? i kind of made a self-discovery for a problem i was trying to solve....and found that mysql transactions would solve my problem. i wanted a set of SQLs to all be executed, or none an with undo of partial successful updates. is this transactions the standard way, and is this a must-do for realtime applications? any pros/cons/advise? thanks! Hi, I'm trying to insert data into two different tables using, but am getting an error I can't figure out. If I move the $mysqli->commit(); into the foreach loop, I get at least one returned row before the rest fail. The error current error message is Array ( [0] => Error: Couldn't insert into english! ). Any idea what is causing this?
<?php $file_array = file('../grammar/conjunctions.txt'); $csv = array_map('str_getcsv', $file_array); // DB $mysqli = new mysqli('localhost', 'root', '******', 'angos'); $mysqli->autocommit(false); $error = array(); foreach($csv as $value) { $angos_query = $mysqli->query("INSERT INTO angos (angos, grammar) VALUES ('$value[0]', 'con')"); $id = $mysqli->insert_id; // grab the currant angos table id if($angos_query == false) { array_push($error, "Error: Couldn't insert into angos!"); } $english_query = $mysqli->query("INSERT INTO english (angos_id, english) VALUES ('$id', '$value[1]')"); if($english_query == false) { array_push($error, "Error: Couldn't insert into english!"); } if(!empty($error)) { $mysqli->rollback(); } } $mysqli->commit(); print_r($error); // print_r($csv); ?>More info SQL: CREATE TABLE angos ( id int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, angos varchar(255) not null, grammar varchar(3) not null, updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, CONSTRAINT unique_input UNIQUE (angos) ) engine=InnoDB; CREATE TABLE english ( id int unsigned not null primary key, angos_id int unsigned, english varchar(255), grammar_note varchar(500), CONSTRAINT fk_angos_source FOREIGN KEY (angos_id) REFERENCES angos(id) ON DELETE CASCADE ON UPDATE CASCADE ) engine=InnoDB; well done really need help but this seemed the best place to put it well i was wondering what would be easy 1st project for a beginner to make in php, About Me Hi, firstly let me introduce myself. My name is Liam O'Connor and I'm 17 years old, 18 soon (quite excited) living in the UK and I've been learning how to makes websites ever since I was 16. Within the last 2 years I have taught myself (x)HTML/CSS, PHP/MySQL, JavaScript/Ajax to a good standard. I'm currently at college doing a Computing Networking and Security Extended Diploma. The Project I have been working on a website for many months now that I REALLY love doing. When ready for launch the website will be a simple social networking website that lets users communicate in groups or one-on-one, also users will be able to create chats on the topics they like to talk about and personalise them to how they like. What have I done so far? Within the last few months I have created a well working chat system that allows many users to communicate together, and many features within the chat such as emoticons, change status (online, busy, away), control of font size, sound alerts, chat comments, and a thumb rating system. What could you do? If you are interested to help develop a website like this one (for free) in your own time, please contact me and let me know a little about you and what you think you would be able to offer. There is no rush to get this project finished and put live for the world to see so there would be no pressure on you. If you are not interested in developing the website but you believe you have some wise words of wisdom please share them with me or if you believe you can help in any other way please let me know. Please check out the image below Thanks Hello I am new to the forums and this is my first post A little about me, I have played around with php time to time but don't know how to code it, I can modify it and use scripts and what not but I can't find a script that I wan't to do this I wan't to be able to upload and file share site without using mysql and using cookies instead to keep track of user's upload's without having them to register a account, I don't want a user management system for this I just want them to be able to upload a file and it keep track of their upload's(I can set a limit of course), and be able to share the direct link to their friends for them to quickly download it. I need to know what steps I need to do and how to start basically and if anyone can help me out. Thank you PHP Freaks Hi, I need more than one person on my team for my project, I was wondering if someone will join and help me. My project it a website software (kind of like a CMS). This won't be paid. That's the only problem.
So I am working on a project in which I am taking pictures from an SSH area, running ImageMagick on the picture to crop out what I want and then use the threshold to make it like I want, and then finally run Tesseract OCR on the final picture. I have a new picture coming in to the spot I am taking the pictures from every six seconds and I need the program to run the commands to do all of this every six seconds as the pictures come in forever basically. As of right now, here is my code that I have. I am relatively new to using PHP scripting working for the command line in Ubuntu. So if anyone could help me with some fixes to this code, I would be greatly appreciative. Code: [Select] <?php function tesseract($image) { define($ocmd, `ssh *place i am taking from*`); fwrite("<pre>$ocmd</pre>"); define("$pic1", "`convert $image -crop 1000x170+350+785 -negate -threshold 42000 $image.tif`");//This is a 1920x1080 hd image define("$pic2", "`convert $image -crop 600x95+200+550 -negate -threshold 41000 $image.tif`");//This is a 1280x720 hd image define("$pic3", "`convert $image -crop 650x100+75+550 -negate -threshold 43000 $image.tif`");//This is a 960x720 hd image define("$pic4", "`convert $image -crop 500x62+175+410 -black-threshold 53% $image.tif`");//This is a 960x540 hd image define("$cmd2", "`tesseract $image.tif $image.txt`");//command to take the words of the edited image list($width, $height) = ImageCreateFromJPEG(filename); define("$area", "($width*$height)"); if ($area == 1920*1080) { $line = $pic1; } elseif ($area == 1280*720) { $line = $pic2; } elseif ($area == 960*720) { $line = $pic3; } elseif ($area == 960*540) { $line = $pic4; } else { $line = "Please try a picture of another size."; } echo("<pre>$line</pre>"); if ($line != "Please try a picture of another size.") { echo"<pre>$cmd2</pre>"; } } ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=306541.0 Fatal error: Method name must be a string in C:\xampp\htdocs\cmsv2room\model\getTimeTableClass.php on line 216 i am using setters ang getters for arrays while setting an array in a array i get this error the line in which i got the error is below $gettimetableObject->$setFacnameArray($FacnameArrayR); actually iam storing arrays in an array $FacnameArrayR is an array storing in a array with help of object(concept of setters) i am having a problem passing variables from a php file to a html file using a javascript funtion. here is the code i have. Code: [Select] /////////InteractiveMap.HTML//////////////////////////////////////////////////// <script type="text/javascript"> // This function is called when a building is clicked. function buildingClick(id,name,desc) { var mywin; var isOpen = false; var searchInt; var passVal; passVal = desc; mywin = window.location.href = "informationPage.html"; searchInt = setInterval(function(){if(isOpen){var display=mywin.document.getElementById("infoArea"); display.value = passVal;}});} /////////////////////////////////////////////////////////////////// ////////////InformationPage.html/////////////////////////////// <script type="text/javascript"> window.onload = function(){window.opener.window["isOpen"] = true;}; </script> <textarea disabled id="infoArea"></textarea> ////////////////////////////////////////////////////// I am just tryin to display the variable desc in the textarea "infoArea" but it wont work.Any help would be appreciated. eoin with my limited PHP programming skills I have managed to successfully a produce a css button maker which makes and produces the code for a number of resolutions and devices. this is the $result displayed Code: [Select] $result = "<a href='#' class='blnk'><li class='btn rnd'>" .$_SESSION['text'] ."</li></a>"; ($_SESSION['result']==$result); this is how each device is called: Code: [Select] #### ANDROID ####### if ($_SESSION['device']=="android") { echo "<div id='andt'></div><div id='andm'><div id='and-st'><div id='btn'>"; $i=1; while($i<=$_SESSION['nbr']){ echo $result; $i++; } echo "<div class='cl'></div></div></div></div><div id='andb'></div>";} This is the dropdown for the bumber of buttons Code: [Select] <legend> Button No</legend> <select name="nbr"><option value="<? echo $_SESSION['nbr'] ?>"><? echo $_SESSION['nbr'] ?></option><?php include('inc/f-1to8.php'); ?></select></fieldset></td> Code: [Select] <tr> <td colspan="3"><fieldset><legend>Button Text </legend><input name="text" type="text" value="<? echo $_SESSION['text'] ?>" size="50" maxlength="16" /></fieldset></td> What I need is to know howto not only produce a number of Button Text input boxes that correspond to Button No but ones that each correspond individual buttons so each button has its own text field. If anyone can help it would be much appreciated - Im suprised I have got as far as I have. here is the link at the mo http://www.d-sine.com/_STYLES/buttons.php - (the reset button will set default settings by going to a page that posts back default settings in hidden fields on a meta refresh) Kind Regards Hi all, I am an intermediate PHP Programmer, but I'm now stuck with getting any further. I am currently developing a CMS with a few people. However, I wish to put that aside for a month or so and learn PHP a bit better. Can anyone suggest a fairly "easy" project for me to do to learn a bit more about PHP? Best Regards, DM So I have decided to do research as my project and gain something from this. But also I will have to include programming which i prefer PHP. and will be testing these for my research. Does this sound like a good project and also If it is good sound.. Where do I start?... need a starting point and then I could go on to doing it.. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=319234.0 Okay, let's say I have a block of text like so; 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 I need to be able to add more/less digits to the text. Like so; 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 etc Also if it's greater than a certain number, to subtract. :3 How would I go about doing that? Thank you, Doctor I'm doing a project using PHP to store reviews by people in the database.
http://postimg.org/image/3l9j1uipf/
When the 'Add Reviews' is clicked, it goes here
> http://postimg.org/image/q07qvnluh/
Here comes the problem, I need to add radio buttons / groups for people to select their phone rating 1-5.
& in the front page (the page with add / search / list), it displays the ranking / rating of phones.
Anyone have any idea how do I do the codes?
Edited by Axton, 06 August 2014 - 05:18 AM. |