Jump to content

davef

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

davef's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. well, the quotes did help with that. is the following "line 6"? mysql_select_db($mx) or die("Can't select database");
  2. Thanks. I am putting in the actual server, username and password in the code, just not on what I post here. And after putting quotes around the database name the dot / . in it is now recognized properly, yielding the same error message in both attempts at coding. Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in /hermes/web04/b1964/david/test000.php on line 6 Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_VARIABLE or '$' in /hermes/web04/b1964/david/suma.php on line 6 Although these coding attempts were provided by kind folks on these forums, you're right, I was cutting and pasting (it was an effective way to learn html), but only after failing to get the tutorials-- I did go through the one you suggested-- to understand them or to get their examples to work. Still, with what I've picked up in the forums, I will go back to the tutorials and/or get a book, especially since I can bring questions from them to here. Thanks again.
  3. here's another version with its error message and the error message taken from the screen when i "run"/view the file.I am sure that i am viewing the same file coded here. [code=php:0] <?PHP $db_host = 'david.hostsmysql.com'; $db_user = 'username'; $db_pwd = 'dddddddd'; $database = 'mx'; mysql_connect($david.hostsmysql.com,$usern,$dddddd) or die("Can't connect to database"); mysql_select_db($mx) or die("Can't select database"); $result = mysql_query("SELECT * FROM contact1") or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows>0) { while($row=mysql_fetch_array($result)) { echo "First name: " . $row['firstname1'] . "<br>"; echo "Last name: " . $row['lastname1'] . "<br>"; echo "Phone: " . $row['phonenumber1'] . "<br>"; echo "Email: " . $row['email1'] . "<br>"; echo "Website: " . $row['website1'] . "<br>"; echo "<hr>"; } } ?> [/code] Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /hermes/web04/b1964/david/test000.php on line 6
  4. Right, here's the code in its entirety, with just a bit of scrambling on the host, username, etc I was putting in the actual info and taking out the xxxxx. THANKS for your efforts. I don't feel so bad about my difficulties. Why is it so hard? Php is a lot more complex than html. Is there a good way to learn it? book? [code=php:0] <?PHP $db_host = 'david.hostsmysql.com'; $db_user = 'username'; $db_pwd = 'ddddddddd'; $database = 'mx'; mysql_connect($db_david.hostsmysql.com,$db_username,$db_username) or die("Can't connect to database"); mysql_select_db($mx) or die("Can't select database"); $result = mysql_query("SELECT * FROM contact1") or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows>0) { while($row=mysql_fetch_array($result)) { echo "First name: " . $row['firstname1'] . "<br>"; echo "Last name: " . $row['lastname1'] . "<br>"; echo "Phone: " . $row['phonenumber1'] . "<br>"; echo "Email: " . $row['email1'] . "<br>"; echo "Website: " . $row['website1'] . "<br>"; echo "<hr>"; } } ?> [code] and here is the error message Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'hostsmysqlcom' (1) in /hermes/web04/b1964/david/suma.php on line 6 Can't connect to database[/code]
  5. yes, but there wasn't a problem connecting with the host before i put the db_ in front of the host address
  6. thanks when i insert db_ before the host ,username and password, db_xxxxxx below, (that's what you recommended i think) i get: Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'hostcom' (1) in /hermes/web04/b1964/david/suma.php on line 6 Can't connect to database
  7. Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /hermes/web04/b1964/violet/test000.php on line 6 <?PHP $db_host = 'xxxx'; $db_user = 'xxx'; $db_pwd = 'xxx'; $database = 'mx'; mysql_connect($xxxxx,$xxx,$xxxxxx) or die("Can't connect to database"); mysql_select_db($mx) or die("Can't select database"); $result = mysql_query("SELECT * FROM contact1") or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows>0) { while($row=mysql_fetch_array($result)) { echo "First name: " . $row['firstname1'] . "<br>"; echo "Last name: " . $row['lastname1'] . "<br>"; echo "Phone: " . $row['phonenumber1'] . "<br>"; echo "Email: " . $row['email1'] . "<br>"; echo "Website: " . $row['website1'] . "<br>"; echo "<hr>"; } } ?> thanx
  8. litebearer saving that code as .php I get: Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /hermes/web04/b1964/violet/display2.php on line 11 here's the code with the server, user name , password xxxxxxxxxed out <?php $db_host = 'violet.bizlandmysql.com'; $db_user = 'dravef'; $db_pwd = '10801080'; $database = 'mx'; $table = 'contact1'; if (!mysql_connect($violet.bizlandmysql.com,$dravef,$10801080)) die("Can't connect to database"); if (!mysql_select_db($mx)) die("Can't select database"); <?PHP $db_host = 'xxx'; $db_user = 'xxxx'; $db_pwd = 'xxxxx'; $database = 'mx'; if (!mysql_connect($xxxx,$xx,$xxx)) die("Can't connect to database"); } if (!mysql_select_db($mx)){ die("Can't select database"); } $result = mysql_query("SELECT * FROM contact1") or die(mysql_error()); $num_rows = mysql_num_rows($result); if($num_rows>0) { while($row=mysql_fetch_array($result)) { echo "First name: " . $row['firstname1'] . "<br>"; echo "Last name: " . $row['lastname1'] . "<br>"; echo "Phone: " . $row['phonenumber1'] . "<br>"; echo "Email: " . $row['email1'] . "<br>"; echo "Website: " . $row['website1'] . "<br>"; echo "<hr>"; } } ?>
  9. when i save it as .php i get Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /hermes/web04/b1964/david/display.php on line 61 yes, i also have spent hourrrrrrsssss and i have the maddening feeling that it is something like a ;
  10. the rest of the code i've been trying (the latest) is $num=mysql_numrows($result); $i=0; while ($i < $num) { $firstname1=mysql_result($result,$i,"firstname1"); $lastname1=mysql_result($result,$i,"lastname1"); $phonenumber1=mysql_result($result,$i,"phonenumber1"); $email1=mysql_result($result,$i,"email1"); $website1=mysql_result($result,$i,"website1"); echo "<b>$firstname1$lastname1</b><br>Phone: $phonenumber1<br>E-mail: $email1<br>Web: $website1<br><hr><br>"; $i++; } ?> </body> </html>
  11. database name- mx table name- contact1 5 fields in order: firstname1 lastname1 phonenumber1 email1 website1 Thanks! (just in case)
  12. i'm trying to get a php database to output/display on a html webpage and have no results from cutting and pasting code from online tutorials i'm saving to a file with a htm extension i believe i have the connection data right: $db_host = 'server'; $db_user = 'username'; $db_pwd = 'password'; $database = 'database'; $table = 'table'; if (!mysql_connect($server,$username,$password)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT * FROM table") or die(mysql_error()); Can someone please help me? send code? tell me what i'm doing wrong? Thanks
×
×
  • 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.