Closed Thread Icon

Topic awaiting preservation: phpMyAdmin questions Pages that link to <a href="https://ozoneasylum.com/backlink?for=27295" title="Pages that link to Topic awaiting preservation: phpMyAdmin questions" rel="nofollow" >Topic awaiting preservation: phpMyAdmin questions\

 
Author Thread
redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 01-10-2006 07:24

I've found more time to dabble with php/mysql so be patient with me

I'm working on a content updater for web (id, page, content) and I'm not sure what to set the "type" too in the database for content. Because this will be for some unkown amount of content I would like it to be capable of holding a very, very large amount of text and probably some html. On most beginner tutorials I'm reading the largest I see is varchar (100)... what's the best practices for my situation?

Also, in this code...

code:
<?php

	require("functions.php");
	$update = $_GET['update'];

	connectDB();

	$query = "SELECT * FROM contentTable WHERE page='$update'";
	$result = mysql_query($query);
	$num = mysql_numrows($result);
	
	if ($num == 0)
	{
		$query = "INSERT INTO contentTable VALUES ('', '$update', 'Add Page Content Here')"; 
		mysql_query($query);
	}

	mysql_close();
	
	for ($i = 0; $i < $num; $i++)
	{
		$id = mysql_result($result, $i, "id");
		$page = mysql_result($result, $i, "page");
		$content = mysql_result($result, $i, "content");
	}

	echo 'Update <b>' . $page . ' Page</b><br><br>';
	
?>



The first if statement... if "page" requested doesn't exist in the database I would like it to just add it with the "Add Page Content Here" for the content. It works great but it doesn't show until you click through the link twice...? Sort of like it stops right after the if statement and doesn't continue through the code; Any ideas why? Thanks for your time.

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-10-2006 09:55

ok... you need a mysql->text or mysql->largetext column to store text (use a blob though, if it's binary. text fields in mysql are stripped from trailing whitespace.)


As for your code... you have no error handling whatsoever.
Start by sticking
error_reporting ( E_ALL ); before the first require.
Then see all the pretty errors it might generate.

Then come back ;-)

redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 01-11-2006 05:48

k - updated my content type to longtext and added error_reporting ( E_ALL ); to the first of my script but no errors are generated. Also, reading here it talks about a text field being "indexed" (about the fourth <p> down)... what exactly does that mean? I know a can index columns with the phpMyAdmin actions... does this help speed things up?

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 01-11-2006 09:53

indexing can speed things up if you're using select where xyz = tyb (or > or < or => or <=) queries...
it's not necessary for your primary key - that's already indexed.

Textfield indexing comes in two flavors - the standard index supporting only comparison and like 'xyz%' (but not like '%kyz' or like '%aoeu%').
Or the fulltextindex which only searchs whole words (which need to be four letters or more), but in is very very fast at doing so.



Btw, I wouldn't expect to get any more data with php->mysql_result() after I had called php->mysql_close()
And of course you need to run the select query again *after* you have inserted your new data, for it to show up in the output.

redroy
Paranoid (IV) Inmate

From: 1393
Insane since: Dec 2003

posted posted 01-20-2006 02:56

Forgot to thank you... really helped me out a lot; thanks!

« BackwardsOnwards »

Show Forum Drop Down Menu