Comments (13)
Hey! @kimeeo What wrong? Me too.
@mevdschee Maybe this tool should write some log or debug.
return null. And no more .I 'm cray......
curl -X POST "http://localhost/api.php/posts" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"user_id\": 44, \"category_id\": 3, \"content\": \"这是一个测试\"}"
Code | Details
-- | --
200 | Response body null
Response headers content-type: application/json; charset=utf-8
Code | Description
-- | --
200 | Identifier of created item.
Example Value
Model 0
Sorry..................
user_id and category_id must be exist.
from php-crud-api.
@xouaib it is probably another exception, please replace "PDOException" with "Exception" or "Throwable" depending on your PHP version.
from php-crud-api.
@xouaib You are now sending post parameters and expect it to be a JSON document, that's not correct.
from php-crud-api.
Try this with
PUT http://kimeeo.com/restDemo/api.php/categories/2
name=my_name
POST
http://kimeeo.com/restDemo/api.php/categories
name=my_name
DELETE
http://kimeeo.com/restDemo/api.php/categories/2
all it does is return null.
from php-crud-api.
I would love to help, but I need more information. Which database engine do you use? Which SQL file did you load? What platform are you on? Which client do you use (like PostMan or curl)? Please provide more information.
from php-crud-api.
Went to "http://editor.swagger.io/" and clicked "File" - "Import URL" and entered "http://kimeeo.com/restDemo/api.php". There I tested your API and it works fine!
from php-crud-api.
Which database engine do you use.
-> MySQL
Which SQL file did you load
->blog_mysql.sql
What platform are you on?
-> PHP 5.6
Which client do you use
-> PostMan
As I said, GET is working
but if PUT, DELETE, POST it reutnr's null
from php-crud-api.
My Bad, Something was wrong at my end.
from php-crud-api.
No problem, enjoy the software!
from php-crud-api.
I don't know, probably returning an header with the error message would make most sense.. but only in the case some debug flag is true.. for security reasons.. or yes.. logging.. that could also work..
from php-crud-api.
@mevdschee hi dear,
pl i create CRUD system API using PHP and MySQL, then the POST not working :
<?php
include 'config/database.php';
if ($_POST) {
try {
$query = "INSERT INTO products SET p_name=:name, p_description=:description, p_price=:price";
$stmt = $con->prepare($query);
$name = $_POST['name'];
$description = $_POST['description'];
$price = $_POST['price'];
$stmt->bindParam(':name', $name);
$stmt->bindParam(':description', $description);
$stmt->bindParam(':price', $price);
if ($stmt->execute()) {
echo json_encode(array('result' => 'success'));
} else {
echo json_encode(array('result' => 'fail'));
}
} catch (PDOException $exception) {
die('ERROR: ' . $exception->getMessage());
}
}
the database file contains already all header that we need , i check the CREATE with POST method using POSTMAN but not working
CORDIALLY
CORD
from php-crud-api.
i still strive with it without ay advance Mr @mevdschee
from php-crud-api.
@mevdschee thank you so much it's working perfectly
from php-crud-api.
Related Issues (20)
- HTML Middleware HOT 2
- Update with "where" HOT 8
- "Request Tranformer" middleware HOT 2
- Azure App Service HOT 1
- Add PHP backend to any app project with one command HOT 1
- Any advice on events integration? HOT 2
- Synchronization between local IndexedDB and MySQL Database. HOT 3
- Can the API Support Customized Cache Management for Specific Tables? HOT 9
- Question: Add property on create HOT 3
- Insights on caching with Redis HOT 2
- Using Customization handler to insert app-generated ID HOT 11
- PUT using curl comes back successful but the record is not actually updated HOT 2
- Suggestion to modify response JSON root Key (records) HOT 2
- firebase jwt public key rotation HOT 5
- "Route '' not found" HOT 3
- Additional SQL queries in authorization handlers HOT 2
- Direct usage of PHP CRUD API functions in external PHP Files HOT 8
- Failure on postgres when table name is domains HOT 10
- Returning user uploaded file using custom controller HOT 2
- Found this PDOException occurred (enable debug mode) in message HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-crud-api.