Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,849 members, 7,810,274 topics. Date: Saturday, 27 April 2024 at 04:17 AM |
Nairaland Forum / Science/Technology / Programming / Php/mysql Insert Issues (1070 Views)
How To Make a DESKTOP Executable Software Using PHP,MYSQL,SQLITE / Insert Image Into Mysql / Php/mysql Help:how To Run Sql Query From A Link (2) (3) (4)
(1) (Reply)
Php/mysql Insert Issues by IronFist(m): 11:18am On Mar 20, 2007 |
PHP/MySQL gurus.I need help with PHP/MySQL. I created a form but every time i send stuff through the form it doesn't insert nothing.I'm attaching the SQL for my table CREATE TABLE `albion`.`article` ( Here's the code for my PHP form
What exactly am i getting wrong?Appreciate the help fellaz. |
Re: Php/mysql Insert Issues by oleku(m): 4:01pm On Mar 26, 2007 |
I have been able to edit your code. Try this : <? if(isset($_POST['Save Article'])) { $db = mysql_connect($host,$username,$password); // Databse Host Username and password mysql_select_db($database,$db); // Database name $Query = sprintf("INSERT INTO article (topic,author,article) VALUES('%s','%s','%s')",$_POST['Topic'],$_POST['Author'],$_POST['Article']); if ($result = mysql_query($Query)) { echo '<center><b>Article added to the database</b></center><br>'; } else { exit('<center>Sorry, there was an error saving to the database</center>'); } } ?> oleku www.oleku.org |
Re: Php/mysql Insert Issues by naijaguru(m): 4:41pm On Mar 27, 2007 |
The code posted by Oleku should work but. However one needs to clarify somethings here. IronFist. You were trying to use the DBconnect object from PEAR, but u didnt seem to understand how it works. You should try avoiding using PEAR if u are a rookie in PHP. Use the 'native' mysql_ functions in php 1. To create table/database in PHP, use PhpMyAdmin - as a starter. 2. To Insert data, I'd advice u to run your queries this way. $sql = "INSERT INTO table SET field1='value1', field2 = 'value2', field3='value3'"; instead of $sql = "INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3)"; 3. And make sure u always use the addslashes() function for your queries and stripslashes() for output |
(1) (Reply)
A Java Programmer To Be Needs Your Help Please! / THE VALLEY OF DEATH - A PLACE YOU'LL FIND MOST FOUNDERS / Voice Advertisment To Cell Phone
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19 |