Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL Insert Submit Button PHP
    primarykey
    data
    text
    <p>I am generating a list of images and looking to insert a specific image based on wether or not a submit button has been pressed alongside my image.</p> <p>Here is my code to generate a list of images. Alongside the images is the submit button, like count and other data:</p> <pre><code>// Display results foreach ($media-&gt;data as $data) { echo "&lt;a href=\"{$data-&gt;link}\"&lt;/a&gt;"; echo "&lt;h4&gt;Photo by: {$data-&gt;user-&gt;username}&lt;/h6&gt;"; echo $pictureImage = "&lt;img src=\"{$data-&gt;images-&gt;thumbnail-&gt;url}\"&gt;"; echo "&lt;h5&gt;Like Count for Photo: {$data-&gt;likes-&gt;count}&lt;/h5&gt;"; echo "&lt;form&gt;"; echo '&lt;input type="submit" onClick=post()&gt;'; echo "&lt;/form&gt;"; } </code></pre> <p>I am then trying to insert that picture into my database:</p> <p><strong>InstagramImages(DB) - image(field)</strong></p> <pre><code>function post() { $hostname = "redacted"; $username = "redacted"; $dbname = "redacted"; //These variable values need to be changed by you before deploying $password = "redacted"; $usertable = "InstagramImages"; //Connecting to your database mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later."); mysql_select_db($dbname); $sql="INSERT INTO $usertable (image) VALUES ('$pictureImage')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } echo "1 record added"; mysqli_close($con); } </code></pre> <p>Any help would be appreciated. I need help creating the right INSERT query for the php variable $pictureImage. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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