Error code... input field = database field

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
No0b
Forum Commoner
Posts: 37
Joined: Tue Feb 07, 2006 6:17 pm

Error code... input field = database field

Post by No0b »

This post as been edited:

there are no more errors just that there it's not doing what i want it to read below...

and my code is:

Code: Select all

<?
$db_name = "dbname";
$table_name = "tbname";
$connection = @mysql_connect("localhost", "id", "pass") or die(msql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "SELECT picture FROM $table_name WHERE username = '$_SESSION[username]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>

<body>
<div align=center>
<br><br>
<table width="500" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#CCCCCC" bordercolordark="#CCFFFF">
<tr>
 <td height="40" background="/images/Gradient.jpg">
  <font size="5"><b>Edit Spot</b></font>
 </td>
</tr>
<tr>
<td>
<br>
<FORM METHOD="POST" ACTION=" do_upload.php" ENCTYPE="multipart/form-data">
<p><strong>Web Address:</strong><br>
<input type="text" name="webaddress" size="30"></p>
<p><strong>Eyecon:</strong><br>
<INPUT TYPE="file" NAME="eyecon" value="<? mysql_fetch_array($result); ?>" SIZE="30"></p>
<p><strong>Heading:<strong><br>
<input type="text" name="heading" value="<? mysql_fetch_array($result); ?>" size="30"></p>
<p><strong>Description:</strong><br>
<textarea name="description" cols=45 rows=5 wrap=virtual></textarea></p>
<p><strong>Keywords:</strong><br>
<input type="text" name="key1" size="20"><input type="text" name="key2" size="20"><br>
<input type="text" name="key3" size="20"><input type="text" name="key4" size="20"><br>
<input type="text" name="key5" size="20"><input type="text" name="key6" size="20"><br>
<input type="text" name="key7" size="20"><input type="text" name="key8" size="20"><br>
<input type="text" name="key9" size="20"><input type="text" name="key10" size="20"><p>
</td>
</tr>
<tr>
<td height="40" background="/images/Gradient.jpg">
<p><input type="submit" name="submit" value="Save Changes"></p>
</td>
</tr>
</table>
</form>
</body>
</html>
What i'm trying to do is take info from the database and place it in the input fields. Example: say your username is dude and you log in as dude the $_SESSION[username] super is now dude you go over to your preferences and want to change your pick the <input type="file"> in the code above should have the value of the field in the database called "picture" and should only be the row where the username field in the database equals the $_SESSION[username] super, so that it's only your picture. If this makes any sence to you please post, if it doesn't??? Well just post anyway. lol...

Thanks for reading and all help is appreciated.
Last edited by No0b on Wed Feb 08, 2006 10:15 pm, edited 5 times in total.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

I dont know, but here are 2 errors I found in your script.
<textarea name="discription" cols=45 rows=5 wrat=virtual></textarea></p>
should be
<textarea name="discription" cols=45 rows=5 wrap=virtual></textarea></p>

and
<input type="text" name="heading" value="<? echo "$result\"; ?>" size="30"></p>
should be
<input type="text" name="heading" value="<? echo '$result\'; ?>" size="30"></p>
EDIT:
Also there is not even 122 lines in this code
User avatar
No0b
Forum Commoner
Posts: 37
Joined: Tue Feb 07, 2006 6:17 pm

Post by No0b »

ok so the script doesn't have any errors on it but just doesn't do what i want it to do. and that is have the input fields display the value of the picture field in the database. it's all in the first post.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

Get rid of your @ symbols, fix the error nickman pointed out, and repost the code with any errors.
User avatar
No0b
Forum Commoner
Posts: 37
Joined: Tue Feb 07, 2006 6:17 pm

Post by No0b »

why should i get rid of the @ in my code?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

because it slows down your code and also prevents you from seeing errors that could be the symptom of a larger overall problem
Post Reply