Jump to content

Recommended Posts

hi there,

I'm teaching myself how to write PHP scripts for inserting and retrieving data from a MySQL database that I'm using with 1&1.

The test script I am using is below but when I host this onto my FTP server all I get is the code itself rather than the result. This is realyl frustrating me as I don't know where I'm going wrong. Hope someone can help me.... (I have replaced my localhost name, username and password with the correct one for my databse as didn't want to write it below for security reasons)


<?php
$conn = mysql_connect("localhostname", "username",
"password");
mysql_select_db("db191523061"$conn);
$sql = SELECT * FROM Events";
$result = mysql_query($sql, $conn) or die(mysql_error());
$number_of_rows = mysql_num-rows($results);
echo "The number of rows is $number_of_rows";
echo $conn;
mysql_close($conn);
?>


According to the book I'm learning from I should see the result - 'The number of rows is 2' in my browser once it has been put onto my webserver but I don't . I just see the written code as above.

Please help!!

Thanks.

Rich
Link to comment
https://forums.phpfreaks.com/topic/34114-cant-see-my-php-scripts/
Share on other sites

Does the file you are running ending with .php? Also does your 1&1 hosting account allow you to use PHP?

If you are learning PHP it is best to install Apache, PHP and MySQL on your computer locally. This saves you from have to upload to your host and you can learn PHP whilst off-line. There is a package you can install called WAMP (Windows Only) or XAMMP (for Macs and Linux).
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.