Jump to content

Muddy_Funster

Members
  • Posts

    3,372
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Muddy_Funster

  1. You should never depend on javascript to do anything. javascript is an optional enhancement, not a core component.
  2. you will need to connect to the server, select your database and then select your information from your table that you want to use. once you have done that you will be able to manipulate it in PHP. You will need to read through the tutorial.
  3. you're welcome
  4. I don't know that it will make any difference, but you could try a cut down test page: $user= "root"; $pass= "OtlPHP07"; $host= "localhost"; $db= "widget_corp"; $con = mysql_connect($host, $user, $pass) or die ("Can't Connect : ".mysql_error()); $cur_db = mysql_select_db($db, $con) or die ("Unable to open Database '$db' : ".mysql_error()); $qry = "SELECT menu_name, content FROM pages ORDER BY id DESC"; $return = mysql_query($qry) or die (Data retetreval failed running : $qry <br><br> with the following error :<br>".mysql_error()); WHILE ($row = mysql_fetch_assoc($return)){ echo "<p>{$row['menu_name']} ---- {$row['content']} </p>" } Cutting it down to the bare minimum might help find the problem - or not
  5. neither of those are queries It would depend on how you are quering the data, I would expect that you would actualy want to index the last name field, and of cource set ID to a primary key. but as I said, as no two preasidents are going to have the same inauguration date, you would use a unique index for that field if any at all. And to be honest, for all the preasidents there have been, you would only be talking a difference of milliseconds between each option.
  6. You have a header (probably redirect) that you are trying to call after there has been information returned to the browser (characters sent back to the screen).
  7. I would worry less about non-unique indexes and more about Primary Key indexes. Indexes in databases do what they do everywhere else - make the process of finding things much quicker and easier IF they are used properly. A non-unique index allows for multiple entries of the same value to be included within the indexed field (not something I think you would need in the given scenrio unless multiple preasidents were inaugurated on the same date...)
  8. You can't POST a variable - only a form element. if you want to POST $answer add it to the form as a hidden field <input type="hidden" name="answer" value="<?php echo $answer ?>" /> This will POST the value of $answer into the array variable $_POST['answer'] and is the easiest solution to your question.
  9. Ooops, I crumpled the php tags at the top when I coppied it over, change the top two lines to this and you'll be back to where it was when it was working: <?php require_once('Connections/pwnedbook.php'); ?> <?php if (!function_exists("GetSQLValueString")) {
  10. Your third option isn't a commercialy viable solution. No company is going to accept that their information is held in the same table as several other companies all with the same access level. I am not sure how many users you can acctualy assign to a database (I think it's noth of 320,000 - but I just pulled that from thin air) but you can still use database authentication to dictate which table prefix they can and can't access. I think Fenway's first post was in refference to If you ever need to cross refference the information between multiple companies over multiple databases it's a pain in the ass (such as generating reports on time allocation for a support service).
  11. <?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } if (isset($_SESSION['name'])){ $name = $_SESSION['name']; echo "Hello $name"; ?> using the isset() function to check that the session variable of ['name'] exists (which it only will while someone has logged in) lets you display the name on condition that it is a logged in member that is viewing the page.
  12. there isn't 13 lines there, and nonothing called Campaign either. the problem is either in the code you didn't post up, or in the include file.
  13. Looks good: well commented, nice tabulation (no select * either ). There is, however, no admin alert attached to the error capture - you may want to look into that. Other than that, it may be slight overkill with the functions but that's nothing to worry about here. When you get round to ordering posts by date, I would personaly do it in the SQL, rather than the PHP - as I would have used SQL COUNT(*) to get the post count aswell, but that's neither here nor there as it's a matter of personal prefference. All in all
  14. you can set user permissions per table, you can prefix each table for each client, no need for a new databases. The issue comes when you want to administer the databases, if you have 100 clients with 55 tables each all in the same database, that's 5500 tables you need to sift through to get the ones you want. Having a master table that can pull the client tables by prefix makes this nice and easy, as does segregating the tables over multiple databases ( normaly by region - such as europe, america, asia all get a database each) that way you can filter down where you look by the information you have on your client.
  15. ok, here's what I got for you. These should replace your existing pages, but I havn't tested any of this, so you will NEED to make backups of the ones you have. It's the best I could think of just now to make it work the way I think you want it to. Let me know how it goes. login: <?php require_once('Connections/pwnedbook.php'); if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['Username'])) { $loginUsername=$_POST['Username']; $password=$_POST['Password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "index.php"; $MM_redirectLoginFailed = "Register.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_pwnedbook, $pwnedbook); $LoginRS__query=sprintf("SELECT username, password, id FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $pwnedbook) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; $pullID = mysql_fetch_assoc($LoginRS); $usrID = $pullID['id']; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; $_SESSION['MM_userid'] = $usrID if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Log In</title> <style type="text/css"> body,td,th { color: #FFF; font-family: "Comic Sans MS", cursive; } body { background-color: #000; } </style> <link href="Css/estilo.css" rel="stylesheet" type="text/css" /> </head> <body> <div align="center"><a href="index.php"><img src="Images/logon_logo.gif" width="300" height="150" /></a> </div> <p align="center">Welcome to Pwnedbook.co.uk - the unsocial network for gamers! </p> <p align="center">You need to log in to see this site. </p> <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>"> <p align="center"> <label for="Username">Username</label> <input type="text" name="Username" id="Username" /> </p> <p align="center"> <label for="Password">Password</label> <input type="password" name="Password" id="Password" /> </p> <p align="center"> <input type="submit" name="Submit" id="Submit" value="Go" /> </p> </form> </body> </html> message submit: !-- Post a message <?php //initialize the session if (!isset($_SESSION)) { session_start(); } //define database include("db.php"); // if content has been sent if(isset($_POST["textarea_noticia"])){ $msg = $_POST["textarea_noticia"]; $userid = $_SESSION['MM_userid']; // Insert information $sql = mysql_query("INSERT INTO messages(message, id_fk)values('$msg', $userid)") or die (mysql_error()); $qry_retrn = "SELECT mesg_id, message, user_name, prof_pic FROM messages LEFT JOIN users ON (messages.id_fk = users.id) order by msg_id desc"; $result = mysql_query($qry_retrn) or die (mysql_error()); $row = mysql_fetch_assoc($result); $id = $row["msg_id"]; $msg = $row["message"]; $usr = $row['username']; //will need to be added to display $pic = $row['prof_pic']; //will need to be added to display } ?> <div class="bar<?php echo $id;?>"> <div class="post_box"> <?php //to display image from source $dir = "profpics/"; //opening directory if ($opendir = opendir($dir)) { //reading directory while (($file = readdir($opendir)) !== FALSE) { if ($file!="."&&$file!="..") echo "<img src = '$dir/$file' img width='38' img height='38'><br>"; } } ?> <div class="noticia"><?php echo $msg; ?></div> <div class="eliminar_noticia"><a href="javaScript:void(0)" id="<?php echo $id;?>" class="eliminar_noticia_actualizado">Del</a></div> <div class="enlace_comentar"><a href="javaScript:void(0)" id="<?php echo $id;?>" class="comentar">Comment</a></div> <div id="contenedor_textarea_comentario" class="contenedor_textarea_comentario<?php echo $id;?>"> <div class="comentario_caja" id="comentario_caja<?php echo $id;?>"> <form name="<?php echo $id;?>" method="post"> <textarea class="text_area" name="comentario_valor" id="textarea<?php echo $id;?>"></textarea> <br /> <input type="submit" value="Enter" class="enviar_comentario" id="<?php echo $id;?>" /> </form> </div> <!-- Div donde se aƱadiran los comentarios --> <div id="comentario_cargado<?php echo $id;?>"></div> </div> </div> </div> comment submit: <?php include("db.php"); if(isSet($_POST['comentario_valor'])){ $id=time();// Demo Use $comment=$_POST['comentario_valor']; $id=$_POST['id']; $user = $_SESSION['MM_userid']; $sql=mysql_query("insert into comments(comment, msg_id_fk, id_fk)values('$comment',$id, $user)") or die (mysql_error()); $qry_back = "SELECT com_id, comment, ". "CASE WHEN comments.id_fk IS NULL THEN 'Annon' ELSE (SELECT user_name FROM users WHERE users.user_id = comments.id_fk) END AS postedBy, ". "CASE WHEN comments.id_fk IS NULL THEN 'http://domain/folder/guest.img' ELSE (SELECT prof_pic FROM users WHERE users.user_id = comments.id_fk) END AS com_image ". "FROM comments ORDER BY com_id desc"; //you will need to change the 'http://domain/folder/guest.img' to what you will use as a default image for non members. $result=mysql_query($qry_back) or die (mysql_error()); $row=mysql_fetch_array($result); $com_id=$row['com_id']; $comment=$row['comment']; $poster = $row['postedBy']; //will need to be added to display $img = $row['com_image']; //will need to be added to display } ?> <div class="conetenedor_comentarios" id="conetenedor_comentarios<?php echo $com_id;?>"> <img src="Img/comment.png" width="38" height="38" class="imagen" /> <div class="mostrar_comentario" id="mostrar_comentario<?php echo $com_id;?>"><?php echo $comment;?></div> <div class="comentario_borrar"><a href="#" id="<?php echo $com_id; ?>" class="comentario_borrar_actualizar">X</a></div> <div class="enlace_comentar"></div> </div>
  16. You do know that you can probably do what you want from within excel it's self, with filtering, some basic formulas and copy/paste special.
  17. Depends. A single database will be fine, as long as you properly define your tables and set appropriate security. However, if there are going to be a lot of tables for a lot of clients then regonalising the content into multiple database would make life easier all round.
  18. I'll go for that.
  19. You would need something more like: while ($row = mysql_fetch_assoc($result){ echo'<a href="/petonline.co.za/data/imagedisplay.php?id='.$user_uid.'&add='.$uidadd.'" target="_blank">More Info</a>'; } then on imagedisplay.php <php $user_id = $_GET['id']; $uidadd = $_GET['add']; //rest of page code
  20. also, $tbl_name isn't defined
  21. You can use the loop, you just need to put it in the right place - have the html content generated through the loop before the mail is sent, that way you won't mail for every result - or look at using vardump() or print_r() instead of echo
  22. What part of that is causing the problem?
  23. Your table structure is all wrong. each table should have it's own unique key field with another field used for linking accross the tables. set your tables up like this: users - can stay the same, as it will be your core refference ( although make sure that the user_id filed is an auto_inc Primary Key). in each of the other two tables change the image_id and other_id to also be auto_inc Primary Keys and add to each of these tables a user_id column that will contain the user_id that the image and other tables will refference. Once you have done this you should be able to pull the information out properly using a JOIN: SELECT user_name, user_surname, image_thumb, image_url, image_date, other_note FROM users RIGHT JOIN images ON (users.user_id = images.user_id) RIGHT JOIN other ON (users.user_id = images.user_id) WHERE users.user_id = <xxx> where <xxx> the user id of the account that you want to look up.
  24. Right, I can see where the problem using the user ID was coming from, and should have that fixed. Can you post up the forms you are using for your post message and post comment pages - I need to make sure I keep the right variable names.
×
×
  • 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.