Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
mysql query is not affecting table in the database
Old 04-04-2009, 12:50 PM mysql query is not affecting table in the database
Skilled Talker

Posts: 54
Trades: 0
The code below is supposed to add a new record to forum table.But when ever i executes it ,no error message and yet the new record is not insert into the table.please help.any help is appreciated.
PHP Code:
if ((isset($_POST["MM_category"])) && ($_POST["MM_category"] == "formadd")) {
  
$insertSQL sprintf("INSERT INTO forum ( forum_category) VALUES ( %s)",
                       
GetSQLValueString($_POST['forumcat'], "text"));

  
mysql_select_db($database_sql1$sql1);
  
$Result1 mysql_query($insertSQL$sql1) or die(mysql_error());
  
$addGoTo "editforumcat.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$addGoTo .= (strpos($addGoTo'?')) ? "&" "?";
    
$addGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$addGoTo));
}
//the form to accept input from user
<form action="$_SERVER['PHP_SELF']" method="post" name="forumadd">
<
table width="200" border="0" cellspacing="2" cellpadding="1">
  <
tr>
    <
td nowrap="nowrap">Category name</td><td><input name="forumcat" type="text" size="32" /></td>
   
  </
tr>
</
table>
<
input type="hidden" name="MM_category" value="forumadd" />
<
input name="" type="submit" value="Add to forum category" />
</
form
kani alavi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-05-2009, 08:18 AM Re: mysql query is not affecting table in the database
Junior Talker

Posts: 4
Name: Philip Rollins
Trades: 0
Not 100% sure but this part does not look right to me. MySQL query should be formatted like the first section but I have never used sprintf try running raw commands trough phpmyadmin. Maybe turn this. INSERT INTO forum ( forum_category) VALUES ( %s) Into this. INSERT INTO `forum` ( `forum_category` ) VALUES ( '{%s}') Every professional I've seen uses the ` I never had any problems with or without it, but it might just work.
Code:
 $insertSQL = sprintf("INSERT INTO forum ( forum_category) VALUES ( %s)",                        GetSQLValueString($_POST['forumcat'], "text"));
SenseiNinja is offline
Reply With Quote
View Public Profile
 
Old 04-06-2009, 01:52 AM Re: mysql query is not affecting table in the database
dark_lord's Avatar
Experienced Talker

Posts: 41
Name: Parijat Roy
Location: INDIA-KOLKATA
Trades: 0
why don't you change this confusing part
PHP Code:
$insertSQL sprintf("INSERT INTO forum ( forum_category) VALUES ( %s)",
                       
GetSQLValueString($_POST['forumcat'], "text")); 
to something easier?

PHP Code:
$f_cat mysql_escape_string($_POST['forumcat']);
$insertSQL "INSERT INTO forum SET forum_category = '".$f_cat."'"
I guess you are not getting any error because of blank value is getting inserted?
__________________
I AM THE BEAUTIFUL NIGHTMARE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dark_lord is offline
Reply With Quote
View Public Profile Visit dark_lord's homepage!
 
Reply     « Reply to mysql query is not affecting table in the database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11268 seconds with 12 queries