Jump to content

Search the Community

Showing results for tags 'parameter mysql'.

  • 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. Hi - I have been battling for days trying to pass a parameter to a functioning procedure. I have a PHP app that works perfectly, which calls a Procedure in our database. As soon as I add a parameter to the Procedure, I get zero result. The objective is to be able to pass a parameter (accountID) to the called Procedure. This parameter is to be used to control the WHERE clause in the procedure Please can someone look at tell me what am I doing wrong. Thanks in advance (and I'm sorry to have copied all the code, but thought it would help) Larry The PHP (getallroutesformap.php ) Application code<?php include 'dbconnect.php'; switch ($dbType) { case DB_MYSQL: $stmt = $pdo->prepare('CALL prcGetAllRoutesForMap();'); $acID='10091'; $stmt->bindParam(':accID', $acID, PDO::PARAM_STR); // always calls the procedure /// $stmt->bindParam(':accID', $acID); /// does not work /// $stmt->bindParam(':accID', 10091); /// does not work $acID='10091'; break; case DB_POSTGRESQL: case DB_SQLITE3: } $stmt->execute(); $json = '{ "locations": ['; foreach ($stmt as $row) { $json .= $row['json']; $json .= ','; } $json = rtrim($json, ","); $json .= '] }'; header('Content-Type: application/json'); echo $json; ?> Database Procedure (getallroutesformap) that works.Note: accountID=’10091’, but I need it to be a variable/parameter BEGIN SELECT sessionId, gpsTime, CONCAT('{ "latitude":"', CAST(latitude AS CHAR),'", "longitude":"', CAST(longitude AS CHAR), '", "speed":"', CAST(speed AS CHAR), '", "direction":"', CAST(direction AS CHAR), '", "distance":"', CAST(distance AS CHAR), '", "locationMethod":"', locationMethod, '", "gpsTime":"', DATE_FORMAT(gpsTime, '%b %e %Y %h:%i%p'), '", "userName":"', userName, '", "phoneNumber":"', phoneNumber, '", "sessionID":"', CAST(sessionID AS CHAR), '", "accuracy":"', CAST(accuracy AS CHAR), '", "extraInfo":"', extraInfo, '" }') json FROM (SELECT MAX(GPSLocationID) ID FROM gpslocations WHERE accountID = '10091' && sessionID != '0' && CHAR_LENGTH(sessionID) != 0 && gpstime != '0000-00-00 00:00:00' GROUP BY sessionID) AS MaxID JOIN gpslocations ON gpslocations.GPSLocationID = MaxID.ID ORDER BY gpsTime; END Database Procedure that gives Zero ResultsHere the Procedure has a parameter assigned to it called accID . which is setup as an IN, VARCHAR, 15 This immediately gives me a zero result, even if I change accountID= accID or leave it as it was before. BEGIN SELECT sessionId, gpsTime, CONCAT('{ "latitude":"', CAST(latitude AS CHAR),'", "longitude":"', CAST(longitude AS CHAR), '", "speed":"', CAST(speed AS CHAR), '", "direction":"', CAST(direction AS CHAR), '", "distance":"', CAST(distance AS CHAR), '", "locationMethod":"', locationMethod, '", "gpsTime":"', DATE_FORMAT(gpsTime, '%b %e %Y %h:%i%p'), '", "userName":"', userName, '", "phoneNumber":"', phoneNumber, '", "sessionID":"', CAST(sessionID AS CHAR), '", "accuracy":"', CAST(accuracy AS CHAR), '", "extraInfo":"', extraInfo, '" }') json FROM (SELECT MAX(GPSLocationID) ID FROM gpslocations WHERE accountID = accID && sessionID != '0' && CHAR_LENGTH(sessionID) != 0 && gpstime != '0000-00-00 00:00:00' GROUP BY sessionID) AS MaxID JOIN gpslocations ON gpslocations.GPSLocationID = MaxID.ID ORDER BY gpsTime; END
×
×
  • 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.