I am trying to learn php to access an sql database. I have tried a number of small scripts trying to make something work. So far I hit a wall.
MY current script is generating the following error message:
[php]Parse error: syntax error, unexpected T_STRING in /home/content/x/x/x/xxxxxxxx/html/phptest/newtest.php on line 7[/php]
Line 7 is the Create table command line -
The script is:
[php]<?php
// Connects to your Database
mysql_connect(“xxxxdata.db.9927794.hostedresource.com”, “username”, “xxxxxxxxxx”) or die(mysql_error());
mysql_select_db(“sengdata”) or die(mysql_error());
// create new table
//
CREATE TABLE friends (name VARCHAR(30), favcolor VARCHAR(30), favfood VARCHAR(30), pet VARCHAR(30));
//
// CREATE TABLE Persons (P_Id int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255))
//
INSERT INTO friends VALUES ( “Rose”, “Pink”, “Tacos”, “Cat” ), ( “Bradley”, “Blue”, “Potatoes”, “Frog” ),
( “Marie”, “Black”, “Popcorn”, “Dog” ), ( “Ann”, “Orange”, “Soup”, “Cat” )
//
// Collects data from “friends” table
$data = mysql_query(“SELECT * FROM friends”)
or die(mysql_error());
//
// puts the “friends” info into the $info array
$info = mysql_fetch_array( $data );
// Print out the contents of the entry
Print "Name: ".$info[‘name’] . " ";
Print "Pet: ".$info[‘pet’] . "
";
?> [/php]
I have had this same problem with several scripts and hit the same problems every time. I just want to get something working on MY database, then I can go from there.
this one just a learning script but in the end,
I am trying to create a simple php script that will allow me to enter an email name and then access my sql database and search for it. If it is there, say “the name is there” or if not there say this is a “new email name”.
Thanks for any and all Help
Randy