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
405 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 ...
0
votes
1answer
34 views

query always fails to execute in php

I am trying to insert student exam answers to a table online_exam_marks. I stored $_POST values after ensuring that $_POST value is not empty and if they empty I just set it to $a = '0' to different ...
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
1answer
160 views

How to debug pset8 search.php?

Hello I have trouble to do any debuging in search.php pset8. In previous problems there where always some way to print my variables and figure out what was wrong with my querys och logics. However in ...
2
votes
2answers
476 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 ...
0
votes
2answers
672 views

API call with file_gets_content() doesn't work with variables

for my final project I am trying to query a barcode database through via their API. When I hardcode the barcode and api key, everything works as expected but when I am using variables, ...
0
votes
1answer
1k views

Editable html table (PHP, MySQL) - doesn't save changes in database

For my final project, i'm trying to make my html tables editable by users, with updating data in MySQL. I've found in web a few js scripts for such case but no one works as needed. My result - ...
0
votes
1answer
504 views

pset7 register.php !isset() vs empty(): !isset() doesn't work

I am at register.php now. I will be grateful for explanation why !isset() doesn't do the job while empty() perfectly does. For example, if (empty($_POST["username"])) { apologize("Please, ...
1
vote
1answer
107 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? ...
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 = ...
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 ...
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
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 ...
0
votes
2answers
72 views

Pset7, is it using a different php version in 2017? Why do I see “$” when searching for help

Are we using a different version of Flask, SQLite or PHPliteadmin in 2017? Why are the codes i'm seeing in the web so different from mine..? Mainly, the $ sign, I've never used a single $.. Unless I'...
0
votes
1answer
258 views

PSET8 import fatal error

I've been trying to implement import and I've modified the file US.txt by replacing \t with " , " on each line just for a better practicality with my code. However, I receive the following error: ...
0
votes
1answer
174 views

PSET8 import undefined offsets and fatal error

I've been trying to implement import and I've modified the file US.txt by replacing "\t" with " , " on each line just for a better practicality with my code. However, I receive the following error: ...
0
votes
1answer
25 views

Final PHP/HTML Integration

I have a list of links that all link to the same page. I want to make it so that depending on which one of the links you click, the page will render differently. So for example, you're on list.php. ...
0
votes
1answer
40 views

Printing from SQL in PHP

I am trying to print text I have placed into a MySql database. I have been able to insert into the database, but I don't know what to put to take out the value/text <?php require("../includes/...
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 ...
0
votes
1answer
517 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
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
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
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
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
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 ...
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
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 ...
0
votes
1answer
51 views

What study material to go through in order to understand CS50.php

I have just got my final scores for my final project and would like to first thank all the members that helped in the last few months, now what next after cs50? I was kind of thinking to master php so ...
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, ...
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 ...
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 ...
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
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 ...
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 ...
0
votes
0answers
29 views

my code takes too long to execute

This loop here takes too long to be executed. Does it mean I am getting into an infinite loop? How can I fix it ? it is suppose to be reading from a csv file and storing them into an array then ...
0
votes
1answer
935 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
2answers
263 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
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
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++) ...
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
540 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
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 ...
0
votes
1answer
319 views

pset6: PHP Templating and Indexes

I've been bashing my head for a few hours now. I finally was able to pass the server1 check50 last night, but the server2 check50 is killing me. Source: server.c: :) server.c exists :) server ...
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 ...
0
votes
2answers
327 views

Pset 7 | C$50 Finance: query() undefined in register.php

I'm having an issue with register.php. When I try to run the file on my web server and press submit (no matter the inputs) I get this fatal error message: ( ! ) Fatal error: Call to undefined ...
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 ...
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) ...
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"); } ...