Questions tagged [php]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
18 views

Escaping Characters in PHP

// handle URL if (preg_match("/^https?:\/\//", $destination)) { header("Location: " . $destination); } I was wondering why the string inside preg_match has extra /^ and / ...
1
vote
1answer
181 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 ...
0
votes
3answers
1k views

Finance: Buy/Sell does not insert into MySQL history table

On pset7 and struggling with the history part. When I buy or sell a stock, it's reflected in the portfolio and the cash available is also updated. However, it does not seem to be affecting the ...
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 ...
0
votes
1answer
86 views

How to Access Appliance Website In Vhosts

If you are past pset7, or at least have set up PHPMyadmin, you can access your PHPmyadmin databases outside of the appliance by going to ip.ad.dr.ess/phpmyadmin. How do I access my websites in vhosts ...
1
vote
1answer
843 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
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
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 ...
0
votes
1answer
342 views

to what extent does CS50 teach the different languages? [closed]

There are many languages taught in CS50. javascript, css, html, c, [tag: PHP], etc. To what extent are they taught? Can I make my own websites after CS50 ? To what extend do I have to learn these ...
0
votes
1answer
71 views

php syntax questions

I am having trouble with formatting php correctly. Specifically, when I need to use two sets of double quotes, how do I make it group them correctly? eg: query("INSERT INTO Holdings (id, symbol, ...
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
218 views

pset7 php files are not served

I'm using appliance2014, went trough all the steps in pset7, phpmyadmin seems to be working fine, but whenever I try the link specified in the problem set, where I'm supposed to test the server after ...
0
votes
1answer
136 views

Setting up a connection between php and mysql outside of CS50 Appliance using the methods of CS50 Finance?

I recently decided to get my final project from last year online. But I ran into a lot of trouble. Can someone help me? I was using the functions in last year's CS50 finance to connect php to mysql db,...
0
votes
0answers
284 views

Array to string conversion error in PHP

In public/quote.php, I have a line: render("quote.php", ["price"=>$s["price"]); Then in template.php, I try to print: print("Price: " . $s["price"]); but I keep getting this error: Array to ...
0
votes
1answer
208 views

pset7 unknown column in where clause

This throws an error saying YHOO is an unknown column...I thought 'symbol' was the column name in this query? $id = 6; $symbol = "YHOO"; $shares_query = query("SELECT shares FROM portfolio WHERE id = ...
0
votes
1answer
427 views

what is the username and passwrod when sending mail via phpmailer?

how do i know what is the password and username for phpmailer for pset7. i am using the off campus smtp server smtp.comcast.net but everytime i try to send an email it gets rejected due to the need ...
1
vote
1answer
111 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? ...
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 ...
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-...
1
vote
1answer
743 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 ...
0
votes
1answer
657 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 ...
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) ...
1
vote
1answer
942 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 =...
2
votes
1answer
281 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 ...
3
votes
2answers
897 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 ...
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 ...
0
votes
1answer
206 views

Pset7 SQL Error!

I'm working in Pset7. I've downloaded pset7.sql file, opened it with gedit, copied and pasted the file's content in phpMyAdmin's SQL text box then clicked GO. As in the pset7 instruction, I should see ...
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

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
2