
sid0972
Members-
Posts
50 -
Joined
-
Last visited
Everything posted by sid0972
-
table with multiple columns or several tables with redundant data?
sid0972 replied to sid0972's topic in MySQL Help
its like this, table 1 table 2 username username info 1 info 3 info 2 info 4 and another 6 tables main table username info 5 . . . info 15 the fields info1-info 4 will be stored repeatedly for a single user, whereas in main table they are stored only once for a single user. -
thanks for the answer. Its a bit over my head, but i have stalled this particular thing, i will read pattern matching again. now at least i know whom to catch if i get stuck .
-
table with multiple columns or several tables with redundant data?
sid0972 replied to sid0972's topic in MySQL Help
i have read about normalization , and, in a nutshell, it means that using the best possible queries to to the required job without having retrieve irrelevant data, right?? not talking about 3NF or 5NF or BCNF, they are way over my head. -
it is a member profile system, similar to bulletin boards, forums, like this one itself (phpfreaks), with much less functionality. I was asking about this do that i could store their posts in another table, and could retrieve posts according to user names and post id's.
-
i think $link wont be NULL cause of this if (strstr($link, 'http://') === false) { $link = 'http://'.$link; is this what you meant to say?? i have tried without this function included, and failed. also, this might be open for attacks, and thank you for that link, but i didnt understand how it was working. Care to elaborate?
-
<?php function score_valid($score,$link) { if (!filled_out($score)) { echo "There's something wrong. <a href=\"my_oc.php\">Go back and change it.</a>"; break; } if (strstr($link, 'http://') === false) { $link = 'http://'.$link; } if($link!==NULL) { if (!(@fopen($link, 'r'))) { echo "There's something wrong<a href=\"my_oc.php\">Go back and change it.</a>"; break; } else { return true; } } else { return true; } } ?> function filled_out function filled_out($form_vars) { foreach ($form_vars as $key => $value) { if ((!isset($key)) || ($value == '')) { return false; } } return true; }
-
tried both, didnt work
-
is there a function to check if a value is held by a variable or not?
-
as the topic says. i ALREADY have the regex to match url, what do i add to accept a NULL as well?? i have tried if(regex to match url)||NULL)) and iif(regex to match url)||'0')) but they didnt work out, any clue to what do i do?
-
cause these are the columns that will be users posts, updated regularly. I have solved the problem, the 2ndt table gets updated with username automatically when an entry in 1st table is made. On a side note, does anyone have a better table structure for this purpose??
-
yeah, but i wanted to know the query, as i do not know it myselves kinda new to mysql.
-
i am working on a website,on mysql and php. i have two tables, table 1 table 2 username pri_key username pri_key field_1 field_3 field_2 field_4 i want to update ( if not, then insert) values in table 2, all the values, referencing table 1. Like "update table 2 set username='this', field_3='....' and field_4='...' where username{from php as session variable}='name referenced from table 1'; I was wondering what would be the query for this.
-
table with multiple columns or several tables with redundant data?
sid0972 replied to sid0972's topic in MySQL Help
thank you -
table with multiple columns or several tables with redundant data?
sid0972 replied to sid0972's topic in MySQL Help
I'll explain what am i doing. I have a website, on php and mysql. 1st approach A person registers, his username is stored in 8 different tables, which contain different info about him. Referencing data becomes easier, but is very time consuming ( but, only once). 2nd approach A person registers, his username is stored only once, but that table has many columns, say about 20. Table becomes large. which one is better? I can select only the required values as you pointed out, but i would have to use "select * from table" at some places. -
the question is a little different from the title though, as i provide the constraints. If i insert a particular value in say, 8 tables, just once, and access other fields of that table many times, is it faster than having a big table with like, 20 columns, and accessing multiple fields, provided i would be using queries like " select * from table" and other time consuming queries like count of all entries in the table??
-
OK i solved it. earlier i was passing the username in the function as an argument. Now i tried taking username from session variable, $name=$_SESSION['user']. now it works, thanks for taking a look into it.
-
You are correct at one point, when details are saved i always clicked 'back', as i didnt put any 'link' there to go back. But it still does not explain that why, after coming back to the display page, details are not being displayed even after hitting refresh, as you said, but only after the current session is destroyed and new one starts. EDIT: when i log in, details are displayed correctly, no problem, but then if i click on some other link ( i have several ) and if i come back to display page, details are gone...... only show up when i log out and log in again. Does it have to do something with sessions??
-
i have created a login system using php and mysql, and it has an option to store and edit some details. when i edit and save the details, they get saved in the database, but they are not shown on the web page during that session. When i log out and log in again, then the new details are shown. i need to know why is this happening.
-
hey i have a page to edit details, and when i save the details in database the results are not reflected immediately, only when i log out and login again, the new details are shown. What could be the reason?? if it is required to post the snippet of code, please do tell.
-
well i found the solution.... i studied the basics of php and mysql thoroughly this time and got through it
-
i tried but to no avail if you want i can post the whole code here itself... tried to google also, nothing came up
-
can anyone please tell me whats wrong with my code???
-
and these are the error i get on file abc.php PHP Notice: Undefined index: abc in /var/www/work/fns/add_oc_middle.php on line 5 PHP Notice: Undefined index: valid_user in /var/www/work/fns/add.php on line 13 PHP Notice: Undefined variable: result in /var/www/work/fns/add_oc_middle.php on line 16 PHP Fatal error: Uncaught exception 'Exception' with message 'Score could not be inserted.' in /var/www/work/fns/add_oc_middle.php:22 Stack trace: #0 /var/www/work/fns/add_oc_middle.php(7): add_abc(NULL) #1 {main} thrown in /var/www/work/fns/add.php on line 22
-
hey, newbie here i am writing a code to insert some values in database, it actually worked in the afternoon, but when i started the system in the night it magically stopped working. First, i am taking the value in a text box, then forwarding it to a file to be stored in a variable, then calling a function (which is in yet another file) which stores the values in the database. the code is here text box <form action="add.php" method="post"> <center><input type="text" name="abc" size="9" maxlength="9"> <br><br> <input type="submit" value="Save"> to hold "abc" in a variable $abc=$_POST['abc']; add_abc($abc); to insert it in a database <?php session_start(); require_once('db_fns.php'); function add_abc($abc) { $valid_user = $_SESSION['valid_user']; $conn = db_connect(); if ($result && ($result->num_rows>0)) { throw new Exception('already exists.'); } if (!$conn->query("insert into scores (username,abc) values ('".$valid_user."', '".$abc."')")) { throw new Exception('could not be inserted.'); } else { echo "successful";} return true; can anyone please tell me whats wrong here??