Jump to content

Hello, I am completely lost..need help with php and mysql


Recommended Posts

Hello, I am having trouble with a script.  I'm pretty sure it is correct, but it keeps shooting me a syntax error "t_variable" im not sure what that means.  All im tryna do is, setup a site which information can be entered, and i want that info to go to a table in mysql....and it just wont work....any suggections

 

 

<html><head><title>Adding a User </title></head>
<body>
<?php
if( (!$firstname) or (!$lastname) or (!$username) or (!$password) )
{
$form ="Please enter all new user details";
$form.="<form action=\"$PHP_SELF\"";
$form.=" method=\"post\">First Name: ";
$form.="<input type=\"text\" name=\firstname\"";
$form.=" value=\"$firstname\"><br>Last Name: ";
$form.="<input type=\"text\" name=\"lastname\"";
$form.=" value=\"$lastname\"><br>UserName: ";
$form.="<input type=\"text\" name=\"username\"";
$form.=" value=\"$username\"><br>PassWord: ";
$form.="<input type=\"text\" name=\"password\"";
$form.=" value=\"$password\"><br>";
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>";
echo($form);
}
else
{ $conn = mysql_connect("mysql4.000webhost.com")or die("Try Again Punk");
  $db = mysql_select_db("a3213677_snorre",$conn)or die("NOOPE")
  $sql = "insert into User Table(first_name,last_name,user_name,password) values(\"$firstname\",\"$lastname\",\"$username\",password(\$password\") )";
  $result = mysql_query($sql,$conn)or die ("NOT EVEN");
  if($result) { echo("New User $username ADDED DUH!"); }
}
?> </body></html>

 

LINE 24 has the problem

I tried out the code it seems to work when I added the semicolon at this line ?

 

$db = mysql_select_db("a3213677_snorre",$conn)or die("NOOPE");

]

 

i copied and pasted what u just sent me....and now its giving me a t_string....everytime i change it theres a new syntax

Where are you testing this? A local PC? Live web hosting?

 

yea its webhost, and its has a server/database of its own with a mysql, and i want this info to go into the mysql tables, and for some reason i dont know what im doing wrong cause ive tried many times

Live web servers often have disk caching setup with long TTL (time to live) settings that prevent checking for file changes. You would need to output no caching settings for all your files and then wait for the cache to be cleared out so that the no caching setting applies.

 

You should be learning php, developing php code, and debugging php code on a local development system. You will save a ton of time in the development cycle.

Live web servers often have disk caching setup with long TTL (time to live) settings that prevent checking for file changes. You would need to output no caching settings for all your files and then wait for the cache to be cleared out so that the no caching setting applies.

 

You should be learning php, developing php code, and debugging php code on a local development system. You will save a ton of time in the development cycle.

 

i have a small company, and all i want is a basic thing that sends info to that database....theres no way i can fix this? there are no cache settings on webhost.  is there a different possible code i can use to relay simple information from website to a datebaste

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.