Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Insert Numbers not working?
    text
    copied!<p>I am inserting tags from a textarea into a database but the issue is that whenever I try to insert the album INT or the track INT it shows up as 0 in the database. If you see the PHP output the values are equal to 1 then when its inserted into the database with four separate queries it always shows up as 0.</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;link type="text/css" rel="stylesheet" href="style.css" /&gt;&lt;/head&gt; &lt;?php include 'connect.php'; $tags = $_POST['tags']; //$album = $_POST['album']; //$track = $_POST['track']; $data = preg_replace("~\s*[\r\n]+~", ', ', $tags); $arr=explode(",",$data); foreach ($arr as $value) { $id = 'NULL'; $album = $_POST['album']; $track = $_POST['track']; echo $id; echo "&lt;br&gt;"; echo $album; echo "&lt;br&gt;"; echo $track; echo "&lt;br&gt;"; echo $value; echo "&lt;br&gt;&lt;br&gt;"; // echo "id "; // echo $album; // echo " "; // echo $track; // echo " "; // echo $value; // echo " inserted into the DB!&lt;BR&gt;"; //mysql_query("INSERT INTO tags (`id`, `album`, `track`, `tag`) VALUES (NULL, '$album', '$track', '$value')"); //mysql_query("INSERT INTO `tags` (`id`, `album`, `track`, `tag`) VALUES(NULL, '".$album."', '".$track."', '".$value."')") or die(mysql_error()); //mysql_query("INSERT INTO tags (id, album, track, tag) VALUES (NULL, '$album', '$track', '$value' )") or die(mysql_error()); mysql_query("INSERT INTO tags(id, album, track, tag) VALUES('$id' , '$album', '$track', '$value')") or die(mysql_error()); } ?&gt; &lt;/html&gt; </code></pre> <p>PHP browser output:</p> <pre><code>NULL 1 1 this NULL 1 1 is NULL 1 1 a NULL 1 1 test </code></pre> <p>Database shows the following entries with EVERY query I have tried</p> <p><a href="http://i.stack.imgur.com/d6QQ9.png" rel="nofollow">http://i.stack.imgur.com/d6QQ9.png</a></p> <p>Secondary link if first one fails</p> <p><a href="http://d4rkd0s.info/tags.png" rel="nofollow">http://d4rkd0s.info/tags.png</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload