PHP - Is Something Limiting Mysql_query Insert Into ~ I Need Help
Ok so here's my code first the ajax/javascript, secondly the php. Issue i'm having is that first it wasn't entering any data into my database then eventual through much troubleshooting I figured out that if I add more then 10 variables in my INSERT INTO query it wont work. Ten or less and it works perfect. I CAN NOT figure this out?! Note, at the bottom of the php script I have the script that I would like to work, commented out, and the script that is currently working, active. You can see it only has 10 working entries.
Code: [Select] function entervehicle(){ var stk = document.getElementById("stk").value var my = document.getElementById("my").value var mak = document.getElementById("mak").value var mod = document.getElementById("mod").value var mil = document.getElementById("mil").value var pri = document.getElementById("pri").value var bst = document.getElementById("bst").value var len = document.getElementById("len").value var eng = document.getElementById("eng").value var dor = document.getElementById("dor").value var tra = document.getElementById("tra").value var gvw = document.getElementById("gvw").value var inc = document.getElementById("inc").value var exc = document.getElementById("exc").value var cfo = document.getElementById("cfo").value var titl = document.getElementById("titl").value var desc = document.getElementById("desc").value var vin = document.getElementById("vin").value var pic1 = document.getElementById("pic1").value var pic2 = document.getElementById("pic2").value var pic3 = document.getElementById("pic3").value var pic4 = document.getElementById("pic4").value var pic5 = document.getElementById("pic5").value var pic6 = document.getElementById("pic6").value var pic7 = document.getElementById("pic7").value var pic8 = document.getElementById("pic8").value var pic9 = document.getElementById("pic9").value var linksubmit ="../php/entervehicle.php?stk=" + stk +"&my=" + my +"&mak=" + mak +"&mod=" + mod +"&mil=" + mil +"&pri=" + pri +"&bst=" + bst +"&len=" + len +"&eng=" + eng +"&dor=" + dor +"&tra=" + tra +"&gvw=" + gvw +"&inc=" + inc +"&exc=" + exc +"&cfo=" + cfo +"&titl=" + titl +"&desc=" + desc +"&vin=" + vin +"&pic1=" + pic1 +"&pic2=" + pic2 +"&pic3=" + pic3 +"&pic4=" + pic4 +"&pic5=" + pic5 +"&pic6=" + pic6 +"&pic7=" + pic7 +"&pic8=" + pic8 +"&pic9=" + pic9 alert(linksubmit); var entrequest = getHTTPObject(); if(entrequest) { entrequest.open("GET",linksubmit,true); entrequest.onreadystatechange = function(){ entveh(entrequest); }; entrequest.send(null); } } function entveh(entrequest){ if(entrequest.readyState == 4){ if(entrequest.status == 200){ var myPHP = entrequest.responseText; document.getElementById("adminmain").innerHTML = myPHP; } } } <?php $stk = $_GET['stk']; $my = $_GET['my']; $mak = $_GET['mak']; $mod = $_GET['mod']; $mil = $_GET['mil']; $pri = $_GET['pri']; $bst = $_GET['bst']; $len = $_GET['len']; $eng = $_GET['eng']; $dor = $_GET['dor']; $tra = $_GET['tra']; $gvw = $_GET['gvw']; $inc = $_GET['inc']; $exc = $_GET['exc']; $cfo = $_GET['cfo']; $titl = $_GET['titl']; $desc = $_GET['desc']; $vin = $_GET['vin']; $pic1 = $_GET['pic1']; $pic2 = $_GET['pic2']; $pic3 = $_GET['pic3']; $pic4 = $_GET['pic4']; $pic5 = $_GET['pic5']; $pic6 = $_GET['pic6']; $pic7 = $_GET['pic7']; $pic8 = $_GET['pic8']; $pic9 = $_GET['pic9']; require("database.php"); $tresult = mysql_query("INSERT INTO automobile_stat (stock_number,model_year, make, model, miles, price, body_style, length, description, trans) VALUES ('$stk', '$my', '$mak', '$mod', '$mil', '$pri', '$bst', '$len', '$desc', '$tra')"); /*$tresult = mysql_query("INSERT INTO automobile_stat (stock_number, model_year, make, model, miles, price, body_style, length, description, engine, doors, trans, gvw, int_color, ext_color, car_fax_owner, title_desc, main_picture_src, vin) VALUES ('$stk', '$my', '$mak', '$mod', '$mil', '$pri', '$mpri', '$bst', '$len', '$desc', '$eng', '$dor', 'tra', '$gvw', '$inc', '$exc', '$cfo', '$titl', 'img', '$vin')");*/ /*$tresult=mysql_query("SELECT * FROM automobile_stat" ); $countrows = mysql_num_rows($tresult); while($row = mysql_fetch_array($tresult)){ echo $row[stock_number]; }*/ mysql_close($linkID); ?> Similar TutorialsHi... Before I have no problem in using On Duplicate Key, but now i have because of using time function. Before I only have insert query: Code: [Select] $result = mysql_query("INSERT INTO regular_sum_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM regular_dtr_total GROUP BY EMP_NO") or die(mysql_error()); And now I think that I need to add a syntax for Update, so i revise my code: Code: [Select] $result = mysql_query("INSERT INTO regular_sum_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM regular_dtr_total GROUP BY EMP_NO ON DUPLICATE KEY EMP_NO = EMP_NO, Hours = sec_to_time(SUM(time_to_sec(Rendered)))") or die(mysql_error()); and I got a problem in this part: Hours = sec_to_time(SUM(time_to_sec(Rendered)))") Thank you Hi, why won't this work, there is no error messages so it gets to this point, but won't redirect??? (Obviously a lot is missed out here) $query = mysql_query("SELECT * FROM `users` WHERE `username`='$username'"); if ($username==$dbusername&&$password==$dbpassword) { $_SESSION['user'] = $username; while($row = mysql_fetch_array($query)){ $type = $row['Type']; if ($type=="0") { header("Location: chefpanel.php"); }else{ header("Location: restpanel.php"); } } } else $errors[] = 'Password Incorrect'; } else $errors[] = 'Username Incorrect'; Hey Guys, Im having problems with my code. What im trying to do is run a mysql query and show the results, but if the query returns no data, echo out "No incoming requests!" Here is my code: <? $check = "SELECT * FROM requests WHERE club='" . $_SESSION['club'] . "' AND team='" . $_SESSION['team'] . "' AND accepted='0'"; $result=mysql_query($check); if (mysql_num_rows($result) == 0) { while ($getinfo = mysql_fetch_array($result)) { $time = $getinfo["time"]; $who = $getinfo["player_name"]; $whofor = $getinfo["toplayfor"]; $from = $getinfo["team"]; $idp = $getinfo["player_id"]; echo "<a href='profile.php?id=".$idp."&team=".$from."'>".$who." </a><div style='float:right;'>(".$from.")</div><br />"; echo "<div style='margin-top: 2px;'></div>"; echo date('l, F jS, g:ia',$time); echo "<br /><div style='margin-top: 2px;'></div><a href='accept.php?playerid=".$idp."&toplayfor=".$whofor."'>Accept</a> | Decline"; echo "<div id='newsline'></div>"; } } else { echo 'No incoming requests'; } ?> Could someone help me out here? Thanks Heaps! OK So I have a quick question... how would I go about making a query like: mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND key='$key' "); You see, theres an error: Quote You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' key='1234' LIMIT 1' at line 1 I know this is a simple issue, and I know you cant keep creating AND's inside the query, but how would I do it? I've never attempted to use more than one AND before, so its new to me even though I'm a experienced PHP Developer. Thanks in advance! Hey guys, I've been playing around with this open source php game, I'm having problems with the registration system. For some reason the script is echoing back that there is no password in the password fields. When in fact there is: Add_player.php: Code: [Select] <?php session_start(); session_register("pid"); include("common.inc"); include("date.inc"); include("header.inc"); dbConnect(); $res = mysql_query("select id from $dbName.pdm_players where name=\"$name\"") or die(mysql_error()); if ($name == "" || $password1 == "") { echo "<center><div class=\"sheader\">Oh dear me!</div> You have to actually enter a name and password!"; $name = ""; include("character_form.inc"); echo "</center>"; include("footer.inc"); return 0; } if ($name == $password1) { echo "<center><div class=\"sheader\">Oh dear me!</div> You can't make the password the same as the name. People will guess your password!"; include("character_form.inc"); echo "</center>"; include("footer.inc"); return 0; } if (strlen($password1) < 6) { echo "<center><div class=\"sheader\">Oh dear me!</div> Passwords must be at least 6 characters, otherwise they are easy to guess!"; include("character_form.inc"); echo "</center>"; include("footer.inc"); return 0; } if (mysql_fetch_row($res)) { echo "<center><div class=\"sheader\">Oh dear me!</div> Player $name already exists, try a different name."; $name = ""; include("character_form.inc"); echo "</center>"; include("footer.inc"); return 0; } if ($password1 != $password2) { echo "<center><div class=\"sheader\">Oh dear me!</div>"; echo "The two passwords didn't match - type carefully now!."; include("character_form.inc"); echo "</center>"; include("footer.inc"); return 0; } echo "<div class=\"sheader\">Registration for $name successful</div>"; $cp = crypt($password1); $dateArray = getdate(time()); $likeNowScoob = $dateArray["year"] . "-" . $dateArray["mon"] . "-" . $dateArray["mday"]; if ($character < 1 || $character > 9) { die("you are an idiot"); } pdm_characters(); $res = mysql_query("select type from $dbName.pdm_characters where cid = $character") or die(mysql_error()); $t = mysql_fetch_row($res); pdm_stuff(); $specRes = mysql_query("select sid from $dbName.pdm_stuff where sid >= 28 and sid <= 33 and type like \"%$t[0]%\"") or die(mysql_error()); $res = mysql_query("BEGIN") or die(mysql_error()); $res = mysql_query("insert into $dbName.pdm_players (name, used, dob, cpass, char_id, roundswon, evo, aWeapon, dWeapon) VALUES (\"$name\", 1, \"$likeNowScoob\", \"$cp\", $character, 0,0,0,0)") or die(mysql_error()); $res = mysql_query("select id from $dbName.pdm_players where name=\"$name\" for update") or die(mysql_error()); $row = mysql_fetch_row($res); $pid = $row[0]; $res = mysql_query("insert into $dbName.pdm_league (id, highest, days_no_1, yesterday, longPoints) VALUES ($pid, 16777215, 0, 16777215, 0)") or die(mysql_error()); $res = mysql_query("insert into $dbName.pdm_stats (id, level, attack, defence, health, speed, exp, ko, healthpercent, fights) VALUES ($pid, 1, 100, 100, 100, 100, 0, 0, 10, 0)") or die(mysql_error()); $res = mysql_query("insert into $dbName.pdm_clanmembers2 (id, clanTag, applyTag, utype) VALUES ($pid, NULL, NULL, '')") or die(mysql_error()); $res = mysql_query("insert into $dbName.pdm_money (id, bank, wallet, bankdate) VALUES ($pid, 0,0, '0000-00-00')") or die(mysql_error()); while ($row = mysql_fetch_row($specRes)) { $res = mysql_query("insert into $dbName.pdm_specials (id, sid, qty, switch) values ($pid, $row[0], 0, 1)") or die(mysql_error()); } $res = mysql_query("COMMIT") or die(mysql_error()); session_register("playerName"); $playerName = stripper($name); echo "<P><diV>Welcome $playerName, click the Fight link down the left to fight your first opponent.</div>"; include("main_screen.inc"); include("footer.inc"); ?> Character_form.inc: Code: [Select] <center> <form method="post" action="add_player.php"> <P> <table cellpadding="0" cellspacing="0"><tr><td align="center"> <?php dbConnect(); pdm_characters();#check HEAP table exists $res = mysql_query("select cid, name, type from $dbName.pdm_characters order by type") or die(mysql_error()); $marker = "X"; $firstOne = 1; $cTypes["A"] = "Alien"; $cTypes["M"] = "Magic"; $cTypes["S"] = "Spirit"; while ($row = mysql_fetch_row($res)) { if ($marker != $row[2]) #new type (alien/magic etc) { if ($marker != "X") { echo "</table>\n"; } $cn = $cTypes[$row[2]]; echo "\n<table cellpadding=\"0\" cellspacing=\"0\" border=1> <tr><td colspan=\"3\" align=\"center\"><div class=\"sheader\"> $cn characters</div></td></tr><tr bgcolor=\"#efefef\">"; $marker = $row[2]; } echo "\n<td><table><tr><td align=center>$row[1]</td></tr><tr><td align=center> <img alt=\"Pick me!\" src=\"images/$row[0]0.gif\"></td></tr><tr> <td align=center><input type=\"radio\" name=\"character\" value=\"$row[0]\""; if ($firstOne and $character == "") { $firstOne = 0; echo " CHECKED "; } if ($character == $row[0]) { echo " CHECKED "; } echo "></td></tr></table></td>"; } echo "</tr></table> <table width=\"551\" cellpadding=0 cellspacing=0><tr><td colspan=\"3\"><div class=\"sheader\">character details</div></td></tr> <tr><td align=\"center\">Name<br><input size=20 maxlength=20 type=text name=\"name\" value = \"$name\"></td>"; ?> <td align="center">Password<br><input type="password" name="password1" size=20 maxlength=20></td> <td align="center">Password again<br><input type="password" name="password2" size=20 maxlength=20></td></tr> <tr><td colspan="3" align="center"><input type="submit" value="Register my character"></td></tr></table> </td></tr></table> <hr> </form> </centER> Anyone able to offer up any advice or where its going wrong, If I remove the validation stuff, it still doesn't insert the user into the database. Cheers I am getting a "mysqli_query() expects parameter 1 to be mysqli, null given" error. the code I am using is below but simplified. connect() does connect to the database without throwing any errors but when I get down to query() I get the above error. public function connect() { mysqli_connect(self::DBHOST, self::DBUSER, self::DBPASS, self::DBNAME); } public function query($query) { mysqli_query(self::connect(), $query); } below is what I am using to call the function. I am not sure if I have to pass the $link in the query function too. I have tried but it didn't seem to do any better. $link = db::connect(); $query = "SELECT name FROM plugins"; db::query($query); I am sure this is something simple that I have overlooked but I am new to this and still learning. Thank you for any help you can provide. Im not sure f this is the right spot for this or not but... I have a website that has a content box that has a fixed height and width. How would i make it so after the box is full it puts a link to read more at the bottom of it? Also images may be used as well. Its also for a wordpress blog OMG! Crafting well thought out business logic is such a PITA sometimes! I am working on an ecommerce site that sells subscriptions, books, gear, etc. Similar to a lot of online newspapers, I have a "Subscribe" button in my website mast where people can buy a subscription. After clicking on that button, the user is first presented with different subscription offers (e.g. sliver, gold, platinum), and then I have a one-page checkout form where they create an account - kind of important for an online subscription! - and they pay with a credit card. Easy! Trying to be a nice guy, I decided to add the ability to choose a subscription from my online store as well. (Presumably you want to offer as many ways for people to buy things from you as possible, right?) Well here is the issue I just discovered... What happens if a person is browsing through my product catalog, and they add multiple subscriptions to their shopping cart? Of course I would welcome the extra $$$, but I just realized that would break how people create their accounts and pay, because above I assume that ONE person, buys ONE subscription and pays for it in ONE transaction. So my questions is, "Would it be a mortal sin to limit people to buying only ONE subscription at a time if they do so while in my online store?" I would hope that people would get that, but as we know, users do some crazy stuff!! In fairness, if you went to buy a subscription at the Wall Street Journal or any other large newspaper/magazine, you would be forced to do one subscription per transaction. I am just wondering what happens if someone goes on a shopping spree in my online store, buys several books, some t-shirts, and decides he/she also wants to buy 5 subscriptions on the spot. Thoughts?
Hi, I am wondering if it is possible to monitor how long someone is on a website for and to limit them for example: 30 minutes. An example of this would be one of those Tv Online websites which allow you to only watch 30 minutes of video time. If you try refreshing the page it will still not allow you. My question is, Is it an ip check which does this? Sorry If it such a broad topic. Nick hey I am still little new in php can you help me in this one func.php function confirm_query($result_set){ if(!$result_set){ die(mysql_error()); } function get_subjects_all() { global $connection ; $sub_query = "SELECT * FROM subjects ORDER BY position ASC"; $subject_query = mysql_query($sub_query,$connection); confirm_query($subject_query) ; return $subject_query; } function get_pages_all($subject_id) { global $connection; $query = "SELECT * FROM pages WHERE subject_id = '$subject_id' ORDER BY position ASC"; $page_set = mysql_query($query, $connection); confirm_query($page_set); return $page_set; } test.php require_once("config.php"); require_once("func.php"); $subject_query = get_subjects_all(); while($subject = mysql_fetch_array($subject_query)) { echo "<a href= \"test.php?subj=" . urlencode($subject["id"]) . "\">{$subject['menu_name']} <br />"; } $an = $subject["id"] ; $page_set = get_pages_all($an); while($page = mysql_fetch_array($page_set)) { echo "<a href = \"test.php?page=" . urldecode($page["id"]) . "\">{$page['menu_name']} </a><br />" ; // echo "<b> <a href= '1.php?page={$page['id']}' >{$page['menu_name']} </a></b> <br />"; } in this line WHERE subject_id = '$subject_id' the query don't work and gives me sql error i tried with this one ' ".$subject_id." ' but not worked but if i changed $subject_id to a number it work and read the data from the table thanks in advanced . I'm pretty new to PHP and I'm having trouble inserting data into my database from a webpage. Here is the code. The error is on the lines with $query and $result. The error comes back: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/76/5697876/html/corbinreynolds/insert.php on line 39 Lost connection to MySQL server at 'reading initial communication packet', system error: 111 I've been working at this for hours and can't seem to figure this out. Any ideas? <?php $first=$_POST['first']; $last=$_POST['last']; if (!$first || !$last) { echo 'Error: Enter the required data.'; exit; } if (!get_magic_quotes_gpc()) { $first = addslashes($first); $last = addslashes($last); } $hostname = '127.0.0.1'; $username = 'root'; $password = 'root'; $dbname = 'phonebook'; @ $db = mysql_connect($hostname,$username.$password,$dbname); if (mysqli_connect_errno()) { echo 'Errer: Could not connect to database'; echo '<br>'; echo mysqli_connect_error(); exit; } $query = "INSERT INTO contact (first,last) VALUES ('$first','$last')"; $result = mysql_query($query,$db) or die(mysql_error()); if ($result) { echo $db->affected_rows." contact inserted into the database"; echo 'Contact Entered: '.$first.' '.$last.''; } else { echo 'Error: Contact not added.'; exit; } echo 'Closing Database'; $db->close(); ?> I've got a very simple script that records IP address of every page view. Here is the script: $ip = $_SERVER['REMOTE_ADDR']; $query = "INSERT INTO tracking VALUES ('', '1', '$ip')"; echo $query; echo ("<hr>"); if (mysql_query($query)) { echo ("INSERT OK"); } else { echo ("INSERT failed"); } FYI: the 1st value is "auto_increment" in the DB, therefore blank ('') in the query string, and the 2nd value "1" is just for the page number 1, as this script will be on other pages, with different numbers. Now, when I go to this page, it outputs the query, and hr, and then "INSERT failed" and sure enough, no record gets added to the DB. The strangest thing is, is that when I copy the query that the page shows, and paste it into mysqlPHPadmin's "SQL" section and run it, it executes fine, and a record gets added to the DB, however the page is unable to do that. Any ideas? PS: the connection (which I didn't paste in here) is fine, that's definitely not the problem. I'm hoping someone can help me cos my hair's going white with this one. I'm trying to put together a script that acts as web-based interface to an SQL server. There are actually two parts, admin.htm and admin.php. The first part is just a form that passes login credentials to the PHP file. That part seems to work fine, but I'll post the source anyway: - Code: [Select] <!DOCTYPE HTML> <html lang="en"> <head> <title>SQL admin login</title> <meta charset="iso-8859-1" /> </head> <body> <form action="admin.php" method="post"> <label for="username">Username: -</label> <br /> <input type="text" name="username" id="username" /> <br /> <br /> <label for="password">Password: -</label> <br /> <input type="password" name="password" id="password" /> <br /> <br /> <label for="server">Server: -</label> <br /> <input type="text" name="server" id="server" /> <br /> <br /> <label for="database">Database: -</label> <br /> <input type="text" name="database" id="database" /> <br /> <br /> <input type="submit" value="Login" /> <input type="reset" value="Reset" /> </form> </body> </html> Following is the content of admin.php. By this point I can see the connection in MySQL Workbench, and when I submit the query 'SELECT * FROM subscribers' it's being stored in '$_POST['query']', but 'mysql_query($_POST['query'],$_SESSION['con']);' is returning nothing. There is definitely a record in that table, and the user I'm logging on with has permission to run the 'SELECT' command against this database, so I can't figure out why mysql_query(); is returning nothing: - Code: [Select] <!DOCTYPE HTML> <?php session_start(); if(!$_SESSION['con']) { if(!($_POST['username'] || $_POST['password'])) { if(!($_SESSION['username'] || $_SESSION['password'])) { $error="Username and password variables empty."; } } else { $_SESSION['username']=mysql_real_escape_string($_POST['username']); $_SESSION['password']=mysql_real_escape_string($_POST['password']); $_SESSION['server']=mysql_real_escape_string($_POST['server']); $_SESSION['database']=mysql_real_escape_string($_POST['database']); $_SESSION['con']=mysql_pconnect($_SESSION['server'],$_SESSION['username'],$_SESSION['password']); if(!$_SESSION['con']) { $error="Failed to connect to server."; } else { $database=mysql_select_db($_SESSION['database'],$_SESSION['con']); if(!$database) { $error="Failed to connect to database."; } } } } if(!$_POST['query']) { $error="No query submitted."; } else { $result=mysql_query($_POST['query'],$_SESSION['con']); if(!$result) { $error="Query returned nothing."; } } ?> <html lang="en"> <head> <title>SQL admin interface</title> <meta charset="iso-8859-1" /> </head> <body> <form action="admin.php" method="post"> <textarea name="query" rows="10" cols="50">SELECT * FROM subscribers</textarea> <br /> <br /> <input type="submit" value="Submit query" /> </form> <?php if($error) { echo $_POST['query']."<br /><br />".$result."<br /><br />".$error; die(); } else { while($row=mysql_fetch_assoc($result)) { echo $row['name']." ".$row['email']; echo "<br />"; } } ?> </body> </html> Can anyone help? MOD EDIT: [code] . . . [/code] tags added. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=328375.0 Is there something wrong this? If so, I'm not seeing it...I keep getting this error: Quote ( ! ) Parse error: syntax error, unexpected T_STRING in C:\Program Files\wamp\www\register.php on line 1059 Here's my code for registering a member: Code: [Select] <?php mysql_query (INSERT INTO fans (id, username, email, password, country, region, gender, status, account, subscription, time_registered, date_registered, birthdate, name, website, age, activation_key) VALUES ('', '{$_SESSION["user"]["username"]}', '{$_SESSION["user"]["email"]}', '{$_SESSION["user"]["password"]}', '{$_SESSION["user"]["country"]}', '{$_SESSION["user"]["region"]}', '{$_SESSION["user"]["gender"]}', 'Offline', 'Inactive', 'Unsubscribed', '{$_SESSION["user"]["time"]}', '{$_SESSION["user"]["date"]}', '{$_SESSION["user"]["birthdate"]}', '{$_SESSION["user"]["name"]}', '{$_SESSION["user"]["website"]}', '{$_SESSION["user"]["age"]}', '{$_SESSION["user"]["activation_key"]}')) or die ("Could not register member"); ?> Help, please and thank you! function wsProcessClientMessage($clientID, $opcode, &$data, $dataLength) { global $wsClients; // check opcodes if ($opcode == WS_OPCODE_PING) { // received ping message return wsSendClientMessage($clientID, WS_OPCODE_PONG, $data); } elseif ($opcode == WS_OPCODE_PONG) { // received pong message (it's valid if the server did not send a ping request for this pong message) if ($wsClients[$clientID][4] !== false) { $wsClients[$clientID][4] = false; } } elseif ($opcode == WS_OPCODE_CLOSE) { // received close message if (substr($data, 1, 1) !== false) { $array = unpack('na', substr($data, 0, 2)); $status = $array['a']; } else { $status = false; } if ($wsClients[$clientID][2] == WS_READY_STATE_CLOSING) { // the server already sent a close frame to the client, this is the client's close frame reply // (no need to send another close frame to the client) $wsClients[$clientID][2] = WS_READY_STATE_CLOSED; } else { // the server has not already sent a close frame to the client, send one now wsSendClientClose($clientID, WS_STATUS_NORMAL_CLOSE); } wsRemoveClient($clientID); } elseif ($opcode == WS_OPCODE_TEXT || $opcode == WS_OPCODE_BINARY) { // received text or binary message if (function_exists('wsOnMessage')) wsOnMessage($clientID, $data, $dataLength, $opcode == WS_OPCODE_BINARY); } else { // unknown opcode return false; } return true; } Hey there - I have been trying to limit the number of comments a user can make per day on my social network. Thanks to great help on here I am getting really close, however, there are some bugs that have me banging my head against the wall. I am able to limit, but now, its 1. not limiting PER day and limiting all around ( meaning: I can't make any comments at all today ) 2. it is limiting for EVERY user as opposed to limiting a specific user Here is the code I have: Code: [Select] if(isset($_POST['commentProfileSubmit'])) { if($_POST['ProfileComment'] == "" || $_POST['ProfileComment'] == "Tell the community what's on your mind...") { $valid = false; $error_msgs_comments[] = "Whoops! You forgot to write your airwave."; }else{ if($_POST['ProfileComment'] == "" || $_POST['ProfileComment'] == "Leave ".$prof->first_name." a comment here...") { $valid = false; $error_msgs_comments[] = "Whoops! You forgot to write your comment."; }else{ /* if the person signed in is NOT the profile */ $query = "SELECT * FROM `cysticUsers` WHERE `id` = '" . $prof->id . "'"; $request = mysql_query($query,$connection) or die(mysql_error()); $result = mysql_fetch_array($request); $max_post_per_day = 5; $Email = $result['Email']; $check_profi = $result['check_profi']; $check_reply = $result['check_reply']; if($prof->id != $auth->id && $check_profi == 'checked' && $max_post_per_day < 5) { $to = $Email; $subject = "$auth->first_name $auth->last_name commented on your profile on CysticLife"; $message = "$auth->first_name $auth->last_name commented on your profile on CysticLife: <br /><br />\"$body\"<br /><br /> <a href='http://www.cysticlife.org/Profile_build.php?id=" . $prof->id . "'>Click here to view</a><br /><br />Do LIFE,<br /> The CysticLife Team"; $from = "CysticLife <noreply@cysticlife.org>"; $headers = 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n"; $headers .= "From: $from"; mail($to, $subject, $message, $headers); } $query = "SELECT COUNT(*) FROM `CysticAirwaves` WHERE `FromUserID` = $auth->id AND `date` = CURDATE()"; $result = mysql_query($query, $connection); $post_count = mysql_result($result, 0); if($post_count >= $max_posts_per_day) { echo "You have reached the maximum number of posts for the day. Try again tomorrow"; } else { $comment = mysql_real_escape_string($_POST['ProfileComment']); $query = "INSERT INTO `CysticAirwaves` (`FromUserID`, `ToUserID`, `comment`, `status`, `statusCommentAirwave`, `date`, `time`) VALUES ('{$auth->id}', '{$prof->id}', '{$comment}', 'active', 'active', CURDATE(), CURTIME())"; mysql_query($query, $connection) or die(mysql_error()); } if($auth->id == $prof->id) { $just_inserted = mysql_insert_id(); $query = "UPDATE `CysticAirwaves` SET `status` = 'dead' WHERE `FromUserID` = '" . $auth->id . "' AND `ToUserID` = '" . $prof->id . "' AND `id` != '" . $just_inserted . "'"; $request = mysql_query($query,$connection); } } } } thanks so much in advanced Hi. Trying to use the "Excerpt or Content Word Limit in WordPress: Redux" code to limit my Amazon product description content but to no avail. Getting the "Fatal error: Call to undefined function content() in index.php on line 36". The following is the code in the index.php file that makes the call: " <div class="post-content"> <?php content(30); ?> <!-- <?php the_post_excerpt($excerpt_length=30); ?> --> </div><!-- POST CONTENT --> " The functions.php file is quite large but I attached it so anyone who would like to take a look at it. Can anyone tell why it's not finding the function 'content'? Thanks! Following on from the excellent help in the thread at http://www.phpfreaks.com/forums/php-coding-help/using-a-generated-row-number-in-another-query I have another question regarding the League Standings that are generated there. I want to have another version that limits the records to the last 5 games for each team. Just using 'LIMIT 5' would return the first five teams and all their records but I want it to retrieve all of the teams and each teams last five records (games). The easy way would be to restrict a the dates but as games get postponed and moved using WHERE with a specific date would not guarantee the same number of games for each team. There is the possibility that this could be done via the query but I have not come across anything in some quite extensive searching (although, once again, I do not know if I am using the right search terms!) so I assume PHP would, once again be the saviour! Thanks in advance for any suggestions. Steve |