You are here: Re: [PHP] Inserting records question « PHP « IT news, forums, messages
Re: [PHP] Inserting records question

Posted by Philip Hallstrom on 09/09/05 04:41

> Still learning, so sorry if this sounds really simply noobish. But as I
> understand things currently this should work. But doesn't. I've been
> looking over tutorials but just don't see whatever the problem is.
>
> I created a simple table with the following fields (in order)
> tc_id (auto nmbr)
> lname
> fname
> machine_name
> email_addr
> problem
> date_time_submitted (timestamp)
>
> And I'm trying to run this insert from form input.
>
> $username="somename";
> $password="somepass";
> $database="somedb";
> $table="sometable";
> mysql_connect(localhost,$username,$password);
> @mysql_select_db("$database") or die("Unable to Connect to DB");
> $tc_query = "INSERT INTO $tablel VALUES(NULL, $lname, $fname, $machine_name,
> $email_addr, $problem, NULL)";
> $result = mysql_query($tc_query);
> mysql_close();
>
> So what exactly do I seem to be missing here?

A lot of single quotes... around the parameters you are inserting...

add in a print($tc_query) and see what that looks like... run that
directly in mysql and it will give you more details on the error.

Or, make it look like this:

$tc_query = "INSERT INTO $tablel VALUES(NULL, '$lname', '$fname',
'$machine_name', '$email_addr', '$problem', NULL)";

I'd also suggest you read this page:

http://www.php.net/mysql_escape_string

good luck!

-p

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация