Questions tagged [php]

PHP is a general-purpose, open source scripting language widely used in web development.

Filter by
Sorted by
Tagged with
4
votes
1answer
3k views

Accessing information from PHPmyadmin using Javscript

I am currently working on my final project and trying to add markers to my Google map using information from a MySQL table. I called this table ideas and the table contains info such as the longitude ...
3
votes
2answers
887 views

How Does extract() Work in PHP?

From what I understand, extract() takes in an array as an argument and creates variables whose names are exactly identical to the keys in this array and whose values are the values associated with ...
2
votes
1answer
602 views

pset8 (mashup) - Inserting $places variable into configure function in scripts.js

On line 109 of the scripts.js distro is the TODO _.template("(p)TODO(/p)") (Using parenthesis instead of carrots to make this read correctly) I cannot for the life of me figure out how to have ...
2
votes
1answer
277 views

How to Correctly Submit Form Data Using GET?

If https://www.google.com/search?q=cs50 submits form data using GET to search, what is search? What is its extension? Is it possible to visit this page without passing the parameter called q? (well, I ...
2
votes
1answer
179 views

PHP array syntax

I am confused about why I can't print the content of $positions using the code below. $rows = query("SELECT * FROM protfolio WHERE id = ?", $_SESSION["id"]); $positions = []; foreach ($rows as $row) ...
2
votes
2answers
474 views

chmod doesn't work on individual files?

When I do something like chmod 000 dir I don't see the directory when I open the server but when I do this on individual files and not the directory chmod 000 file.php I still see that file in my ...
1
vote
2answers
193 views

How Does PHP Construct Variables and Store Data in Them?

From the notes of week9 - lecture, Once we’re in PHP mode, we access a variable named $_POST. This is an associative array which PHP constructs for you whenever you pass in data via the POST ...
1
vote
1answer
488 views

phpMyAdmin: “mysql extension missing” error

pset7: I receive the following error when trying to open phpMyAdmin: "the mysqli extension is missing. Please check your PHP configuration. See our documentation for more information." I previously ...
1
vote
2answers
5k views

How to link submit button with the <select> list in HTML?

I want to create an HTML page that consists of a <select> option list, and a submit button with it. There are 3 options in the list and I want that when one option is selected and the submit ...
1
vote
1answer
742 views

Extra feature to send receipts - PHP Mailer not connecting

I'm trying to add the feature to send "receipts" after buying and selling stocks. It seems to be very straightforward, I'm just using the code that David used in froshims, but I get the following ...
1
vote
1answer
81 views

Pagination using mysql and php

Are there any MySQL queries that can help me retrieve x recent entries from a table having z total rows such that I can keep a take-off point y, where 0 <= x <= y <= z? Actually its for ...
1
vote
2answers
56 views

redirect my apache index?

Hi I am trying the apache server out so i decided to install one on my Raspberry Pi. I then wanted to take the same (or some of) the code we had in pset7 and run on my own server. I have a problem ...
1
vote
1answer
179 views

How to determine how much cash a user has in C$50 Finance's portfolio.php

I've read portfolio's specifications. However, I have a doubt regarding how to update a given users's balance. Suppose a user with an id '1' buys a stock whose symbol is 'A' for a price '$B'. Now ...
1
vote
2answers
88 views

Path to PHP Interpreter

What is the path to the PHP interpreter in the CS50 appliance? I used it a couple times but I forgot what the path is. I think it starts with #/env or something similar. Thanks, David
1
vote
1answer
78 views

Pset7 - Portfolio: $positions not filling

Working within index.php, I feel like I understand the logic of what is going on, and I can get portfolio.php to render out fine on the website - with the exception that it only prints out one row ...
1
vote
1answer
26 views

Do calls to render() overwrite each other?

Do calls to render overwrite each other? I mean, if I call render twice in a php file located in pset7/public (was it called a controller?), and both of those calls render() with two different views, ...
1
vote
1answer
38 views

Encrypted passwords in POST method

when using an html form and submitting this form to another php file. When should I encrypt important data like passwords ? Where should I encrypt them.
1
vote
1answer
61 views

C$50 Finance Pset7 - Buy.php not INSERTing shares correctly

My code for Buy.php. For some reason whenever I fill out both fields of shares and symbol correctly I get the apologize error that the data wasn't inserted into the table correctly. (I don't think I ...
1
vote
1answer
539 views

How difficult are pset7 and pset8?

I am just about 50% done with pset6, for me pset5 and pset6 were the most difficult ones for me, as we have transitioned from C to php in lectures of week 6 and week 7 just wanna ask those who have ...
1
vote
1answer
245 views

Debugging in Problem Set 7: CS50 Finance

I am in the process of completing Problem Set 7 and I would like to know if there is a better way to debug than using print statements.
1
vote
2answers
95 views

Array in php vs R (pset7 sell.php)

Ok, I'm at pset7 (C$50 Finance), more specifically trying to implement sell.php. I have created a template, sell_form.php, where users can select the symbol of the stock they want to sell and ...
1
vote
1answer
786 views

CSS Table Gradient Not Working

I am trying to make a gradient for my table head, but it is not working at all. CSS: PHP + HTML I still have my nooby table.
1
vote
1answer
44 views

How to Redirect Only When a User Clicks Ok on a Popup?

I want a JS popup to appear after something is successfully completed. How do I make it appear, and disappear only when the user closes it, then redirect to the next page? By the way this is in a php ...
1
vote
1answer
26 views

Much less comfortable section re pset5 [closed]

I'm taking cs50x and having a lot of trouble with pset6. I just noticed that there are experimental videos of sections given by many different TFs. Could anyone recommend one or two section ...
1
vote
1answer
940 views

Unknown column cash php?

When I try to test register.php for pset7, the website says that there is an unknown column cash in the error. Can anyone see what is my mistake? Here is the part of my coding with this error: $rows =...
1
vote
1answer
40 views

Why is my browser downloading a page instead of displaying it?

Whenever I try to run the staff's fro-shims-0 program or any other PHP code the browser just downloads the PHP file for me. Isn't there something about PHP being a server side scripting language? How ...
1
vote
1answer
81 views

Reading a book before starting pset7 Help needed abt Cs50 IDE

Ok to get full grasp of php html and css I have decided to read a book first and practice some of it examples before diving into the actual pset7, just wanna ask those who have completed cs50.... I ...
1
vote
1answer
99 views

pset7 (buy): trouble comparing value of transaction with cash

For some reason it is impossible for me to compare the cost of the buy-transaction with the user's cash balance in pset7. $value correctly comes up as a float, but $cash comes up as a string (even ...
1
vote
1answer
116 views

I am working on the quotes' section of the pset7. I always get this error which I am unable to understand?

quote.php <?php // configuration require("../includes/config.php"); if ($_SERVER["REQUEST_METHOD"] == "GET") { //do something // else render form render(".....
1
vote
3answers
157 views

Excel into MySQL

A website has a link to download an excel file. I need some of those columns in my MySQL database. Is there a relatively painless way to: 1. use phpmyadmin's import tab 2. use a method similar to ...
1
vote
1answer
106 views

Install MongoDB on appliance - Uint type error

For my final project, I'm trying to install the MongoDB PHP driver. While compiling, I get the error unknown type name 'uint'; did you mean 'int'?. It seems like I am missing a library, but which one? ...
1
vote
1answer
96 views

php chart library

For the final project I need to use php to graph simple linear functions. I can't seem to install any of the charting libraries available online (e.g. image_graph, imagick). Is there some pre-...
0
votes
1answer
45 views

cs50::init(_DIR_.“/../config.json”) pset7

// CS50 Library require("../vendor/library50-php-5/CS50/CS50.php"); CS50::init(__DIR__ . "/../config.json"); How does CS50::init(directory) work?
0
votes
1answer
934 views

syntax error, unexpected 'for' T_FOR

I got this error syntax error, unexpected 'for' T_FOR for a function that uses a for loop. However, I can't point out what's the mistake. All the semicolons and variables are in place supposedly ...
0
votes
1answer
27 views

include 'file.php' does not seem to work

I seem to have the problem that in a php file I wrote, I can not seem to link an external file: -bash-4.1$ pwd /home/mywebsite.com/public_html/incl -bash-4.1$ ls toinclude.php hereisthecode.php ...
0
votes
1answer
415 views

When I run my apache50 server at ~/workspace/pset7/public why does login.php files open?

I have a question regarding the working of pset7. I have completed it but now I am scratching my head for this question. When I run my apache50 server like : apache50 start ~/workspace/pset7/public ...
0
votes
1answer
431 views

register php pset7 query to INSERT do not work

Trying to make register.php to insert a name, the checks work fine, as empty name, empty password an confirmation and password different from confirmation leads to apologize. Then if user already ...
0
votes
1answer
86 views

Question about “echo”, “print”, “printf” in php

Is there any difference between"echo", "print", "printf" in php? They seem to have the same output when being implemented... Thanks!
0
votes
1answer
649 views

How to create a drop-down menu that contains the stocks that has as options?

I'm struggling trying to create the form for this part of the pset. I have a controller (sell.php) and a template form (sell_form.php). Sell.php receives submission from sell_form.php, delete user 's ...
0
votes
1answer
515 views

PHP removal from CS50

Hello dear CS50 folks, I was wondering - just out of curiosity - why PHP was removed from CS50 ? And why choose Python instead ? If someone could give me an elaborate answer, explaining the ...
0
votes
1answer
34 views

PSET7: Extracting strings from queries with PHP

Not a bug, but wondering if someone can explain why this works... I'm attempting to display someone's name and cash position. In index, I query the tables for the relevant values. This returns an ...
0
votes
1answer
114 views

How can I update the version of php on my cs50 appliance?

I have version 17-12 of cs50 appliance. It has the version 5.4.7 of php . I want to update the version of php to 7. How can I do this?
0
votes
1answer
75 views

illegal string offset error in portfolio

I am passing an associative array(positions) via render: render("portfolio.php", [ "title" => "Portfolio","positions" => $positions]); and trying to print it in portfolio using below code: ...
0
votes
1answer
6 views

What's is wrong with this php code

The interpreter won't interpret my code for some syntax error in line 13 and I can't figure out what's the problem. <?php extract($_GET) for($i = 0; $i < key; $i++) ...
0
votes
2answers
262 views

pset7 reset password php mail function doesn't send email

EDIT number 2: I have tried phpmailer instead of mail() function. Please, take a look at the code below. I have created a few email accounts to test the code, none worked: yahoo, gmail, yandex. I am ...
0
votes
1answer
101 views

PSET8: fopen() not working for import

For pset8, fopen() keeps returning FALSE. The relevant part of my code is below: #!/usr/bin/env php <?php $file = ($argv[1]); if(file_exists($file) == 0) { exit("File does not exist.\n"); } ...
0
votes
1answer
87 views

Drop-down Menu for Sell_View.PHP gives empty options

I've been working on CS50 Pset7, CS50 Finance, and I have everything working bar the sell page. Everything on the sell page works, except for the fact that when I click my drop-down menu to choose ...
0
votes
1answer
221 views

How to make search.php return results that are more relevant

For pset8 in search.php, I cannot get relevant results to show up. I am using match () against () and I really want to only use this. The problem is, for example, when I type in Cincinnati, I get ...
0
votes
1answer
81 views

How should I connect to the multiple databases?

I am trying to Merge several psets. But to do that I think I need to have multiple databases. My dumbest approach to that problem follows like this in constants.php define("DATABASE", "pset7"); ...
0
votes
1answer
64 views

week7 lecture2 source code speller.php not found

David showed the php version of speller.c but I can't find the code neither on edx, nor on cs50.harvard.edu https://cs50.harvard.edu/lectures/7/w/src https://courses.edx.org/courses/course-v1:...