第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

發(fā)布到數(shù)據(jù)庫不起作用(錯(cuò)誤/警告:JSON 輸入意外結(jié)束)

發(fā)布到數(shù)據(jù)庫不起作用(錯(cuò)誤/警告:JSON 輸入意外結(jié)束)

PHP
翻閱古今 2022-10-09 17:15:28
我正在使用 React Native 開發(fā)移動(dòng)應(yīng)用程序。問題是我似乎無法將任何內(nèi)容插入數(shù)據(jù)庫。我有一個(gè)注冊頁面,用戶需要在其中編寫用戶名和密碼(并重復(fù)該密碼),幾個(gè)月前該頁面運(yùn)行良好。我沒有更改該特定頁面上的任何內(nèi)容,但是當(dāng)我開始添加新頁面時(shí),例如另一個(gè)不起作用的頁面,它停止工作并給了我可以在此處看到的警告:另一個(gè)不起作用的頁面是用戶可以在其中發(fā)布帶有標(biāo)題日期等的工作。此頁面尚未完成,但應(yīng)該已完成,以便用戶可以將某些內(nèi)容發(fā)布到數(shù)據(jù)庫,但它給了我可以在此處看到的錯(cuò)誤:注冊頁面的代碼如下(不包括樣式表):import React, { Component } from "react"; import { View, Text, StyleSheet, Alert, TextInput, ImageBackground, Image, AsyncStorage, TouchableOpacity } from "react-native";import { Button, Icon, withTheme } from 'react-native-elements';const SIGNUP_URL = 'http://kamilla-server.000webhostapp.com/app/signUp.php';class SignUp extends Component { constructor(props) {    super(props);    this.state= {        email: '',        password: '',        password2: '',    }; }async onSignUp() {    const { email, password, password2 } = this.state;    if(this.state.email != '' && this.state.password != '' && this.state.password2 != '') {        if(password != password2) {            Alert.alert('Password matcher ikke', 'De to indtastede passwords skal v?re det samme password')        } else {            const response = await fetch(SIGNUP_URL, {                headers: {                    Accept: 'application/json',                    'Content-Type': 'application/json'                },                method: 'POST',                body: JSON.stringify({ email, password }),            })            const data = await response.json()            if (data.error) {                alert(data.error)            } else {                AsyncStorage.setItem('UserID', data.user.UserID)                this.props.navigation.navigate('SignUpMessage')            }        }    } else {        Alert.alert('Tomme felter', 'Venligt indtast email og password for at kunne oprette en bruger')    }}
查看完整描述

2 回答

?
楊魅力

TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超6個(gè)贊

問題是這一行: $_SESSION['userID'] = $getUser['UserID']; The $getUserneeds to be $getNewUser,因?yàn)檫@是我從中獲取的變量的名稱。我一定是在不知不覺中改變了它,從而產(chǎn)生了問題。



查看完整回答
反對 回復(fù) 2022-10-09
?
回首憶惘然

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊

我在這里可能錯(cuò)了,但我最好的猜測是您的 fetch api 收到錯(cuò)誤,您應(yīng)該嘗試將async onSignUp函數(shù)的 fetch 修改為:


  await fetch(SIGNUP_URL, {<params>})

    .then(res => {

      // Handle API Errors

      if (!res.ok) {

        console.log(res.statusText);

      }

      // Return if no errors

      return res.json();

    })

    // this is the data you want

    .then(data => data)

    // it will only reject on network failure or if anything prevented the request from completing

    .catch(error => {

      console.log(error.message)

    });

您可以嘗試上述方法,看看您是否在響應(yīng)中收到錯(cuò)誤!希望這可以幫助!!


查看完整回答
反對 回復(fù) 2022-10-09
  • 2 回答
  • 0 關(guān)注
  • 199 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號