3
votes
Accepted
Pagination using mysql and php
Yes, there are many solutions.
If with "recent entries" you mean "sorted by date" (or with sequential indexed IDs), all you need to do is :
Define a variable called $last_id = 0;
Use a SELECT ...
3
votes
Extra feature to send receipts - PHP Mailer not connecting
The problem is really about host(smtp.fas.harvard.edu),
I had the same problem and here is my decision:
I created a new mailbox at gmail, and used it like this:
/*Sends a message of $body with ...
3
votes
Accepted
How Does extract() Work in PHP?
I just wanna make sure, does extract() declare these variables as global variables?
Not necessarily. The description of extract() reads, "Import variables from an array into the current symbol table."...
3
votes
How to link submit button with the <select> list in HTML?
You can achieve that using JavaScript:
<div>
<h1>SELECT A TOPIC</h1>
<select id="select">
<option value="physics">physics</option>
<option value="...
3
votes
phpMyAdmin: "mysql extension missing" error
We all know that phpMyAdmin can be flaky sometimes. Unfortunately, I can't tell you how to fix it -- but I can tell you how to use mysql50 shell from the command line. Try stuff like this:
mysql50 ...
2
votes
Accepted
How Does PHP Construct Variables and Store Data in Them?
Toward the end of the last century (early 1990's) a common way for web servers to talk to programming languages was by using the Common Gateway Interface (CGI). CGI is very simple and works in a way ...
2
votes
How Does PHP Construct Variables and Store Data in Them?
When we submit form data to a URL or a page using either of these methods (i.e., GET and POST), how does this web page receive this data underneath the hood?
GET and POST are two request methods of ...
2
votes
Accepted
How to create a drop-down menu that contains the stocks that has as options?
First, for closed tags, if you open a tag, you should close it. I see you're not closing the <select> tag. More information about that tag maybe found here.
Also, you have </div> within ...
2
votes
Accepted
How to determine how much cash a user has in C$50 Finance's portfolio.php
Yes your logic is correct, and this is exactly the way the world works.
Say I have $20.
I buy a diamond for $10.
So now I have $10 left.
In a week from now, the same diamond, costs $5.
But I still ...
2
votes
Accepted
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?
search is just a path that Google's web servers use as an entry point into the search engine. Behind ...
2
votes
Accepted
Question about "echo", "print", "printf" in php
here's a good link which shows you the differences: http://www.nutt.net/2004/12/09/php-benchmarking-echo-vs-print-vs-printf/
2
votes
pset8 (mashup) - Inserting $places variable into configure function in scripts.js
I figured it out. <%= ... %> is indeed the way you pass in arguments to _.template. When I watched the video in the problem set again the prof mentioned how this code operates similarly to the "%i" ...
2
votes
Accepted
register php pset7 query to INSERT do not work
Such a subtle thing. Your are inserting 3 columns (username, hash, cash). The computer thinks you are sending 4 values because of the comma in your cash amount. VALUES(?, ?, 10000,00)
2
votes
Accepted
When I run my apache50 server at ~/workspace/pset7/public why does login.php files open?
From the pset instructions:
Know that index.php is the
file that’s loaded by default when you visit a URL like https://ide50-username.cs50.io/.
...which calls (redirects to) login.php (via ...
2
votes
include 'file.php' does not seem to work
You've probably gotten used to using #include statements in C. The equivalent function in PHP is require(). If you have access to pset7 or pset8, just look at the distribution code provided. You'll ...
2
votes
Accepted
2
votes
cs50::init(_DIR_."/../config.json") pset7
To answer the specific question from your comment "why is :: used?"
From the config section of the spec
(That :: syntax just means that init is "inside of" an "object" called CS50. An object in ...
1
vote
Accepted
Looking at the course, could I use PDO instead of mysql?
as you reach pset7, the first pset that you are going to interact with a database in it, you won't have to write your own code to connect with your database. instead, there is a query function ...
1
vote
Accepted
PSET8 import undefined offsets and fatal error
The problem is your input data. Your query is expecting 12 values on every line. The first line in your example has 9. You "lost" the blank columns from the text file, presumably when you converted ...
1
vote
Accepted
PSET8 import fatal error
The problem is your insert query. You are inserting 12 columns, you have 12 ? placeholders, but you are sending 13 arguments.
Also, beware: implode returns a string. So you $str_values[0] et. al. ...
1
vote
Printing from SQL in PHP
recall that, assuming the query is syntactically correct, query returns an array of the resulting rows (if any) or an empty array otherwise. try print_r'ing $comment to learn about the structure of ...
1
vote
Accepted
pset7 php generated html appearing above CS50 finance header
Ignore this,
It was actually fixed very easily by switching the order of the render function and the array loop.
Doh!
1
vote
Accepted
Escaping Characters in PHP
the first argument that preg_match takes according to the documentation is a pattern. that is, a regular expression to test $destination against in this case.
the forward slashes (i.e., /) at the ...
1
vote
Accessing information from PHPmyadmin using Javscript
This is the answer from Kareem's link. Please do not vote on this. I just want to take this answered question out of the unanswered list.
There are actually several approaches to do this. Some ...
1
vote
Accepted
Finance: Buy/Sell does not insert into MySQL history table
Try checking your index+ link on the Structure view. I deleted all my unique and primary keys, as well as any links to other tables. This solved the problem..thanks to Kareem .. and, I apologise for ...
1
vote
Array in php vs R (pset7 sell.php)
Just like _POST your positions is an associative array. Just as you get $_POST["symbol"] you get $positions["price"].
If I understood correctly you want to do something like the following
<?php
...
1
vote
Accepted
CSS Table Gradient Not Working
I made something simple but I think you can tinker further on your own:
grad.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style....
1
vote
Accepted
Path to PHP Interpreter
If I understand correctly you mean the path to php interpreter so that to use a #! to make it executable. It's #!/usr/bin/env php.
1
vote
Path to PHP Interpreter
I think the simplest answer is php <filename>.
So if you have a php file called hello.php that looks like this:
<?php
printf("Hello, world!\n");
?>
you would run php hello.php and you'd ...
1
vote
Accepted
How to Redirect Only When a User Clicks Ok on a Popup?
If you want to use the redirect() function provided in pset7 I'm not sure how, but in general you can do it like so:
echo "<script type='text/javascript'>
if (confirm('Want to redirect?'...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
php × 80pset7 × 37
mysql × 13
finance × 11
html × 10
sql × 6
pset8 × 5
final-project × 5
import × 4
javascript × 3
query × 3
portfolio × 3
final × 3
css × 3
appliance × 2
cs50-ide × 2
array × 2
sell × 2
debug × 2
syntax × 2
portfolio.php × 2
phpmailer × 2
get × 2
form-data × 2
pset6 × 1