Jump to content

ryanhowdy

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.familycms.com/

Profile Information

  • Gender
    Not Telling

ryanhowdy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I can't figure out what's wrong with the following code. It seems to work fine on some servers and not on others, I think it is a MySQL 5 problem, but I'm not sure. mysql_query("CREATE TABLE `fcms_address` ( `id` int(11) NOT NULL auto_increment, `user` int(11) NOT NULL default '0', `entered_by` INT(11) NOT NULL DEFAULT '0', `updated` timestamp NOT NULL default CURRENT_TIMESTAMP, `address` varchar(50) default NULL, `city` varchar(50) default NULL, `state` varchar(50) default NULL, `zip` varchar(10) default NULL, `home` varchar(20) default NULL, `work` varchar(20) default NULL, `cell` varchar(20) default NULL, PRIMARY KEY (`id`), KEY `user_ind` (`user`), KEY `ent_ind` (`entered_by`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1") or die(mysql_error()); mysql_query("ALTER TABLE `fcms_address` ADD CONSTRAINT `fcms_address_ibfk_1` FOREIGN KEY (`user`) REFERENCES `fcms_users` (`id`) ON DELETE CASCADE" ) or die(mysql_error()); mysql_query("ALTER TABLE `fcms_address` ADD CONSTRAINT `fcms_address_ibfk_2` FOREIGN KEY (`entered_by`) REFERENCES `fcms_users` (`id`) ON DELETE CASCADE" ) or die(mysql_error()); And I get the following error: Any ideas?
  2. I am having problems with an addressbook table in my php/mysql application. The problem I am having is that users with mysql 5 seem to be getting an foreign key constraint fails error but no one else does. The table layout is as follows: id int(11) No user int(11) No 0 entered_by int(11) No 0 updated timestamp No CURRENT_TIMESTAMP address varchar(50) Yes NULL city varchar(50) Yes NULL state varchar(50) Yes NULL zip varchar(10) Yes NULL home varchar(20) Yes NULL work varchar(20) Yes NULL cell varchar(20) Yes NULL I wanted user and entered_by to both be foreign keys that point to table members.userid. It's been too long since my DB design classes, but I assume this isn't the right way to do this. The user field would be used for the user that the address belongs to and entered_by would be used to show what member entered that address, because I want to allow members to enter addresses for other members or non-members. Is there a better way to accomplish what I want? Thanks in advance
  3. try this header("Location: ".$_SERVER[HTTP_REFERER]);
  4. Something like this? if (isset($_POST['your_post_var'])) { echo "<meta http-equiv='refresh' content='0;URL=yahoo.com'>"; }
  5. line 3 looks like this... $user = $_POST['user']; This is a login script, and I'm checking to see if the username field was submitted and filled out. the code works fine, but I want to try and clean up these notices. what is the correct way to check for this? without the notices?
  6. i'm using a basic chat script and i'm trying to add a section for users currently logged in. i only want to display the users who have posted in the last 2 min getUsersOnline() and handleReceiveUsers() are the new info that doesn't seem to work. i know each of them are being called correctly, i can output from either function, but it looks like handleReceiveUsers() doesn't receive the xml data correctly I can't figure out what's wrong... chat.php var sendReq = getXmlHttpRequestObject(); var receiveReq = getXmlHttpRequestObject(); var receiveReq2 = getXmlHttpRequestObject(); var lastMessage = 0; var mTimer; function startChat() { document.getElementById('txt_message').focus(); getChatText(); getUsersOnline(); } function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.'; } } function getUsersOnline() { if (receiveReq2.readyState == 4 || receiveReq2.readyState == 0) { receiveReq2.open("GET", 'getChat.php?chat=1&last=' + lastMessage, true); receiveReq2.onreadystatechange = handleReceiveUsers; var param = 'action=getusers'; receiveReq2.send(param); } } function handleReceiveUsers() { if (receiveReq2.readyState == 4) { var users_div = document.getElementById('div_users'); var xmldoc = receiveReq2.responseXML; var online_nodes = xmldoc.getElementsByTagName("online"); var n_online = online_nodes.length for (i = 0; i < n_online; i++) { var user_node = online_nodes[i].getElementsByTagName("user"); users_div.innerHTML += '<b>' + user_node[0].firstChild.nodeValue + '<b/><br/>'; } mTimer = setTimeout('getChatText();',2000); } } getChat.php <?php header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-Type: text/xml; charset=utf-8"); require('database.php'); $xml = '<?xml version="1.0" ?><root>'; if(isset($_GET['action']) && $_GET['action'] == 'getusers') { $last2min = date('Y-m-d h:m:s', strtotime(date('Y-m-d h:m:s'), "-2 min")); $sql = "SELECT message_id, user_name FROM fcms_chat_msgs WHERE chat_id = " . db_input($_GET['chat']) . " AND post_time <= '$last2min'"; $users_query = db_query($sql); while($users_array = db_fetch_array($users_query)) { $xml .= '<online id="' . $users_array['message_id'] . '">'; $xml .= '<user>' . htmlspecialchars($users_array['user_name']) . '</user>'; $xml .= '</online>'; } } else { $last = (isset($_GET['last']) && $_GET['last'] != '') ? $_GET['last'] : 0; $sql = "SELECT message_id, user_name, message, date_format(post_time, '%r') as post_time" . " FROM fcms_chat_msgs WHERE chat_id = " . db_input($_GET['chat']) . " AND message_id > " . $last; $message_query = db_query($sql); while($message_array = db_fetch_array($message_query)) { $xml .= '<message id="' . $message_array['message_id'] . '">'; $xml .= '<user>' . htmlspecialchars($message_array['user_name']) . '</user>'; $xml .= '<text>' . htmlspecialchars($message_array['message']) . '</text>'; $xml .= '<time>' . $message_array['post_time'] . '</time>'; $xml .= '</message>'; } } $xml .= '</root>'; echo $xml; ?>
  7. yes, that helps and sorry it took so long to reply. thanks again.
  8. I understand that the notices are turned off, but that shouldn't stop the application from working at all should it?
  9. I am trying to re-write an old message board script I wrote awhile ago, using object oriented programming. The problem is I keep getting errors on one server A using php 4.4.2 and it works fine on server B using php 4.4.4. Anyone know what's wrong with my code and how/where I can find out how to fix it. PHP Notice: Undefined variable: db in .../httpdocs/inc/messageboard.class.php on line 11 PHP Notice: Undefined variable: db in .../httpdocs/inc/messageboard.class.php on line 12 PHP Notice: Undefined variable: db in .../httpdocs/inc/messageboard.class.php on line 13 PHP Notice: Undefined variable: db in .../httpdocs/inc/messageboard.class.php on line 14 <?php include 'database.class.php'; class MessageBoard { var $db; var $tz_offset; var $cur_user_id; function MessageBoard ($current_user_id, $type, $host, $database, $user, $pass) { $this->$db = new database($type, $host, $database, $user, $pass); // line 11 $this->$db->debug_mode(); // line 12 $this->$db->query("SELECT timezone FROM fcms_users WHERE id = $current_user_id"); // line 13 $row = $this->$db->get_row(); // line 14 switch($row['timezone']) { case 'EDT': $this->$tz_offset = '-4 hours'; break; case 'CDT': $this->$tz_offset = '-5 hours'; break; case 'MDT': $this->$tz_offset = '-6 hours'; break; case 'PDT': $this->$tz_offset = '-7 hours'; break; case 'AKDT': $this->$tz_offset = '-8 hours'; break; case 'HST': $this->$tz_offset = '-9 hours'; break; default: $this->$tz_offset = '-4 hours'; break; } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.