![]() |
Php help!
This is some php code for a Uni project! It dont work! Can anyone see any errors! Cheers! :confused:
<?php $connect = mysql_connect("localhost","root","live@49"); $db = mysql_select_db("flashphptask_zxq_customers", $connect); $sql = mysql_query("INSERT INTO comments (ID, Name, eMail, Comments) VALUE ('$ID', '$Name','$eMail','$Comments')")or die (mysql_error()); ?> |
Re: Php help!
What error are you getting?
|
Re: Php help!
There is no error - it just wont write anything to the database I have set up! been annoying me all night long!
|
Re: Php help!
Assuming you have given a value to the variables you're using within the query then it will work... you have given the variables a value haven't you? I.e.
$ID = 'This goes in the ID column'; $Name = 'And this in the Name column'; |
Re: Php help!
I think something slightly worse is awry if you are not getting any error messages at all, but you could try these suggestions.
Why are you inserting an ID? is that the id for your item that will be incremented each time you add a new item? if so you should have it set as an auto_increment column in mysql, Then you wont need to insert it manually each time. What is the column type for name, email and comments? If they are set to text you need to be adding them in the SQL query as such: ("INSERT INTO comments (ID, Name, eMail, Comments) VALUE ('$ID', \''$Name'\',\''$eMail'\',\''$Comments'\')") Hope that helps. |
Re: Php help!
Quote:
Pudsey, check your error logs! |
Re: Php help!
Quote:
Can you log into mySQL using those credentials and do an insert? |
Re: Php help!
Also, do you have phpMyAdmin installed? If so, is it working?
|
Re: Php help!
Quote:
what is this...i dont even...:confused: |
Re: Php help!
Code:
make sure you use mysql_real_escape_string() on your insert values, dont forget the ; at the end as an additional saftey, mabey wrap your query up with a sprintf such as... Code:
You could just use PDO or get a DB Class to do most of it for you in OOP standard. |
All times are GMT. The time now is 06:41 PM. |
Powered by vBulletin® - Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.