www.webdeveloper.com
Results 1 to 2 of 2

Thread: I'm getting these warnings

  1. #1
    Join Date
    Jan 2013
    Posts
    4

    I'm getting these warnings

    Trying to create in mySQL

    Warning: mysql_query() [function.mysql-query]: Can't connect to MySQL server on 'localhost' (10061) in D:\Hosting\5704590\html\studentemail_form.php on line 14

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\Hosting\5704590\html\studentemail_form.php on line 14
    Can't connect to MySQL server on 'localhost' (10061)

    This is my code:

    <?php

    function Visit($url)
    {
    $dbc = mysql_connect(); // set this to connect properly
    echo $url;
    mysql_select_db('40daysintheword', $con) || die(mysql_error());
    }

    $query = "INSERT INTO $table(host,firstname, lastname, address, city, phone, email, member childcare, grades)
    VALUES('$_POST[host]', '$_POST[firstname]', '$_POST[lastname]', '$_POST[address]', '$_POST[city]', '$_POST[phone]', '$_POST[email]', '$_POST[member]', '$_POST[childcare]',
    '$_POST[grades]";

    LINE 14: $result = mysql_query($query) || die(mysql_error());

    mysql_close($dbc);

    ?>

    I will be grateful for any help I can get.

    Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,918
    If you are connecting to the DB via your Visit() function, if you don't return the mysql resource from it, then it will exist only within that function. You could maybe change it to something like:
    PHP Code:
    function Visit($url)
    {
      
    $dbc mysql_connect(); // <--- are you setting the dbHost and user/password params here?
      
    mysql_select_db('40daysintheword'$con) || die(mysql_error());
      return 
    $dbc;
    }

    $dbc Visit($url); 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles