Jump to content

Search the Community

Showing results for tags 'pdo mysql dynamic variables'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I've been trying to learn OOP using PDO and I've been doing pretty well, but this threw me for a loop. I have a form that creates more inputs using javascript. I can pull the post variables and echo them, but can't figure out how to pass it to my function. Here is some code if(isset($_REQUEST['insert'])){ $departTime = $_POST['departTime']; $departPlace = $_POST['departPlace']; $arriveTime = $_POST['arriveTime']; $arrivePlace = $_POST['arrivePlace']; $numberOfPass = $_POST['numberOfPass']; $purpose = $_POST['purpose']; $cargo = $_POST['cargo']; $txtbox = $_POST['remarks']; //I can echo my variables I want just fine foreach($departTime as $a => $b) echo "$departTime[$a] - $departPlace[$a] - $arriveTime[$a] <br />"; //I need to get them in this statement and to my function extract($_REQUEST); if($obj->createlog($logDay,$logMonth,$logYear,$logCaptain,$logEmployer,$logLocation,$logWeather,$logSeaCondition,$logVisibility,$logWind,$logRunningTime,$logStandByTime,$logDownTime,$logMate,$logEngineer,$logDeckhand,$logDeckhand2,$logCook,$logAccidents,$logCaptainRemarks,$logLubeOnBoardPrevious,$logFuelOnBoardPrevious,$logFuelReceived,$logFuelTotal,$logFuelUsed,$logFuelTransferred,$logMeterClosing,$logMeterOpening,$logMeterPumped,$logFuelOnBoardEnd,$logLubeReceived,$logLubeTotal,$logLubeUsed,$logLubeOnBoardEnd,$logHoursOnLubePort,$logHoursOnLubeStbd,$totalHoursOnEnginePort,$totalHoursOnEngineStbd,$vesselName,$vesselNumber,$vesselType,$vesselOwner,"dailymasterlogs","vessels")){ header("location:displayLogs.php?status_insert=success"); } } I hope this isn't too much code. If I have too much going on let me know and I can cut it down to help illustrate my question. The main things is I need departTime, departPlace, and arriveTime sent to my function. Here is my function public function createlog($logDay,$logMonth,$logYear,$logCaptain,$logEmployer,$logLocation,$logWeather,$logSeaCondition,$logVisibility,$logWind,$logRunningTime,$logStandByTime,$logDownTime,$logMate,$logEngineer,$logDeckhand,$logDeckhand2,$logCook,$logAccidents,$logCaptainRemarks,$logFuelOnBoardPrevious,$logFuelReceived,$logFuelTotal,$logFuelUsed,$logFuelTransferred,$logMeterClosing,$logMeterOpening,$logMeterPumped,$logFuelOnBoardEnd,$logLubeOnBoardPrevious,$logLubeReceived,$logLubeTotal,$logLubeUsed,$logLubeOnBoardEnd,$logHoursOnLubePort,$logHoursOnLubeStbd,$totalHoursOnEnginePort,$totalHoursOnEngineStbd,$vesselName,$vesselNumber,$vesselType,$vesselOwner,$table,$table2){ $sql = "INSERT INTO $table2 SET vesselName=:vesselName,vesselNumber=:vesselNumber,vesselType=:vesselType,vesselOwner=:vesselOwner"; if(!$stmt = $this->conn->prepare($sql)){ // prepare failed echo "<pre>Prepare failed:\n"; print_r($pdo->errorInfo()); echo "</pre>"; } else { if(!$stmt->execute(array(':vesselName'=>$vesselName,':vesselNumber'=>$vesselNumber,':vesselType'=>$vesselType,':vesselOwner'=>$vesselOwner))){ // execute failed echo "<pre>Execute failed:\n"; print_r($stmt->errorInfo()); echo "</pre>"; } else { // query ran without any errors, you can test if it returned any rows and use them here $sql = "INSERT INTO $table SET logDay=:logDay,logMonth=:logMonth,logYear=:logYear,logCaptain=:logCaptain,logEmployer=:logEmployer,logLocation=:logLocation,logWeather=:logWeather,logSeaCondition=:logSeaCondition,logVisibility=:logVisibility,logWind=:logWind,logRunningTime=:logRunningTime,logStandByTime=:logStandByTime,logDownTime=:logDownTime,logMate=:logMate,logEngineer=:logEngineer,logDeckhand=:logDeckhand,logDeckhand2=:logDeckhand2,logCook=:logCook,logAccidents=:logAccidents,logCaptainRemarks=:logCaptainRemarks,logFuelOnBoardPrevious=:logFuelOnBoardPrevious,logLubeOnBoardPrevious=:logLubeOnBoardPrevious,logFuelReceived=:logFuelReceived,logFuelTotal=:logFuelTotal,logFuelUsed=:logFuelUsed,logFuelTransferred=:logFuelTransferred,logMeterClosing=:logMeterClosing,logMeterOpening=:logMeterOpening,logMeterPumped=:logMeterPumped,logFuelOnBoardEnd=:logFuelOnBoardEnd,logLubeReceived=:logLubeReceived,logLubeTotal=:logLubeTotal,logLubeUsed=:logLubeUsed,logLubeOnBoardEnd=:logLubeOnBoardEnd,logHoursOnLubePort=:logHoursOnLubePort,logHoursOnLubeStbd=:logHoursOnLubeStbd,totalHoursOnEnginePort=:totalHoursOnEnginePort,totalHoursOnEngineStbd=:totalHoursOnEngineStbd"; if(!$stmt = $this->conn->prepare($sql)){ // prepare failed echo "<pre>Prepare failed:\n"; print_r($pdo->errorInfo()); echo "</pre>"; } else { if(!$stmt->execute (array(':logDay'=>$logDay,':logMonth'=>$logMonth,':logYear'=>$logYear,':logCaptain'=>$logCaptain,':logEmployer'=>$logEmployer,':logLocation'=>$logLocation,':logWeather'=>$logWeather,':logSeaCondition'=>$logSeaCondition,':logVisibility'=>$logVisibility,':logWind'=>$logWind,':logRunningTime'=>$logRunningTime,':logStandByTime'=>$logStandByTime,':logDownTime'=>$logDownTime,':logMate'=>$logMate,':logEngineer'=>$logEngineer,':logDeckhand'=>$logDeckhand,':logDeckhand2'=>$logDeckhand2,':logCook'=>$logCook,':logAccidents'=>$logAccidents,':logCaptainRemarks'=>$logCaptainRemarks,':logFuelOnBoardEnd'=>$logFuelOnBoardEnd,':logFuelReceived'=>$logFuelReceived,':logFuelTotal'=>$logFuelTotal,':logFuelUsed'=>$logFuelUsed,':logFuelTransferred'=>$logFuelTransferred,':logMeterClosing'=>$logMeterClosing,':logMeterOpening'=>$logMeterOpening,':logMeterPumped'=>$logMeterPumped,':logFuelOnBoardPrevious'=>$logFuelOnBoardPrevious,':logLubeOnBoardPrevious'=>$logLubeOnBoardPrevious,':logLubeReceived'=>$logLubeReceived,':logLubeTotal'=>$logLubeTotal,':logLubeUsed'=>$logLubeUsed,':logLubeOnBoardEnd'=>$logLubeOnBoardEnd,':logHoursOnLubePort'=>$logHoursOnLubePort,':logHoursOnLubeStbd'=>$logHoursOnLubeStbd,':totalHoursOnEnginePort'=>$totalHoursOnEnginePort,':totalHoursOnEngineStbd'=>$totalHoursOnEngineStbd))){ // execute failed echo "<pre>Execute failed:\n"; print_r($stmt->errorInfo()); echo "</pre>"; } else { // query ran without any errors, you can test if it returned any rows and use them here return true; } } } } } I hope I am clear enough. Any help is appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.