Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving issues with my database? I am trying to have a section in my site where you can add a new neighborhood?
    primarykey
    data
    text
    <p>I am trying to add a section in my site where you can fill out a small form and it will add the neighborhood in for you. When I try to fill in the form and add the new neighborhood, I get the error below. Please let me know what I am doing wrong and why I can't get these to be added into the database? Thanks for any help! </p> <p>Code: <pre><code>require_once('db.php'); //set the registration variables $name = addslashes($_POST['name']); $builder = addslashes($_POST['builder']); $builderURL = $_POST['builderURL']; //connect to database $link = mysql_connect($dbhost, $dbuser, $dbpwd); if (!$link) { die(strip_tags('Could not connect: '.mysql_error())); } //add this contest to the database $stmt = "INSERT INTO hf_neighborhoods (name, builder, builder_url, created_on) VALUES " . "('$name', '$builder', '$builderURL', NOW())"; $result = mysql_query($dbname, $stmt); if(!$result){ die(strip_tags('Error Adding Neighborhood: '.mysql_error())); } //if we made it this far, return a success echo 'success'; ?&gt; DB Call: &lt;?php $dbhost = 'localhost'; $dbname = 'delsur_2011_dev'; $dbuser = 'delsur2011'; $dbpwd = 'newsite!'; ?&gt; Error: &lt;br /&gt; &lt;b&gt;Warning&lt;/b&gt;: mysql_query() expects parameter 2 to be resource, string given in &lt;b&gt;/var/www/vhosts/delsurliving.com/httpdocs/hf/php/addNeighborhood.php&lt;/b&gt; on line &lt;b&gt;21&lt;/b&gt;&lt;br /&gt; Error Adding Neighborhood: </code></pre> <hr> <pre><code>Now I am receiving this error when I try to change it to that new code? Is it just not connecting to the database at all now? I am lost, I wasn't the one that set this file up, I was just told to go and try to fix it so that is what I am trying to do now? Thanks for your help </code></pre> <p><b>Warning</b>: mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in <b>/var/www/vhosts/delsurliving.com/httpdocs/hf/php/addNeighborhood.php</b> on line <b>8</b><br /> <br /> <b>Warning</b>: mysql_real_escape_string(): A link to the server could not be established in <b>/var/www/vhosts/delsurliving.com/httpdocs/hf/php/addNeighborhood.php</b> on line <b>8</b><br /> <br /> <b>Warning</b>: mysql_real_escape_string(): Access denied for user 'apache'@'localhost' (using password: NO) in <b>/var/www/vhosts/delsurliving.com/httpdocs/hf/php/addNeighborhood.php</b> on line <b>9</b><br /> <br /> <b>Warning</b>: mysql_real_escape_string(): A link to the server could not be established in <b>/var/www/vhosts/delsurliving.com/httpdocs/hf/php/addNeighborhood.php</b> on line <b>9</b><br /> Error Adding Neighborhood: No database selected</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.
    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