Newbie Help

Ok, I’m reading about hashing and md5. I understand the need for security and will implement as I continue here. But Kevin’s last post does not tell me how to extrapilate a field from a recordset. Let’s pretend it’s not the login but an product that is on an invoice that I want to display.

Now I would have…
$str=“Select * From tbl_Invoices Where Inv=100”;
$stmt = $pdo->prepare($str);
$stmt->execute();
$rst = $stmt->fetchAll();

echo “
FirstName=” . $rst[Product1];

I know that the echo line is incorrect because nothing prints to the screen. What is the correct syntax to the value of “Product1”?

Also, how do I thank both of you for your help?

You should turn on error reporting. You are missing quotes:

echo “
FirstName=” . $rst[‘Product1’];

It can also be done as

echo “
FirstName={$rst[‘Product1’]}”;

You should download the PDO Bumpstart database I have provided. It will help you.
http://www.phphelp.com/forum/the-occasional-tutorial/beginners-pdo-bumpstart-code-use-it-now!

But Kevin's last post does not tell me how to extrapilate a field from a recordset.

The code I gave you absolutely will show a record. Where the print_r is, is where you would echo your rows.

[php] foreach ($result as $row)
{
//echo ‘

’;
//print_r($row);
//echo ‘
’;
        echo $row['your_column_name'];
         }[/php]

MD5 shouldn’t be used for passwords. Look into Bcrypt or Pbkdf2

This…
echo “RSTCOUNT=” . count($rst);
echo “
FirstName=” . $rst[‘FirstName’];

Gave me…
RSTCOUNT=1
FirstName=

And the field in the db is called “Product1”. Why is this not printing to the screen?

Jim: I am reading about Bcrypt/Pdkdf2

Was it something I said? I forgot to change the ‘FirstName’ to Product1 when I pasted. Here is what I have along with the display…

$str=“Select * From tbl_Products”;
$stmt = $pdo->prepare($str);
$stmt->execute();
$rst = $stmt->fetchAll();

echo “RSTCOUNT=” . count($rst);
echo “
Product1=” . $rst[“Product1”];

RSTCOUNT=1
Product=

So if it is returning 1 record why is it not displaying?

Also, I am try to use the pdo_bumpstart and using workbench for mysql work.
-created pdo_bumpstart in www
-created schema in mysql
-open my connection and select pdo_bumpstart schema
-select the “open a script file in this editor” and select the pdo_bumpstart.sql and I get the script to create the users table with 3 users.
-click the lightning bolt and got 7 actions including creating table users, inserting 3 records and seleting all from the table returing 2 records.

The problem is there is no table users in the schema. What happened here?

Thank you for your help.

The bumpstart is just to get you going with a working PDO database. Now that you have that setup, import YOUR tables to the same database and use the bumpstart code as an example of how to access YOUR records.

OMG! I love linux but this is getting to be rediculous to build 1 website.

I got the bumpstart with the tbl_customers into it. Tried to friggin look at the pdo_bumpstart/index.php and got this…

Forbidden

You don’t have permission to access /pdo_bumpstart/index.php on this server.

WTF! I have a couple of personal sites I have been bulding, trying to learn a little php on this machine. Now I am trying to actually put together a site for my startup company and I keep running into this BS. No offense meant here Kevin and I appreciate all the help and support and will continue to learn as time permits. Aside from storing passwords in the db (which I am still trying to learn-a ton of reading on the internet and it doesnt help when you do not have a site that you can work with) the code you gave me that should display a single field does NOT work. I do not have 6 wks to figure this out. If I can get that 1 thing to work I can at least continue building my site and learn as I go. I am sorry but I am beyond frustrated as I put in 13 hour days and come home hoping to get the site moved forward only to run into more of the same frustration. If I can simply get 1 friggin data field to display at least I can get all my maintenance pages working while I learn about the passwords and encrypting.

Seems like the web server user doesn’t have appropriate access to the file/folder.

If you aren’t comfortable/don’t have time to manage your own dev environment then just get a hosting plan and use that, then you’ll have customer service to help out with all server related problems.

Jim is right, that is a server issue and nothing to do with the script. You need to learn about Linux file permissions. Hang in there. There are a LOT of different things to know to be a programmer than just php.

If you really want to speed up your learning, nothing better than a one on one tutor. If your interested, we can work something out for live training. I can do a direct connection to your machine and teach you right where you work on it while we are on the phone or skype. A few hours of one on one where you can ask questions will speed you right along. Otherwise, you will have to continue the trial and error way of learning.

I can be available at any hours to fit your schedule.

Kevin,

I was an asp programmer for 12 years but life has forced me to change career paths 2 yrs ago. I simply need to get the login page running and need to get 1 of the maintenance pages going. If I have the ability to display data I should be able to figure out fairly easily how to add, edit and delete. I am just confounded that I have a recordset (knowingly display a record count) but cannot print a field to the screen.

I do have a website that I can upload to for a temp solution but that creates a few extra steps every time you need to test (save, switch to ftp, upload, browser, reload, etc.). I would love to have this available on my local machine to make coding faster. I am open to allowing access to my machine. What do you charge?

Keith

I will give you a discounted rate for the fist two hours @ $20 per hour. It will be well worth it and you will learn a lot fast especially since you have programming experience in another language.

Sponsor our Newsletter | Privacy Policy | Terms of Service