Jump to content

Shaun13

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

Posts posted by Shaun13

  1. Ok, so I am having some user-inputed data inserted into the table "nav_links" and it outputs this error:

     

    Unknown column 'h' in 'field list'

     

    I have got the area down to this piece of code.

     

    elseif($_GET['do'] == 'add_link')
    {
    $id = $_GET['cat'];
    if($_GET['go']=='true')
    	{
    	$link_name = $_POST['link_name'];
    	$url = $_POST['url'];
    
    	if(empty($link_name))
    		{
    		$error_txt = 'Enter a link title.';
    		}
    	elseif(empty($url))
    		{
    		$error_txt = 'Enter a URL.';
    		}
    	else
    		{
    		$max = mysql_query('SELECT MAX(id) FROM nav_links');
    		$max_array = mysql_fetch_array($max);
    		$max_id = $max_array['MAX(id)'] +1;
    		$query = mysql_query('INSERT INTO `nav_links` (`id` ,`cat_id` ,`url` ,`name`) VALUES ('.$max_id.', '.$id.', '.$url.', '.$link_name.')');
    		if($query)
    			{
    			$error_txt = 'Link Added Successfully.';
    			}
    		else
    			{
    			$error_txt = mysql_error();
    			}
    		}
    	}

     

    Any help?

     

    Thanks in advance,

     

    ~Shaun

  2. I am creating an install script for people to use my software. Heres the problem:

     

    Here is the part of the script we are lookign at:

     

    	$file1 = fopen("mysql_info.php","w");
    		echo fwrite($file1,"
    		<?php 
    		// ===========================
    		// whats my database info?
    		// ===========================
    		$host2=".$host1."; // Host name 
    		$username2=".$username1."; // Mysql username 
    		$password2=".$password1."; // Mysql password 
    		$db_name2=".$database1."; // Database name 
    
    		 ?>");
    		fclose($file1);

     

    Ok, heres the problem. It is thinking that $host2, $username2, etc.. are variables I have set, and obviously on mysql_info.php, all I end up with is:

     

    <?php 
    		// ===========================
    		// whats my database info?
    		// ===========================
    		=somehost; // Host name 
    		=someusername; // Mysql username 
    		=someonespassword; // Mysql password 
    		=someonesdatabasename; // Database name 
    
    		 ?>

     

     

    Any Help?

     

    ~Shaun

     

  3. Hi, I am creating a forum and I was wondering how I could create a users online legend at the bottom of the index. I tried something like echo "$myusername" and it will only display your username. How could I accomplish this?

     

    ~Shaun

  4. Here is a snipet from a script I have.

     

    	elseif($action == "reply")
    	{
    	$topicid=$_POST['topicid'];
    	$sql8="SELECT MAX(answerid) AS Maxanswerid FROM $tablereplies";
    	$result8=mysql_query($sql8);
    	$rows8=mysql_fetch_array($result8);
    
    	if ($rows8) 
    		{
    		$Maxid = $rows8['Maxanswerid']+1;
    		}
    	else 
    		{
    		$Maxid = 1;
    		}
    	$myusername=$_SESSION['myusername'];
    	$mydisplayname=$displayname;
    	$content=$_POST['content'];
    	$author=$myusername;
    	$authordisplay=$displayname;
    	$datetime=date("m/d/y H:i:s"); // create date and time 
    
    	$sql9="INSERT INTO $tablereplies(questionid, answerid, author, authordisplay, content, datetime)VALUES('$topicid', '$Maxid',  '$author', '$authordisplay', '$content', '$datetime')";
            $result9=mysql_query($sql9);
    
    	if($result9)
    		{
    		$topicid2=$_POST['topicid'];
    		$sql14="SELECT MAX(answerid) AS Maxreplies FROM $tablereplies WHERE questionid='$topicid2'";
    		$result14=mysql_query($sql14);
    		$rows14=mysql_fetch_array($result14);
    
    		echo "<br><br>Successful<BR>";
    		echo "<a href='index.php?viewtopic=".$topicid."'>View your answer</a>";
    
    		if ($rows8) 
    			{
    			$Maxreplies = $rows14['Maxreplies']+1;
    			}
    		else 
    			{
    			$Maxreplies = 1;
    			}
    
    		$sql10="UPDATE $tableposts SET posts='$Maxreplies' WHERE id='$topicid'";
    		$result10=mysql_query($sql10);
    
    		}
    	else 
    		{
    		echo "ERROR";
    		}
    
    	}

     

    This is called when a user submits an answer to a topic. What I want it to do is update the number of replies (posts) in a topic to the MAX(answerid) for a topic (topicid) and then add 1 to that. What it is doing is adding 1 to the MAX(answerid) for ALL topics. SO if a topic's, say id 1, MAX(answerid) is 2 and topic 2's MAX(answerid) is 7, when someone adds a reply to topic 1, the number of replies (posts) is updated to 8, not 3.

     

    I hope this makes sense. Any help is appreciated.

     

    ~Shaun

  5. Ok, so how does a forum like this break this word:

     

    1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

     

    EDIT: Lol, nvm.

  6. Ok, i checked out the wrapword function and it isn't what I am looking for because what I want to do is make it so the content of something a user submits, if it is too long, won't stretch out the table, it will make a break. I need this because quite obviously 100 "1"s will be much less width than 100 "W"s.

     

    All-in-all, is there anyway to make a wordwrap if the word is longer than the table width?

     

    ~Shaun

  7. Ok, i checked out that wordwrap thing, thanks, but it isn't working for me. Heres what I have:

     

    	$sql3="SELECT * FROM $tablereplies WHERE questionid='$id' ORDER BY answerid";
    $result3=mysql_query($sql3);
    
    while($rowsanswers=mysql_fetch_array($result3))
    	{
    	$replycontent=$rowsanswers['content'];
    	$replycontentwrap = wordwrap($replycontent, 200, "<br />\n");
    	echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'>
    	<tr>
    	<td><table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#000000'>
    	<tr>
    	<td bgcolor='#F8F7F1' align='center'><strong>".$rowsanswers['authordisplay']."</strong></td>
    	<td bgcolor='#F8F7F1'>".$rowsanswers['datetime']."</td>
    	</tr>
    	<tr>
    	<td bgcolor='#ffffff' width='20%'>User information will eventually go in here. Area under construction.</td>
    	<td bgcolor='#ffffff' width='80%'>".$replycontentwrap."</td>
    	</tr>
    	</table></td>
    	</tr>
    	</table><br>";
    	}

  8. Ok, I have a script and I have information that a user enters being displayed. I have the information being displayed in tables, but if what you enter is longer than the table, the table gets wider and you have to scroll right to see the whole thing, how can i fix it? Here is the part of the script i am talking about.

     

    if(isset($_REQUEST['viewtopic']))
    {
    echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'>
    <tr>
    <td><table width='900' border='0' cellpadding='3' cellspacing='1' bordercolor='1' bgcolor='#000000'>
    <tr>
    <td align='center' bgcolor='#ccddcc' colspan='2'><strong>".$rows2['title']."</strong>
    </tr>
    <tr>
    <td bgcolor='#F8F7F1' align='center'><strong>".$rows2['authordisplay']."</strong><br>
    <td bgcolor='#F8F7F1'>Date/Time : ".$rows2['datetime']."</td>
    </tr>
    <tr>
    <td bgcolor='#Ffffff' width='200'>User information will eventually go in here. Area under construction.</td>
    <td bgcolor='#Ffffff' align='top'>".$rows2['content']."</td>
    </tr>
    </table></td>
    </tr>
    </table>
    <BR>";
    
    $sql3="SELECT * FROM $tablereplies WHERE questionid='$id' ORDER BY answerid";
    $result3=mysql_query($sql3);
    while($rowsanswers=mysql_fetch_array($result3))
    	{
    	echo "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#ffffff'>
    	<tr>
    	<td><table width='900' border='0' cellpadding='3' cellspacing='1' bgcolor='#000000'>
    	<tr>
    	<td bgcolor='#F8F7F1' align='center'><strong>".$rowsanswers['authordisplay']."</strong></td>
    	<td bgcolor='#F8F7F1'>".$rowsanswers['datetime']."</td>
    	</tr>
    	<tr>
    	<td bgcolor='#ffffff' width='200'>User information will eventually go in here. Area under construction.</td>
    	<td bgcolor='#ffffff' width='700'>".$rowsanswers['content']."</td>
    	</tr>
    	</table></td>
    	</tr>
    	</table><br>";
    	}
    
    if(isset($myusername))
    	{
    	echo "<table width='400' border='0' align='center' cellpadding='0' cellspacing='1' bgcolor='#CCCCCC'>
    	<tr>
    	<form name='reply' method='post' action='index.php?action=reply'>
    	<td>
    	<table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#FFFFFF'>
    	<tr>
    	<td valign='top'><strong>Post</strong></td>
    	<td valign='top'>:</td>
    	<td><textarea name='content' cols='45' rows='3' id='content'></textarea></td>
    	</tr>
    	<tr>
    	<td> </td>
    	<td><input name='topicid' type='hidden' value='".$id."'></td>
    	<td><input type='submit' name='Submit' value='Submit'> <input type='reset' name='Submit2' value='Reset'></td>
    	</tr>
    	</table>
    	</td>
    	</form>";
    	}
    elseif(!isset($myusername))
    	{
    	echo "<a href='index.php?action=login'>Login</a> to reply to topics!";
    	}
    
    $sql4="SELECT views FROM $tableposts WHERE id='$id'";
    $result4=mysql_query($sql4);
    $rows4=mysql_fetch_array($result4);
    $views4=$rows4['views'];
    
    if(empty($views4))
    	{
    	$views4=1;
    	$sql5="INSERT INTO $tableposts(views)VALUES('$views4') WHERE id='$id'";
    	$result5=mysql_query($sql5);
    	}
    
    $addview=$views4+1;
    $sql6="update $tableposts set views='$addview' WHERE id='$id'";
    $result6=mysql_query($sql6);
    }

     

    Any help?

     

    ~Shaun

  9. I have a small question about a MySQL Query:

     

    Here is a small section of code from my script:

     

    elseif($action == "reply")
    	{
    	$topicid=$_POST['topicid'];
    	$sql8="SELECT MAX(answerid) AS Maxanswerid FROM $tablereplies WHERE questionid='$topicid'";
    	$result8=mysql_query($sql8);
    	$rows8=mysql_fetch_array($result8);
    
    	if ($rows8) 
    		{
    		$Max_id = $rows8['Maxanswerid']+1;
    		}
    	else 
    		{
    		$Max_id = 1;
    		}
    	$myusername=$_SESSION['myusername'];
    	$mydisplayname=$displayname;
    	$content=$_REQUEST['content'];
    	$author=$myusername;
    	$authordisplay=$displayname;
    	$datetime=date("d/m/y H:i:s"); // create date and time 
    
    	$sql9="INSERT INTO $tablereplies(questionid, answerid, author, authordisplay, content, datetime)VALUES('$topicid', '$Max_id',  '$author', '$authordisplay', '$content', '$datetime')";
            $result9=mysql_query($sql9);
    
    	if($result9)
    		{
    		echo "<br><br>Successful<BR>";
    		echo "<a href='index.php?viewtopic=".$topicid."'>View your answer</a>";
    
    		$sql10="UPDATE $tableposts SET replies='$Max_id' WHERE id='$topicid'";
    		$result10=mysql_query($sql10);
    
    
    		$memberid1="SELECT posts FROM $tablemembers WHERE username='$myusername'";
    		$memberid1result=mysql_query($memberid1);
    		$maxposts1="SELECT MAX(posts) AS Maxposts FROM $tablemembers WHERE id='$memberidresult'";
    		$results10=mysql_query($maxposts1);
    		$rows10=mysql_fetch_array($results10);
    		$maxpostresults2=$rows10['posts']+1;
    		$sql12="UPDATE $tablemembers SET posts='$maxpostresults2' WHERE username='$myusername'";
    		mysql_query($sql12);
    		}
    	else 
    		{
    		echo "ERROR";
    		}
    
    	}
    }

     

    And I don't get any errors, but it doesn't enter into the database correctly. Any ideas?

     

    ~Shaun

×
×
  • 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.