vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   not inserting? (https://vborg.vbsupport.ru/showthread.php?t=39109)

N!ck 05-27-2002 08:46 PM

not inserting?
 
this biznitch works fine with one exception. when a user tries to register, it returns that he has been successfully registered, but it doesn't seem to insert the user's information. help!

PHP Code:

<?
function dbstart () {
 mysql_connect("localhost", "xxxxxxx", "xxxxxxx");
 mysql_select_db("xxxxxxx");
}

function dbquit () {
 mysql_close();
}

if ($action=="register") {
 if ($yim=="YIM") {
  $yim="";
 }
 if ($aim=="AIM") {
  $aim="";
 }
 if ($icq=="ICQ") {
  $icq="";
 }
 if ($msn=="MSN") {
  $msn="";
 }
 $email=addslashes($email);
 $msn=addslashes($msn);
 $aim=addslashes($aim);
 $yim=addslashes($yim);
 dbstart();
 mysql_query("INSERT INTO shoutboxuser (userid, username, password, email, homepage, yim, aim, icq, msn) VALUES ('0', '$username', '$password', '$email', '$homepage', '$yim', '$icq', '$msn')");
 $msg="You have been successfully registered.  You may now post shouts.";
 dbquit();
}

if ($action=="regform") {
 $msg.="<form action=\"shoutbox.php?action=register\" method=\"post\"><table border=0 cellpadding=2 cellspacing=1>";
 $msg.="<tr><td bgcolor=\"#000033\" align=center><font color=\"#FFFFFF\" face=\"verdana, arial, sans-serif, helvetica, times\" size=2><b>sign up</b></font></td></tr>";
 $msg.="<tr><td bgcolor=\"#0066FF\"><input onFocus=\"this.value=''\" type=text name=\"username\" size=30 maxlength=20 value=\"username\"></td></tr>";
 $msg.="<tr><td bgcolor=\"#0066FF\"><input onFocus=\"this.value=''\" type=text name=\"password\" size=30 maxlength=20 value=\"password\"></td></tr>";
 $msg.="<tr><td bgcolor=\"#0066FF\"><input onFocus=\"this.value=''\" type=text name=\"email\" size=30 maxlength=150 value=\"your email\"></td></tr>";
 $msg.="<tr><td bgcolor=\"#0066FF\"><input onFocus=\"this.value=''\" type=text name=\"yim\" size=15 maxlength=50 value=\"YIM\"><input onFocus=\"this.value=''\" type=text name=\"aim\" size=15 maxlength=50 value=\"AIM\"></td></tr>";
 $msg.="<tr><td bgcolor=\"#0066FF\"><input onFocus=\"this.value=''\" type=text name=\"icq\" size=15 maxlength=50 value=\"ICQ\"><input onFocus=\"this.value=''\" type=text name=\"msn\" size=15 maxlength=50 value=\"MSN\"></td></tr>";
 $msg.="<tr><td align=center><input type=submit onClick=\"this.value=' please wait... '\" value=\" sign up \"></td></tr></table></form>";
}

if ($action=="shout" && $username!="" && $password!="") {
 dbstart();
 $uinfo = mysql_fetch_array(mysql_query("SELECT userid FROM shoutboxuser WHERE username = '$username' AND password = '$password'"));
 $uid = $uinfo[userid];
 if ($uid=="") {
  $msg="Error!  Your username and password combination were not accepted.";
 } else {
  $dateline=time();
  mysql_query("INSERT INTO shoutbox (id, uid, shout, dateline) VALUES ('0', '$uid', '$shout', '$dateline')");
  $msg="";
 }
 dbquit();
}
?>
<html>
<head>
<title>shoutbox - get back in the frames ;)</title>
</head>
<body bgcolor="#0099FF" text="#000033" link="#000099" vlink="#000099">
<img src="/images/titles/shoutbox.gif" width="225" height="67">
<p>
<font face="verdana, arial, sans-serif, helvetica, times" size="2">
<?
if ($msg!="") {
 echo "<center><font face=\"#0000FF\"><b>" . $msg . "</b></font></center><p>";
}
?>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr><td bgcolor="#000033"><font face="verdana, arial, sans-serif, helvetica, times" size="1" color="#FFFFFF"><b>user</b></font></td><td bgcolor="#000033"><font face="verdana, arial, sans-serif, helvetica, times" size="1" color="#FFFFFF"><b>shout</b></font></td></tr>
<?
dbstart();
$sq=mysql_query("SELECT shoutbox.*,shoutboxuser.* FROM shoutbox LEFT JOIN shoutboxuser ON (shoutbox.uid = shoutboxuser.userid) ORDER BY shoutbox.id DESC LIMIT 30");
while ($shout=mysql_fetch_array($sq)) {
?>
<tr><td bgcolor="#0066FF"><font face="verdana, arial, sans-serif, helvetica, times" size="2"><? echo $shout[username]; ?></font></td><td bgcolor="#0066FF"><font face="verdana, arial, sans-serif, helvetica, times" size="2"><? echo $shout[shout]; ?></font></td></tr>
<?
}
?>
</table>
<p>
<center><form action="shoutbox.php?action=shout" method="post">
<table border="0" cellpadding="2" cellspacing="1">
<tr><td colspan="2" bgcolor="#000033" align="center"><font face="verdana, arial, sans-serif, helvetica, times" size="2" color="#FFFFFF"><b>Leave a Shout</b></font></td></tr>
<tr><td bgcolor="#0066FF"><font face="verdana, arial, sans-serif, helvetica, times" size="2">Username:</font></td><td bgcolor="#0066FF"><input type="text" name="username" size="30" maxlength="20"></td></tr>
<tr><td bgcolor="#0066FF"><font face="verdana, arial, sans-serif, helvetica, times" size="2">Password:</font></td><td bgcolor="#0066FF"><input type="password" name="password" size="30" maxlength="20"></td></tr>
<tr><td colspan="2" align="center" bgcolor="#0066FF"><font face="verdana, arial, sans-serif, helvetica, times" size="1">Not registered?  <a href="shoutbox.php?action=regform">Click here.</a></font></td></tr>
<tr><td bgcolor="#0066FF" valign="top"><font face="verdana, arial, sans-serif, helvetica, times" size="2">Shout:</font></td><td bgcolor="#0066FF"><textarea rows="5" cols="28" name="shout" WRAP></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value=" shout! "></td></tr>
</table></form></center>
<?
dbquit();
?>
</body>
</html>


Logician 05-28-2002 10:11 AM

I dont know the structure of your "shoutboxuser" table however doesnt it have an primary key with autoincrement? It's very likely that userid is such a field and if it is, your query must be:

mysql_query("INSERT INTO shoutboxuser (userid, username, password, email, homepage, yim, aim, icq, msn) VALUES (NULL, '$username', '$password', '$email', '$homepage', '$yim', '$icq', '$msn')");

If it does not work for you, insert:

echo mysql_error();

after this line to debug..

N!ck 05-28-2002 06:42 PM

thanks :D


All times are GMT. The time now is 12:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01019 seconds
  • Memory Usage 1,741KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete