Questions tagged [php]

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

0
votes
1answer
783 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
2answers
66 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
22 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
300 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
31 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
44 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
103 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
29 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
57 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: ...
1
vote
1answer
73 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
45 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, ...
1
vote
2answers
51 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
154 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 ...
0
votes
0answers
22 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
363 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
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
35 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
59 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
61 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
364 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
431 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
1answer
87 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 ...
0
votes
2answers
137 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 ...
0
votes
1answer
26 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
2answers
216 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
100 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
206 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
115 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(".....
0
votes
1answer
60 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
134 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
2answers
2k 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
1answer
65 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
53 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:...
0
votes
1answer
318 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 ...
1
vote
1answer
221 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.
2
votes
2answers
232 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
1answer
348 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
2answers
598 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
63 views

issue getting select form working in pset7 sell

I can't get the select form list to show the company's ticker symbol. I've tried various combinations of quotes and braces. Below is part of my controller file and my views file. Any thoughts? ...
0
votes
1answer
28 views

Looking at the course, could I use PDO instead of mysql?

Ok so I haven't enrolled or anything yet, but the course really interests me. I wanted to know if I could use PDO instead of mysql when interacting with the database in PHP? I have a lot of self-...
0
votes
1answer
173 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
257 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
26 views

Final Project not Redirecting

I want to use the skeleton of pset7 for my final project, however I can't get the index to redirect to any other page. I get this phpinfo() page, and when I try to put code in index.php to redirect ...
1
vote
3answers
138 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
31 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/...
0
votes
1answer
359 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
77 views

pset7 php generated html appearing above CS50 finance header

I'm working through pset 7, Every time I render and generate html in the controller it appears above the header on the generated page, I can't for the life of me get it to stop. here's to code. <...
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 ...
0
votes
1answer
14 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 / ...