Jump to content

jhecht

Members
  • Posts

    608
  • Joined

  • Last visited

Posts posted by jhecht

  1. MySQL query returns a resource ID which you can pass into other mysql functions like mysql_num_rows and mysql_fetch_assoc. also, mysql_close is a function, and you need to specify a variable. kinda like what mihalism posted, its just a safety practice just in case your server and MySQL are weird like that.Other than that, good job.

  2. for the connection link, it has to be called var, otherwise it creates parser errors in PHP

    <?phpclass db{//Top level db connectionvar $db_name="db_name"; var $db_host="localhost";var $db_user="db_user";var $db_password="db_password";var $connection="";var $db;$this->connection=mysql_connect($this->db_host,$this->db_user,$this->db_password) or die("I Couldn't connect"); $this->db=mysql_select_db($this->db_name,$this->connection) or die("I Couldn't select your database");}?>

    If in a class you are refferring to the variables created in the function you need to put $this-> and then the variable name, otherwise it doesnt work.

  3. It doesnt need to have an ID, it just needs to be called something like this:

    var mapobj;var maplink;function ToggleMap(linkName){	if(!mapobj)	{		mapobj = document.getElementById("Map");	}	if(!maplink)	{		maplink = document.getElementById("ToggleMapLink");	}	if(mapobj.style.display == "block")	{		mapobj.style.display = "none";		linkName.value="Open";	  }	else	{		mapobj.style.display = "block";		linkName.value="Close";	  }}//call it like<a href="java script:toggle(this);">Open</a>

  4. Look at the post i put on here called basic AJAX coding... or something like that. responseText is used for anything, because even XML is text when you put it down to it.But yes, please let us see the code.

  5. new functions for functions you already have and can be called by alot faster, and easier, are in my book ultimately pointless. if you want, create a new CLASS that handles this, and then the first line on all of your other pages should be include("class_definition_file.php");kinda like

    class db{ var $msa;  function db($host,$user,$pass,$db){  $this->msa = mysql_connect($host,$user,$pass);  if(!($this->msa )){   die("could not connect!<br/>".mysql_error());  } @mysql_select_db($db) or die(mysql_error()); }}

    and then continue on with the other functions you need, this way you only need to do something like $varClass->query("select * FROM bob"); instead of the mysql_query("select * from bob",$mysql_link) etc etc;other than that, dont bother.

  6. Yeah im sorry i can't really help you, i can just offer a little bit of offhand insight on this now( i dont use PHP's image functions at all... never had to and probably never will need to).if im correct, imagepng displays the image, and imagedestroy does what its name says, maybe its possible the header for png's are different (i've heard many things about IE not liking PNG's at all, and their use and acceptance browser wide not being well), so if you could, change possibly to JPEG's. I have no idea what content-disposition does, but i thought the content type had to be capitolized (ie Content-Type), if im wrong then i done hit the shift key one too many times.Other than that, im sorry but i can't help you.

  7. the .htaccess file in my book is over kill.you already have the content-type set, that should already just display the file as an image in your browser. i think the fact that you ForceType is used is making your computer want to download it because the server is telling the browser to.My suggestion is just to get rid of the .htaccess file and see what happens.

  8. Good start, to answer your questions, yes the ?img=something can have underscores, but the entire point of the ?img=something is to have something equal to a number, so there wouldnt need to be any spaces.And yes there is a way to have it say "image not found";

    <?php$input = $_GET['img'];$con = mysql_connect('stuff','stuff','stuff') or die("connection error<br/>".mysql_error());@mysql_select_db('stuff', $con) or die("Could not select database".mysql_error());$result = mysql_query("SELECT img_name,width,height FROM images WHERE img_id='$input'");if(mysql_num_rows($result)>0){$output = mysql_fetch_array($result);echo '<img src="images/' . $output['img_name'] . '" width="' . $output['width'] . '" height="' . $output['height'] . '" alt="" />';}else{ echo "image not found, no record sets match input";}mysql_close($con);?>

    Also, you might want to do a quick check to see if $_GET['img'] is even set. something like if(isset($_GET['img']) && $_GET['img']!=null){//Your base texts here}Should do fine.

  9. I'm sorry man but what you are doing is just over complicating your script so much its killing me.ok so you have one table for users, right?lets say its a simple one with these fields:

    user_id (int unique not null auto_increment([saves you time later on]username(a varchar(255) column)password( varchar(32) because md5 is always 32 chars long)

    This is for users to log in, and whatever.Next is a table for the podcasts

    podcast_id( int unique not null auto_increment)podcast_name(varchar(255)podcast_poster(int not null)podcast_url(text)[text just in case some podcasts have incredibly large and complex url's]

    That is the podcast table, Next comes the votes

    vote_id (int unique not null auto_increment)vote_podcast_id(int, this is the id of the podcast from the podcast table)vote_from_user(int, this is from the USER table)vote_type(int, 0 for "not digged", 1 for "digged", or however you want to do it)vote_amount(int not null, for the +1-+ to -1 or -3 or whatever many numbers you want to be able to do it as.

    This would save you time, instead of everytime a user registers having to add a new column, you just insert a new row and its done. Same with the podcasts, you aren't creating a new column for every user, you just wait for the user to submit a podcast, which also goes dito for the voting. Instead of having to do it by the ID and then adding a column for the user who votes on it, you just add another row.Altering tables just takes too much time, its too ugly, and honestly its just something(no offense meant to you) a newbie would do. Im not saying you literally MERGE the tables, im saying when you select something from one table you can MERGE it(not literally) with values. Lets say im selecting 3 podcasts from my system, but i also want the user who posted it's name to be on there.

    SELECT p.*,u.username FROM `podcasts` p,`users` u WHERE u.user_id=p.podcast_poster ORDER BY p.podcast_id DESC LIMIT 3

    If you want me to show you what im talking about i could whip up a quick mock version of a podcast system to prove it is faster.

  10. ok well, all i can tell you is that this is going to cause you more pain then necessary. PHP... i dont know it might be able to handle it, but im not quite sure.And you would be dealing with DNS and so on, honetly if i were you, i wouldnt do this. honestly im not sure how you would go about doing this, i guess mod_rewrite on apache might be able to do something but.. hey i have no idea honestly, might want to look into that on APACHE, the mod_rewrite code styleother than that, can't help you.

  11. Heres a nice clean data fetching code try it
    <?php//connect$con = mysql_connect("localhost","usernmae","password");if(!$con){ echo mysql_error(); }//pick databasemysql_select_db("database_name", $con);//database query$result = mysql_query("SELECT `pdedecker` FROM `votes` WHERE `id` = '0'", $con) or die(mysql_error());//fetchwhile($getrating_listing = mysql_fetch_array($result)){$getrating_rating = $getrating_listing['pdecker'];}//close connectionmysql_close($con);?>

    Your code is the exact same thing as mine. Just different variables, and with DIE statements(he didnt put em, so neither did i)and pdecker, did you change the values for the mysql_connect and mysql_select_db()?And dude, how you are doing the plus or minus thing is going to cause you ###### later on.make one table for the podcasts, to keep them there and whatever, name etc etc, next create a seperate table with a few fields:ID(for each deletion purposes later on)author, the interger ID of the usertype, i would assume an int, 0 for subtract, 1 for addamount (int type)podcast_id (the ID from the podcasts table)how you are doing it is just going to murder on your server.
  12. very very close, but wrong;you might want to do it like this:

    <form action="otherPage.php" method="post"><textarea name="text"></textarea><br/><input type="submit" value="submit" name="submit"/></form>

    otherPage.php is as followed:

    <?phpif(isset($_POST['text'])){ $file = file_get_contents("edited.xml") or die("could not open edited.xml"); $file .= $_POST['text']; file_put_contents("edited.xml",$file) or die("Could not write to file");}else{ echo "you have come here not of how you are suppposed to... go the ###### away";]?>

  13. Yes, a database would work so much better, and you wouldnt have to add new lines of code everytime you added an image to the database.basically you would have to create a database with a few columns, one being an index(id), the other being the filename, and i dont know if your gallery is set so that every user can allow for uploads, but yes, a database would be easier.here is the basic SQL query you can use, add whatever you like and come back later for help:

    CREATE TABLE `images`(`img_id` int unique not null auto_increment,`img_name` varchar(255));

    Have fun lenny

  14. well i would presume since every page has a different file name, that it would be more than one page impression, but hey im not quite sure so..... i dont know does someone who uses Adsense more know about this?

  15. ok then this isnt as complex as i thought it would be, i thought you meant like any word they put in let them go to a different page.

    <script type="text/javascript"><!--function check(name){ switch(name){ case "up": window.location="pageforup.html"; break; case "left": window.location="pageforleft.html"; break;  case "right": window.location="pageforright.html"; break; default: return false; break; }}//--></script>

    now call it like this:<form name="jim" action="page.php" onsubmit="return false" method="post"><input type="text" name="page"/><input type="button" name="submit" onclick="check(this.parentNode.page.value)"/></form>if that doesnt work then just change this.parentNode.page.value to document.jim.page.value;

  16. You wouldnt need to create a seperate page. If you wanted to waste server space, then go for it. The easiest thing to do is just to create one page and pass a variable to it through the GET variable.Also, if you wanted such a username profile thing, then you could just use Mod_Rewrite if you were on Apache to forward anything put after the slash in your website to forward to a page.But if you really want to create a new page, just tell me and i will show you how.

  17. ok i dont know why you are getting a negative one, but ur code just kinda bugs me.

    $mysql = mysql_connect("localhost","usernmae","password") or die(mysql_error());@mysql_select_db("database");$getrating_result = mysql_query("SELECT pdedecker FROM votes WHERE id=0",$mysql);//You dont need quotes around numbers;$getrating_listing = mysql_fetch_array($getrating_result);$getrating_rating = $getrating_listing['pdecker'];//Mainly because i have no idea what the ###### mysql_fetch_object does, use fetch_array or fetch_assoc;

    What type of column is pdecker? that might be your problem. It should be either an integer, a float, or a double. if its an integer you dont need the + sign before it, its just assumed to be a +, unless you put a - sign infront, where it makes it negative.

  18. ok to Flic: onsubmit=" return check()" Would be how you do it, i already know that you figured it out but still, its kinda sad when you have to go through all of this and end up doing fixing the problem on your own because the people who were helping you decided to start arguing.To the people who were arguing: PM-ing is meant for that. So are AIM, YAHOO, and MSN along with Gtalk. this person came here looking for help, not a debate. To make HTML valid by any means, yes you do need the (/) in the input tags, its just bad practice to not do. Also, onsubmit works if say someone is in the textbox writting something, and accidentally hits enter. Onclick only works when someone hits the button, and i dont know about you but i VERY rarely actually use the mouse to hit the submit button.Sheesh.

×
×
  • Create New...