Little problem with form insertion in MySQL, Please help!!!

Posted on 16th Feb 2014 07:03 pm by admin


I'm a little bit new with php and I have a little issue here. I created a webform to insert some infos into a MySQL database. The weird thing is that some of the infos is correctly inserted and some not? I doubled checked my code and can't find what it is since it's a pretty simple code. If anyone can help, it would be really appreciated!

Here the form code :

Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" xml:lang="en" lang="fr">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link href="../../css/style1.css" rel="stylesheet" type="text/css" />
<br /><br />
<b>Ajout d'un Artiste L.V.A</b>

<form enctype="multipart/form-data" action="processes/insert_artist.php" method="POST" target="main2">
<table cellspacing="0" cellpadding="4" width="550">
<td width="275">Nom de l'artiste : </td>
<td width="225"><input type="text" name="artist" class="login" style="width: 250px"></td>
<td>Label : </td>
<td><input type="text" name="label" class="login" value="L.V.A ENTERTAINMENT" style="width: 250px"></td>
<td>Site Web : </td>
<td><input type="text" name="website" class="login" style="width: 250px"></td>
<td>Albums : </td>
<td><input type="text" name="albums" class="login" style="width: 250px"></td>
<td>Photo 1 :</td>
<td><input type="file" name="uploadedfile" class="login" style="width: 250px"></td>
<td colspan="2">Biographie :</td>
<td colspan="2"><textarea style="width: 550px" rows="15" class="login" name="bio"></textarea></td>
<td colspan="2" height="40" align="right" valign="bottom"><input type="submit" value="Enregsitrer" class="login"></td>

And now here's the PHP code :
$target_path = "../artists photo/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

$picture = basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<center><br /><br />votre photo $picture a été correctement enregistré</center>
} else{
echo "<center><br /><br />Il y a eu un problème avec l'instertion de votre photo</center>
$con = mysql_connect("server","user","pass");

$artist = mysql_real_escape_string($_POST['artist']);
$label = mysql_real_escape_string($_POST['label']);
$website = mysql_real_escape_string($_POST['website']);
$albums = mysql_real_escape_string($_POST['albums']);
$photo = mysql_real_escape_string($_POST['uploadedfile']);
$bio = mysql_real_escape_string($_POST['bio']);

if (!$con)
die('Could not connect: ' . mysql_error());
}mysql_select_db("a1808796_data", $con);$sql="INSERT INTO artists ( artist, label, website, albums, photo, bio)
('$artist','$label','website','$albums','$photo','$bio')";if (!mysql_query($sql,$con))
die('Error: ' . mysql_error());

echo "<br /><br /><center>Votre artiste a correctement été ajouté à la base de donnée.<br /><br /><a href="panel.php" target="main2">Retour au paneau de contrôle</a></center>";

As you can see I have artist, label, website, albums, photo, bio

the artist, label, albums and bio insterts correctly

"website" always inster "website" instead of the value posted in the form

the uploaded file (wich is a picture file) uploads correctly but the value ($photo) is not inserted into the DB....

If anyone sees the problem please help!!!!!


No comments posted yet

Your Answer:

Login to answer
65 Like 43 Dislike
Previous forums Next forums
Other forums

user data not transferring to new page
I'm a PHP learner. After an index.php page, the user goes to a login.php page. Both pages seem to

Struct/union and scope problem!
HI all , I have
Code: in header.h typedef struct Node Link; /* ---------

RadioButtonList item spacing
I have a RadioButtonList and I can't put any spacing between the items. They are arranged verticall

generating all possible random letters

how can i randomize the letters a,b,c,d,e all possible ways, and i want to print the res

returning data from an ssh2_exec()
here's what i got.

$conn = ssh2_connect($this->_host);

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash