0

this is my php code,it works properly before inserting,can it be the fact that i have attatched a photo to my form?
the other problem is,i dont know what type is photo for my xampp database,i left it a VARCHAR, the error i get is:
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\toyota\test.php on line 14

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("forum") or die(mysql_error());
$username = $_POST['username'];
$photo = $_POST['photo'];
$comment = $_POST['comment']; 
$query = "INSERT INTO comments(username, photo, comment) values('$username','$photo','$comment');
$result=mysql_query($query);
if ($results) 
{ 
echo "insert complete";
}
mysql_close($link);
?>

your help will be highly appriciated

3
Contributors
5
Replies
18
Views
3 Years
Discussion Span
Last Post by João_5
0

@pritaeas,thanks a lot for helping me with the stupid mistake i made,so what happens now is,after i submit my form,it redirects to a blank page of URL:
http://localhost/toyota/test.php which is the path of my php code,still my database is not inserted,pls help

0

@pritaeas,thanks once again,every field is well updated except for photos,i have never worked with photos,cant it be that i dont know photo datatype amongst those predefined for xampp?

0

What are you trying to store in the photos column? Is it a path, or a file? In case of the latter you'll need to use a blob field. If you search this forum, you'll find examples for inserting an image into MySQL.

0

In phpMyadmin select the database forum, and click on SQL
In the box insert:

DROP TABLE photo;


    CREATE TABLE files (
  id int(11) NOT NULL AUTO_INCREMENT,
  mime varchar(255) NOT NULL,
  data blob NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB;

If you do not have phpmyadmin installed use this php script

<?php
//connect to db
    $con = mysql_connect("localhost","root",""); 
    if (!$con) 
    { 
    die('Could not connect: ' . mysql_error()); 
    } 
    mysql_select_db("forum") or die(mysql_error());

    mysql_query("CREATE TABLE files (
      id int(11) NOT NULL AUTO_INCREMENT,
      mime varchar(255) NOT NULL,
      data blob NOT NULL,
    ) ENGINE=InnoDB;"); 
    Print "Your table has been created"; 
 ?> 
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.