Jump to content

Armed Rebel

  • Posts

  • Joined

  • Last visited

Posts posted by Armed Rebel

  1. I beleive your connection is wrong.

    $dblocation = ""; $dbusername = ""; $dbpassword = ""; $dbdatabase = ""; $dbconn = mysql_connect("$dblocation","$dbusername","$dbpassword") or die ("Could not connect to MySQL");$lol = mysql_select_db($dbdatabase,$dbconn) or die ("Could not open database");

    Try that, again inputing your own details.

  2. You'll have to edit details, along with adding your db connection.

    <html><head><title>Register</title></head><body><?if ($_POST['submit']){	$un = $_POST['username'];	$pass = $_POST['password'];	$passc = $_POST['passwordc'];	$pass2 = $_POST['password'];	$un = stripslashes($un);	$pass = stripslashes($pass);	$passc = stripslashes($passc);		if ($un == "") { $error=true; }	if ($pass == "") { $error=true; }	if ($passc == "") { $error=true; }	if ($pass != $passc) { $error=true; }		if($error)	{  echo "The following errors have occured:<br /><ul>";  if ($un == "") { echo "There is no username.<br />"; }  if ($pass == "") { echo "There is no password.<br />"; }  if ($passc == "") { echo "There is no password confirmation.<br />"; }  if ($pass != $passc) { echo "Passwords don't match.<br />"; }  echo "</ul>";	}	else	{  $pass=md5($pass);  $sql="INSERT INTO users (username, password) VALUES ('$un', '$pass')";  $query=mysql_query($sql);  if($query)  { 	 echo "You are now registered, you can now <a href='login.php'>Login</a>.";  }  else  { 	 echo "There was a problem with registration, if the problem persists, please contact the admin";  }  exit;  	}}?>	<form action="" method="post"><table><tr><td>Username:</td><td><input name="username" type="text" maxlength="20" value="<? echo $_POST['username']; ?>" /></td></tr><tr><td>Password:</td><td><input name="password" type="password" maxlength="16" value="<? echo $_POST['password']; ?>" /></td></tr><tr><td>Confirm Password:</td><td><input name="passwordc" type="password" maxlength="16" value="<? echo $_POST['passwordc']; ?>" /></td></tr><tr><td><input type="submit" value="register" name="submit" /></td></tr></table></form></body></html>

  3. You'll just do an echo with the html code in it.echo "<a href='blah'>blah</a>";If you want to add variables to the url add a ?blah=blah to the url. If you want to add more, after the first ? add a & between them. so it'd be ?blah=blah&blah2=blahTo retreive the variables, you'd use $_GET['blah'] or $_GET['blah2'].

  4. I'm coding forums right now, and I've come to a problem with it.I'm trying to make links automatically link (so if a user typed in just "http://www.blah.com" it would link it).Here is my code, and you can view what happens here. It only gets the first letter after http://, and it messes up my sig.

    function markup($message){ 	 $find = array("<", ">"); 	 $replace = array("<", ">"); 	 $message=str_replace($find, $replace, $message); 	 $find=array("/\[img\](.+?)\[\/img]/",         "/\[link name=(.+?)\](.+?)\[\/link\]/",      "/\[link\](.+?)\[\/link\]/",       "/\[b\]([^$]*)\[\/b\]/",       "/\[u\]([^$]*)\[\/u\]/",       "/\[i\]([^$]*)\[\/i\]/",      "/\[quote\]\[originator=(.+?)\]([^$]*)\[\/quote\]/",      "/\[quote\]([^$]*)\[\/quote\]/",      "/\[sup\]([^$]*)\[\/sup\]/",      "/\[sub\]([^$]*)\[\/sub\]/",      "/\[div align=(.+?)\]([^$]*)\[\/div\]/",      "/\[size=(.+?)\]([^$]*)\[\/size\]/",      "/\[anchor\](.+?)\[\/anchor\]/",      "/\[color=(.+?)\]([^$]*)\[\/color\]/",      "/http\:\/\/(.+?)/"); 	 $replace=array("<img src=$1>",          "<a href='$2'>$1</a>",          "<a href='$1'>$1</a>",          "<b>$1</b>",          "<u>$1</u>",          "<i>$1</i>",         "<br /><ul>quote <b>$1</b><br /><hr />$2<hr /></ul><br />",         "<br /><ul>quote<br /><hr />$1<hr /></ul><br />",         "<sup>$1</sup>",         "<sub>$1</sub>",         "<div align=$1>$2</div>",         "<font size=\"$1\">$2</font>",         "<a name=\"$1\"\></a>",         "<span style=\"color:$1\">$2</span>",        "<a href='http://$1'>http://$1</a>"); 	 $message=preg_replace($find, $replace, $message); 	 $message=nl2br($message); 	   return $message;}

    Look at the last two array entries.

  5. When you are linking to them, add a GET variable to them.So, the url would be "...index.php?poem=2"Then, in your code:

    if($_GET['poem']==2){      [Poem]}

    You'll have to edit it to your liking, but that is the general idea.

  6. IF you're getting that message then your connection details are inncorrect. Check with your host to make sure that it is correct. Just for the record, when I connect to my dbs, I use localhost for the location, you may want to try the same.

  7. Try this:

    $dblocation = ""; $dbusername = ""; $dbpassword = ""; $dbdatabase = ""; $dbconn = mysql_connect("$dblocation","$dbusername","$dbpassword") or die ("Could not connect to MySQL");$selectdb = mysql_select_db($dbdatabase,$dbconn) or die ("Could not open database");//Make sure that $em has a value$sql="INSERT INTO subscribe (em,status) VALUES ('$em', 'subscribe')";$query=mysql_query($sql);if($query){     echo "Subscription has been completed successfully";}else{     echo "Subscription has NOT been completed successfully";}

    I'll be bold enough to say that that will work.

  8. You'd end up having to change the values to your specifications:

    $get_img=mysql_fetch_array(mysql_query("SELECT img_url FROM tablename"));// You can split this up into three steps if you want, but it isn't neccesary.echo "<img src='$get_img[img_url]' />";

    Providing it is alreayd in your database.

  9. If you already have your connection:Try

    $query="INSERT INTO subscribe (em,status) VALUES ('$em', 'subscribe')";

    You also may as well just make $result a cut and dry function, there isn't a need to put it in a variable (with your script, at least)

  • Create New...