-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
Single or double quoted strings in PHP/HTML (" and ')
Muddy_Funster replied to skew's topic in PHP Coding Help
PHP processes the contents of single and double quotes differenttly! single quotes define a litteral string, double quotes deffine a dynamic string (that's just what I have been calling it for a while now, can't remember the real name for it). try running the following code to see better what I am talking about. eg <?php $stringVariable = 'HELLO WORLD'; echo 'This line is wrapped in single quotes and as you can see -- $stringVariable -- does not get proccessed'; ehco "<BR><BR>"; echo "this line is wrapped in double quotes and as you can see --$stringVariable -- does get proccessed"; ?> I would personaly suggest that you do not get into the habbit of Nodral's suggestion on mix and match for SQL. Use double quotes to have variables proccessed within the string, otherwise use single quotes, and if you need to contain single quotes within your string escape them properly. -- That is purely my opinion and not to be taken as any suggestion of being the "proper" way of doing it. Meh- I type too slow -
facebook style messaging system based on conversations
Muddy_Funster replied to jonniejoejonson's topic in MySQL Help
Just a matter of hardware, MySQL is probably the most scalable DB format available at the moment. -
mandatory for what? set field to: int(3), ZEROFILL, UNSIGNED, AUTO INC
-
1. use code tags when posting code 2. the offending line and the one before and after are very VERY rarely enough to diagnose the problem 3. 2 is perticularly true when the directly preceding line is commented out 4. generaly people include a form of question in their post....
-
your function show error at the end is using a variable named $myError - I cant see where, from the code given, that variable is actualy declaired. Also - are you absoloutly certain you want to run exit(); from within the function (not that it's a problem, just something that's worth thinking about)? P.S. - the ACTUAL error message is always appreciated
-
Selecting from 2 tables with one reference table
Muddy_Funster replied to axl8910's topic in MySQL Help
Why do you "need" to? That's just forcing bad practice. What do you get from the following? SELECT username, phone, name as FlexiName, status, PLC FROM flexi_allocation RIGHT JOIN flexi ON (flexi_allocation.flexiID = flexi.ID) RIGHT JOIN user ON flexi_allocation.user_id = user.user_id) WHERE flexi_allocation.flexi_id IS NOT NULL ORDER BY flexi_allocation.flexi_id ASC Obviously change field and table names as needed. -
Manipulating POST variables between pages
Muddy_Funster replied to tmoby8's topic in PHP Coding Help
sounds like you are seeking the all mighty $_SESSION[] variable Seriously though, if you want to keep variables for more that 1 page onto the next (that includes any page refresh) you should be using either session variables or a server side data store (such as flat file csv or database backend). Session variables are by far the easiest to work with. Just remember to declare the session open at the start of each page you need to use. -
facebook style messaging system based on conversations
Muddy_Funster replied to jonniejoejonson's topic in MySQL Help
a few hundred thousand shouldn't put any noticable strain on resources as long as everything is indexed properly (and as long as you never use SELECT * of course ) -
a long column or several short columns in mysql?
Muddy_Funster replied to etrader's topic in PHP Coding Help
Rule of thumb - have a different field for each piece of data you want to store. -
look into the include_once function
-
You want to take a proper look into the $_SERVER[] variable.
-
Fair point indeed, I hadn't payed attention to what I was doing (too much haste). Problem I was trying to address was that the OP had commented out the lines that assigned $username and $password - and still used them as a verification for the connection string to be called. Thus it's not going to work.
-
no worries
-
Yes....how about:
-
and what do you get with: <?php session_start(); require_once("wsconfig/config.php"); $username = mysqli_real_escape_string($dbc, ($_POST['username'])); $password = mysqli_real_escape_string($dbc, ($_POST['password'])); if ($username&&$password) { $dbc = mysqli_connect($dbhost,$dbuser, $dbpass, $db) or die('Error connection'); $query = "SELECT username, password FROM account where username ='".$username."' and password='".$password."'"; $data = mysqli_query($dbc, $query); $numrows = mysqli_num_rows($data); if ($numrows!=0) { while($row = mysqli_fetch_assoc($data)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername && $password==$dbpassword) { $_SESSION['username'] = $dbusername; header('Location: Admin.php'); } else echo "Incorrect password"; } else die("That user does not exist"); } else die("Invalide login") ?>
-
Add an insert into for the comments table into the sql you are using for the financials one.
-
normaly I wouldn't bother, but you missed the closing ) on it wants to be $username=mysql_real_escape_string($_POST['username']);
-
I take it your not using mysql_real_escape_string() on your form inputs then?
-
Selecting from 2 tables with one reference table
Muddy_Funster replied to axl8910's topic in MySQL Help
Yup - with the information you have given there is also no need for the additional link table, you could allocate the id_flexi to a field in the user table and save some effort. -
facebook style messaging system based on conversations
Muddy_Funster replied to jonniejoejonson's topic in MySQL Help
the threads table I suggested would allow you to limit conversations to singular events per user group - the way you want to do it - and give a limited threadID. example: Existing User Table - take the uID Create a new "threadStatus" table: threadID - Custom Genrated as mentioned in last post Status - int/bool/enum (whatever you like) - indexed, normal Create a new "threads" table Fields: recordID - int, auto inc, PK threadID - ForignKey index Generated In ThreadStatus table set with "On Update - Cascade" uID - taken from the Users table - indexed, normal When a conversation is started you make a new record in the threadStatus table with just the threadID. Next Update the threadStatus Seting it to whatever you want to use for "open". Then you make a new record with the same threadID for each uID that is part of the conversation in the "threads" table. This ties all the users to a single manageable threadID without needing to delimit the contents of the field with underscores. I have put that theadStatus.status and threads.uID are indexed as I assume at some point you will want to see "how many users are in an open conversation" or "how many conversations is user x currently taking part in" -
facebook style messaging system based on conversations
Muddy_Funster replied to jonniejoejonson's topic in MySQL Help
1: As it stands there is no field there that would be viable as a primary key 2: Main difference would be that if you change it to an int field you loose the ability to have a seporator, in your case the underscore, that is anything other than numerical. As the rest of the information is also numerical you would have to make a complex number string as the delimiting refference which would be more detremental than good. 3: Lots. From the ground up it looks too clumsy - e.g. what happens when the same group of people want to start a second conversation without closing the first? How are you dealing with the possability of new people joining into an existing conversation, or one person dropping out while the others continue without them? - I would change from assigning members to a conversation and would rather assign conversations to members. I would have the thread table, having thread_ID as an indexed field (without much thought I would generate the id as a combination of creating memberID and currentDateTime) I would then use that to make a refference list of members that are associated with the thread. Include a status option for each member for things like "invited", "participant", "reader"...etc so that different statuses can be assigned to different members depending on what the creator member chooses for them. This lets members then "opt out" or "request invite" to conversations. Other than that the other changes I would make would be dependant on factors that you havn't provided information about in the post, You have a good idea, and it will run with the setup that you have, but I think it would be better (and make life down the raod much easier) with some changes. -
You need to refference the field directly in the group by, don't bother with the fact that you are extracting the Year and Month from it in the select, just group by the field. Having said that, it will get rid of that specific error, but I have a suspicion that won't get you the result set that you are looking for. Group By in MSSQL is a bit convoluted when compaired to MySQL, you would be well set to reasearch the function in deapth. You have to explicitly name every field that does not have and agrigate function run against it (ie SUM / AVG / STDEV / MIN / MAX etc) in order.
-
using cookies not an option?
-
I think he actualy wants the full contents of <div id='memcontainer'> to apear in two by x format, rather than 1 by x format as opposed to using a table in place of the memcontainer object. On another note - if you are calling the same <div> more than once on a given page, you really should make it a class not an id - id's are designed to be unique and as such should only appear once on a page.
-
1st rule of using header: you can NOT output anything to screen before you call it. does that help?