Hello everyone,

My friend has been helping and he's been great however it's come to a halt :P

I'm working with MYSQL at the moment but am having a few issues with my code.


<html><link href="stylesheet.css" rel="stylesheet" type="text/css">
<div id="header"><img src="http://www.rhinosecurityltd.co.uk/templates/rhuk_milkyway/images/mw_joomla_logo.png" alt="Rhino Security"> </DIV>
<form name="Form" action="SQL.php">
Client/Company Name: <input type="text" name="clientname"><br>
Contact / Letter name: <input type="text" name="contactname"><br>
Notes: <textarea rows="5" cols="30" name="notes">
System Type <select name="system">
<option value="type1">type1</option>
<option value="type2">type2</option>
<option value="type3">type3</option>
<option value="type4">type4</option>
<option value="none" selected="selected">None</option>
Status <select name="status">
<option value="alive" "selected">Alive</option>
<option value="dead">Dead</option>
<option value="stop">Stop</option>
Signal Type<select name="signaltype">
<option value="signal 1" "selected">Signal 1</option>
<option value="signal 2">Signal 2</option>
<option value="signal 3">Signal 3</option>
Verification Method<select name="verification">
<option value="verify1" "selected">verify1</option>
<option value="verify2">verify2</option>
<option value="verify3">verify3</option>
<!--End of intro-->

<!--Start of Address etc-->
Address: <textarea rows="5" cols="30" name="address"></textarea><br>
Postcode: <input type="text" name="postcode"><br>
Telephone: <input type="text" name="telephone"><br>
Mobile: <input type="text" name="mobile"><br>
Mobile2: <input type="text" name="mobiletwo"><br>
Email: <input type="text" name="email"><br>
Main Area: <input type="text" name="mainarea"><br>
<!--End of Address-->

<!--Start of Dates-->
Installation Date: <input type="date" name="installation"><br>
Contract Type: <input type="text" name="Contract"><br>
Expiration date: <input type="date" name="expiration"><br>
Services Per Annum: <select name="SPA">
<option value="0anum">0</option>
<option value="1anum">1</option>
<option value="2anum">2</option>
<option value="none" selected="selected">None</option>
Next Service: <input type="date" name="nservice"><br>
Appointment Req: 
<!--End of Dates-->

<!--Start of Financial Details-->
Invoice Run: ??<br>
Invoice Code:??<br>
<!--End of Financial Details-->
<!--Start of Charges-->
Maintenance: <input type="number" name="maintenance"><br> 
Monitoring: <input type="number" name="monitoring"><br>
<!--End of Charges-->
<!--Start of Monitored System-->
Y/N: <select name="MS">
<option value="myes">Yes</option>
<option value="mno">No</option>
<!--End of Monitored System-->
<!--Start of Certificate details-->
Date: <input type="date" name="certdate"><br>
Certificate: ??
<!--End of Certificate details-->
<input type="submit" value="Submit">



    // Grab our POSTed form values
    // Note that whatever is enclosed by $_POST[""] matches the form input elements
    $clientname= $_POST["ClientName"];
    $contactname= $_POST["ContactName"];
        // Connect to our DB with mysql_connect(<server>, <username>, <password>)
        $sql_connection = mysql_connect("localhost", "xtrapsp_rhino", "passwrod");
        mysql_select_db("xtrapsp_Rhino", $sql_connection);

        $sql = "INSERT INTO Customers(
            ) VALUES (
    mysql_query(Mysql_real_escape_string($sql), $sql_connection);

This is the code on: http://rhino.minepress.co.uk/

The problem I'm having is I don't know if it is submitting the information to the database, I have a Database called xtrapsp_Rhino

And inside that I have a table called Customers, inside that I have 3 different columns.



Any help as to why it's not submitting ANY data?

Edited by bradly.spicer

5 Years
Discussion Span
Last Post by bradly.spicer
$sql = "INSERT INTO Customers(
          Date column is missing here
        VALUES (

If you don't have a date column, remove the comma after ContactName, and remove NOW (and the comma after $contactname).

Use mysql_real_escape_string, all lower case.

Edited by pritaeas


Hey, Thanks for the response.

    // Grab our POSTed form values
    // Note that whatever is enclosed by $_POST[""] matches the form input elements
    $clientname= $_POST["ClientName"];
    $contactname= $_POST["ContactName"];
        // Connect to our DB with mysql_connect(<server>, <username>, <password>)
        $sql_connection = mysql_connect("localhost", "xtrapsp_rhino", "password");
        mysql_select_db("xtrapsp_Rhino", $sql_connection);
        $sql = "INSERT INTO Customers(
            ) VALUES (
    mysql_query(mysql_real_escape_string($sql), $sql_connection);

Made All those changes :)

I'm not sure if it is something I have setup wrong in the Index.php Or the MYSQL. I still can't see why there is no data inside the MYSQL.

When I click in the customers Table I get this:

MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0009 sec )


Try it without the mysql_real_escape_string. Notice only now. It will mess up the quotes that are necessary around the values. If you want to use it, use it on the variables like this:

$clientname = mysql_real_escape_string($_POST["ClientName"]);
$contactname = mysql_real_escape_string($_POST["ContactName"]);
// ...
mysql_query($sql, $sql_connection) or die(mysql_error());

Edited by pritaeas


Thanks pritaeas, I realised that what was previous still works except I wasn't using the right $_POST names in relation to the DB :P

Silly me!

Thanks again Upvoted.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.