Jump to content

pallevillesen

Members
  • Posts

    135
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Denmark

pallevillesen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Typo in code... CHeck the resulting page source.... <form action="egyptian2.php" method=post> <select name="Display" id="Display"> while( = mysql_fetch_array()) { echo \'<option value="\', , \'">\' , , \'</option>\'; } </select> <input type="submit" name="Display" value="Display"> P.
  2. You have to join the two tables results and teams like WHERE t.team_id = r.team_id or something similar... I don\'t see why you get team_id anyway (since awayteam and hometeam probably are team ids anyway ?) But if you insist, then you must join the two tables in a WHERE clause or do a straight JOIN... (rtfm on syntax). P.
  3. select o.user_id, t.team_name from owners u, teams t WHERE o.team_id = t.team_id; Would join the two tables correctly together. If you have entered an owner which have a nonexisting team_id (i.e. the team_id number does not exist in the teams table) - then this owner will NOT be returned... If you want them to come back as well you must do a left join: select o.user_id, t.team_name from owners u LEFT JOIN teams t ON o.team_id = t.team_id; Here all owners will be returned having a team_name of NULL if it is not defined in the teams table... P.
  4. Instead of echo $query, try and say this: echo \"X\".$user.\"X<P>\"; Check carefully if your db contains what it is supposed to. And... this is NOT a good way to do mysql lookups... it way too slow... You should get your joins to work properly instead, and the original code is good... I don\'t have your full original code and unfortunately no time... I\'m back friday, so if you\'re still stuck then post your full code and a \"describe article\", \"describe user\" (sql statements, so we may copy your db schema) then I\'ll have a look. But I\'m pretty sure this is a data problem, not an sql problem (if you understand what I mean). I hope this helps, P.
  5. It is clear what you want, and the code is correct... You COULD try and specify table also: SELECT a.id, a.user, a.title, a.body, u.name FROM article a LEFT JOIN user u ON article.user = user.user; ... since you have two coloumns called user... But basically you\'re selecting ALL rows from article, then JOINing rows from user to this table, where the coloumn \"user\" is identical, if NO row exists in the user table with the current article.user value, NULL is returned.... P.
  6. It means that in one table is says \'Kim\' another place it says \'Kim \' or something similar... (note the space character in the last instance)... You should simply use an integer for users (i.e. an USERID instead of the name) since integer values are better for joining... The code is correct, and it does what it should.... But for some reason, the article.user <> user.user when it comes to \"kim\".... How is the article.user value generated ? Is it selected from the user table and then directly copied and INSERTed into the article table ? So... add an auto_increment field to the users table and then use that id value in your articles table instead of the user column.... You may still check for unique usernames etc. when creating new users... P.
  7. Hi, This can NOT be done in sql, since you want a variable number of rows returned and printed on one line.... It\'s a LOT easier to parse your output in php, and return what you want. (Or any other language, perl, basic, fortran whatever... ) On each new line> while grab line { if UID = UID above, nothing ELSE print UID if SID = SID above, nothing ELSE print SID print field3; } will do it, format to any language... P.
  8. Hi, I just took the top lines from your posted code... So what I wrote was an extract of the page (mdbedit.php ?) with a few lines added.... Anyway, if your phpserver is having the global variables option turned OFF, which is most likely )you may check it with a page, haing content <?php phpinfo();?> It will be under register_globals in the section \'php core\'... Anyway: you should always code like they are turned off (safer code!) That means that ANY variable you are going to pass from one page to another must be FETCHED on the resultpage (page2) where the submitting page is normally page 1.... (or index.php refers to edit_record.php or something similar).... That means you may pass variables in three ways: POST (using a form) GET (using a form or putting it in the URL, like www.palle.dk/test.php?ID=10, will pass the variable ID with the value of 10 to the page called test.php) session variables (plenty of tutorials). The IMPORTANT THING IS TO FETCH THE VARIABLES AGAIN!!! They are passed to the page, but the page still have to read them! This is a truth with some modifications, but they are passed as special variables like this: $_POST[\'ID\'] $_GET[\'ID\'] $_SESSION[\"ID\'] This was the variable ID being passed, so normally I would put a line in the top like this: $ID = $_SESSION[\'ID\']; otherwise I would have to use $_SESSION.... in all the rest of the code, now I just use $ID... Anyway you missing variables are being passed to the function (a function I don\'t know what does), so they should probably not be empty! I\'m leaving for a conference later today and I\'m quite busy finishing presentations etc. so I hope some other people have some time to check this and help oavs. ? Have fun, P.
  9. Edited mdbedit.php <?php // at the top of mdbedit.php session_start(); // restore session $username = $_SESSION[\'username\']; ?> # THE ABOVE WILL RESTORE THE SESSION, AND PUT THE CONTENT OF THE SESSION VARIABLE USERNAME into the variable $username. <?php require_once(\'../Connections/connMDB.php\'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": P.
  10. You\'re not restoring the session in the mdbedit.php page... But I don\'t get it, if you\'re using sessions, why not just keep the username from the session, and forget about GETting it or POSTing the username... Otherwise you should get the cd owners username back from sql as well, do the check in php (against $_SESSION[\'username\']) and output an errormessage like \"Not your cd!\"... My 5 cents. (And I would recommend using POST all places anyway, just for making the URLs nicer... if your system have a login anyway, it won\'t be usable to have GET variables (they won\'t be bookmarkable, unless you\'re in a session). P.
  11. Ok, try an 1. echo $query BEFORE your mysql_query($query); 2. AND then try and run this query directly through shell or phpmyadmin or whatever... It will tell you the error.... (maybe you should have contacts.id = \'$id\' ) Anyway, you should always have some kind of errorhandling in your script, so you would get an error code back from the script in case of errors.... In this case it LOOKs like your query result is empty. Otherwise you would get an error from the mysql_query() statement.... But follow the 2 suggestions above... we\'ll probably get this done today... (if you\'re online). P.
  12. Ah... so your code on page IS working.... Then it\'s pretty simple... Post your code of the referring page, and we\'ll get it fixed.... P.
  13. Well... it\'s because your code assign the value 3 to $id, no matter what you *think* your code does.... So.. post the code on the referring page (i.e. on the allready posted code, try a $id = 4; on the line above the $result = SELECT.....; Just to check that it does work, and the error is in the referring page. And... you\'re not the first with this kind of problem... P.
  14. concat ? P. concat(year,\'-\',month,\'-\',dayofmonth); You can rewrite the long format to numeric format using the case: (CASE month WHEN \'January\' THEN 1 WHEN \'February\' THEN 2 .... THEN 12 END) as month_numeric; So you\'ll end up with: concat(year,\'-\', (CASE month WHEN \'January\' THEN 1 WHEN \'February\' THEN 2 .... THEN 12 END),\'-\', dayofmonth); P.
  15. Try and echo your $query to the output, so you can see if the sql statement sent to the mysql server is correct. 99% of the times, the variable ($id) is not defined or passed correctly to the variable and subsequently to the server... Also, if the statement looks allright, check that it is runnable on the mysqlserver (through mysqlshell or phpmyadmin - if you have such an access). Let us know what the problem was (or is, if it persists). P.
×
×
  • 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.