Skip to main content

I need help getting rid of a fatal error in php [closed]

Hi I'm writing code for a programme that plays blackjack and I keep getting a redeclaration error on a function I'm writing and would like some help

 function displayCard($card)
     {
        $picNum = ( ($card % 5) + 1);
        echo "<img src='images/" . $picNum  . ".png' width='50' height='60' >";

        
         if ($picNum == 1)
             echo "<img src='images/1.png'>";
         elseif ($picNum == 2)
             echo "<img src='images/2.png'>";
         elseif ($picNum == 3)
             echo "<img src='images/3.png'>";    
         elseif ($picNum == 4)
             echo "<img src='images/4.png'>";
         elseif ($picNum == 5)
             echo "<img src='images/5.png'>"; 
             elseif ($picNum == 6)
             echo "<img src='images/6.png'>";
         elseif ($picNum == 7)
             echo "<img src='images/7.png'>";    
         elseif ($picNum ==8)
             echo "<img src='images/8.png'>";
         elseif ($picNum == 9)
             echo "<img src='images/9.png'>"; 
             elseif ($picNum == 10)
             echo "<img src='images/10.png'>";
         elseif ($picNum == 11)
             echo "<img src='images/11.png'>";    
         elseif ($picNum == 12)
             echo "<img src='images/12.png'>";
         elseif ($picNum == 13)
             echo "<img src='images/13.png'>"; 
             elseif ($picNum == 14)
             echo "<img src='images/14.png'>";
         elseif ($picNum == 15)
             echo "<img src='images/15.png'>";    
         elseif ($picNum ==16)
             echo "<img src='images/16.png'>";
         elseif ($picNum == 17)
             echo "<img src='images/17.png'>";
             elseif ($picNum == 18)
             echo "<img src='images/18.png'>";
         elseif ($picNum == 19)
             echo "<img src='images/19.png'>";    
         elseif ($picNum == 20)
             echo "<img src='images/20.png'>";
         elseif ($picNum == 21)
             echo "<img src='images/21.png'>"; 
             elseif ($picNum == 22)
             echo "<img src='images/22.png'>";
         elseif ($picNum == 23)
             echo "<img src='images/23.png'>";    
         elseif ($picNum ==24)
             echo "<img src='images/24.png'>";
         elseif ($picNum == 25)
             echo "<img src='images/25.png'>"; 
             elseif ($picNum == 26)
             echo "<img src='images/26.png'>";
         elseif ($picNum == 27)
             echo "<img src='images/27.png'>";    
         elseif ($picNum == 28)
             echo "<img src='images/28.png'>";
         elseif ($picNum == 29)
             echo "<img src='images/29.png'>"; 
             elseif ($picNum == 30)
             echo "<img src='images/30.png'>";
         elseif ($picNum == 31)
             echo "<img src='images/31.png'>";    
         elseif ($picNum ==32)
             echo "<img src='images/32.png'>";
         elseif ($picNum == 33)
             echo "<img src='images/33.png'>";
             elseif ($picNum == 34)
             echo "<img src='images/34.png'>";
         elseif ($picNum == 35)
             echo "<img src='images/35.png'>";    
         elseif ($picNum ==36)
             echo "<img src='images/36.png'>";
         elseif ($picNum ==37)
             echo "<img src='images/37.png'>"; 
             elseif ($picNum ==38)
             echo "<img src='images/38.png'>";
         elseif ($picNum ==39)
             echo "<img src='images/39.png'>";    
         elseif ($picNum =40)
             echo "<img src='images/40.png'>";
         elseif ($picNum ==41)
             echo "<img src='images/41.png'>"; 
             elseif ($picNum == 42)
             echo "<img src='images/42.png'>";
         elseif ($picNum == 43)
             echo "<img src='images/43.png'>";    
         elseif ($picNum == 44)
             echo "<img src='images/44.png'>";
         elseif ($picNum == 45)
             echo "<img src='images/45.png'>"; 
             elseif ($picNum == 46)
             echo "<img src='images/46.png'>";
         elseif ($picNum == 47)
             echo "<img src='images/47.png'>";    
         elseif ($picNum ==48)
             echo "<img src='images/48.png'>";
         elseif ($picNum == 49)
             echo "<img src='images/49.png'>";
         elseif ($picNum == 50)
             echo "<img src='images/50.png'>";    
         elseif ($picNum ==51)
             echo "<img src='images/51.png'>";
         elseif ($picNum == 52)
             echo "<img src='images/52.png'>";
    }
    
}

Fatal error: Cannot redeclare displayCard() (previously declared in C:\xampp\htdocs\assignment\blackjack.php:82) in C:\xampp\htdocs\assignment\blackjack.php on line 82

*

This is the error I keep getting on this part, I'm unsure what the issue might be with it. it is being both declared and redeclared on the same line of code, though I have only entered DisplayCard once I have an earlier function called displayCards which is operating perfectly. I tried changing the displayCard name to displayCardio, but had the same issue.



source https://stackoverflow.com/questions/68953902/i-need-help-getting-rid-of-a-fatal-error-in-php

Comments

Popular posts from this blog

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console...

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

The number of nodes and edges I calculated manually and by a method provided by networkx library dont match

I am trying to analyse a graph using networkx library in Python. I have implemented a function that returns the nodes and edges of that graph. After that I counted the number of nodes and edges by implementing the len() function for nodes and edges, which gave me 17 for both nodes and edges. However, when I used the method graph.number_of_nodes() of networkx library it gave me 53. My code: import pandas as pd import networkx as nx import matplotlib.pyplot as plt header_list = ["a","b","w"] E =pd.read_csv("aves-barn-swallow-contact-network.edges",sep=" ",header= None,names=header_list) # print(E.head()) # prints first few rows of the csv file G = nx.from_pandas_edgelist(E,"a","b",["w"]) nx.draw(G) plt.show() class GraphAnalyse: #finding nodes and edges def nodeEdge(self,Graph): nodes = Graph.nodes() edges = Graph.edges() ...