Immortal55
-
Posts
59 -
Joined
-
Last visited
Never
Posts posted by Immortal55
-
-
Ah, thank you for that.
That got me over one hurdle, but now I am getting an SQL error:
[b]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(event_date) AS day, COUNT(event_id) FROM calender_events WHERE[/b]
What in the world should I change there, as far as I know that should be perfect... -
This is the error that I keep getting....
[b]Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/theblizz/public_html/whitedevil/calendertest.php on line 13[/b]
I do not understand, I even copied the code from the page and pasted it and it still is giving me this error!
Here is the code (I know I spelled calendar wrong, but that is how it is.):
PHP code:
[code=php:0]
function getEventDays($month, $year) {
$days = array();
$sql = mysql_query("SELECT DAY(event_date) AS day, COUNT(event_id) FROM calender_events WHERE MONTH(event_date) = " . $month . " AND YEAR(event_date) = " . $year . " GROUP BY day");
if (mysql_num_rows($sql) > 0) {
while ($row = mysql_fetch_array($sql)) $days[] = $row['day'];
}
return $days;
}
[/code]
One last thing the $_GET where exactly is it getting the year and month from???
Thank you in advance.
Also, this is all pertaining to the ([url=http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php]http://www.phpfreaks.com/tutorial_cat/29/Calendars--Date-&-Time.php[/url]) calendar tutorial here on the PHP freaks website. -
What I want this script to do is take values from my database and assign them to the numerous variables that the array creates, so if the script worked it would output this:
&Name0=[b]NAME[/b]&TextData0=[b]TEXT[/b]&Author0=[b]AUTHOR[/b]&TheDate0=[b]DATE[/b]&Name1=[b]NAME[/b]&TextData1=[b]TEXT[/b]&Author1=[b]AUTHOR[/b]&TheDate1=[b]DATE[/b]&Name2=[b]NAME[/b]&TextData2=[b]TEXT[/b]&Author2=[b]AUTHOR[/b]&TheDate2=[b]DATE[/b]&NumItems=3&Go=Yes&
I just bolded the values to show you that I want them to say something. All I am getting as output right now is this:
&Name0=&TextData0=&Author0=&TheDate0=&Name1=&TextData1=&Author1=&TheDate1=&Name2=&TextData2=&Author2=&TheDate2=&NumItems=3&Go=Yes&
See, no values.
My DB has 3 records in it, so the final NumItems is correct, but why is nothing else getting any values? -
I do not get exactly what you are trying to say, but when I put $i in the while loop it messes everything up. With the $i before the first while loop, I get the correct increments and everything, something is just wrong with my array, that is all.
-
I am sorry, but I believe doing that would just reset $i to 0, which is not what I want at all.... I have a new problem though...
It is with my array, the array is not getting my results. Here is the script:
[code]
$i=0;
while ($tablefield = mysql_fetch_assoc($result) && $numm = mysql_num_rows($result)) {
$id[$i] = $row['id'];
$title[$i] = $row['title'];
$author[$i] = $row['author'];
$thedate[$i] = $row['date'];
$text[$i] = $row['story'];
$numReturn = $numm;
while ($i < $numReturn) {
$Name = $title[$i];
$TextData = $text[$i];
$Author = $author[$i];
$TheDate = $thedate[$i];
print "&";
print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=$TheDate";
$i++;
}}
[/code]
everything is working fine, except nothing has any values from the database, which makes me think that the array is not working for some reason....Thanks for the help... -
I have this script here, and it is grabbing the information from my database table, and assigning them to values. The problem is my value is set to 3 for every value....
Here is the script:
[code]
if ($result) {
$i = 0;
while ($tablefield = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $tablefield['id'];
$Name = $tablefield['title'];
$Author = $tablefield['author'];
$TheDate = $tablefield['date'];
$TextData = $tablefield['story'];
$numReturn = count($tablefield);
while ($i < $numReturn) {
$Name = $Name;
$TextData = $TextData;
$Author = $Author;
$TheDate = $TheDate;
print "&";
print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=$TheDate";
$i++;
}
}
$numItems = mysql_num_rows($result);
print "&NumItems=$numReturn&Go=Yes&";
}
[/code]
this exports this:
[b]&Name3=Test1&TextData3=Hello, this is a story that hopefully will be called into flash!&Author3=Mitch&TheDate3=today&Name3=Test2&TextData3=Well, this is coming from the future......Yeah.&Author3=John&TheDate3=tomorrow&Name3=Test8000&TextData3=ZUBBLE CUBBLE MUBBLE SHUBBLE&Author3=Toby&TheDate3=June 5th, 3030&NumItems=3[/b]
Notice how all the actual number values are set to 3, which I have 3 inputs in the database, so it is counting right, but it's assigning it to every one.... I want the variables going up incrementally (i.e. Name1=Test1 .... Name2=Test2...)
What is the problem. Thank you in Advance. -
According to the last post (which is still the current state of my script) It shows only one set of information from the table, the most recently added one to say. What could the problem be? This is really tough!
Thanks in advance again. -
I altered the code a little bit.....but now it only shows the most recently added entry in the database, but only once.
here it is:
[code]
if ($result) {
while ($tablefield = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $tablefield['id'];
$title = $tablefield['title'];
$author = $tablefield['author'];
$thedate = $tablefield['date'];
$text = $tablefield['story'];
}
$numReturn = count($tablefield);
$i = 0;
while ($i < $numReturn) {
$Name = $title;
$TextData = $text;
$Author = $author;
$TheDate = $thedate;
print "&";
print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=$TheDate";
$i++;
}print "&NumItems=$numReturn&Go=Yes&";
}
[/code]
Help appreciated! Thank you! -
Alright, I am doing a little dynamic loading in flash, and I am trying to load the variables from a PHP script. I make an array based on the entries in the table, and then they are passed on to flash....The only thing is is that my script grabs the same story multiple times.....and sometimes in a nonsense order....
Here is the script:
[code]
mysql_connect('localhost','admin','iffy')
or die ('Could not connect to database');
mysql_select_db('whitedevil')
or die ('Yeah, your database was found, but not the tables!');
$result = mysql_query('SELECT * FROM news') or die ('no query');
if ($result) {
while ($tablefield = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $tablefield['id'];
$title = $tablefield['title'];
$author = $tablefield['author'];
$date = $tablefield['date'];
$text = $tablefield['story'];
$numReturn = count($tablefield);
$i = 0;
print "&";
while ($i < $numReturn) {
$Name = $title;
$TextData = $text;
$Author = $author;
$TheDate = $date;
print "Name$i=$Name&TextData$i=$TextData&Author$i=$Author&TheDate$i=TheDate&";
$i++;
}
print "&NumItems=$numReturn&Go=Yes&";
}}
else {
print('Sorry, no work.');
}
[/code]
now what would be doing that?? Thank you in advance! -
Ah, awesome thanks a lot guys.
-
Alright, lets say I have a LONGTEXT field in my DB, and something long is entered in there.
And on a page i only want to show......lets say 25 characters, how would I limit it to only showing 25 characters? -
Well, thank you, you cleared up a lot of questions I had even thought I did'nt ask. The explanation of the while loop helped a lot too, thank you.
-
Alright, well what i am trying to do is, I have a database and in the database it stores some info on an image, blah blah. and What I am trying to do is be able to call the images from the database. but when i do it, the same image comes up for all the images that are called from a catagory...
here is the script:
[code=php:0]
<?
require_once('dbconnect.php');
$conn = db_connect();
$db = @mysql_select_db ("theblizz_mitchanderson", $conn)
or die ("Registration failure, try again.");
$sql = mysql_query("SELECT * FROM photos WHERE catagory = '{$_REQUEST['catagory']}' ORDER BY id DESC") or die(mysql_error());
while($row = mysql_fetch_array($sql))
{
stripslashes($row);
$path = $row['path'];
$id = $row['id'];
$image = $path;
if(!$max_width)
$max_width = 150;
if(!$max_height)
$max_height = 150;
$size = GetImageSize($image);
$width = $size[0];
$height = $size[1];
$x_ratio = $max_width / $width;
$y_ratio = $max_height / $height;
if( ($width <= $max_width) && ($height <= $max_height) ) {
$tn_width = $width;
$tn_height = $height;
}
else
if (($x_ratio * $height) < $max_height) {
$tn_height = ceil($x_ratio * $height);
$tn_width = $max_width;
}
else {
$tn_width = ceil($y_ratio * $width);
$tn_height = $max_height;
}}
$sql = mysql_query("SELECT * FROM photos WHERE catagory = '{$_REQUEST['catagory']}' ORDER BY id DESC") or die(mysql_error());
while($row = mysql_fetch_array($sql))
{
stripslashes($row);
echo '<a href="deletepic.php?id=' . $id . '">';
echo '<img src="' . $path . '" width="' . $tn_width . '" height="' . $tn_height . '" border="1">';
echo '</a><br>';
}
?>
[/code]
So pretty much, its just calling the same image x amount of times, i know its the same image because its the same id number, and the actual same image...
Thanks in advance. -
anyone?
-
Alright actually I figured it out, I realized you cannot have any spaces at the start of the script.
Thanks a lot.
but new question
here is the script
[code=php:0]
<?
session_start();
include ('dbconnect.php');
$conn = db_connect();
$db = @mysql_select_db ("theblizz_mitchanderson", $conn)
or die ("Registration failure, try again.");
$sql = mysql_query("SELECT * FROM news ORDER BY id DESC") or die(mysql_error());
while($row = mysql_fetch_assoc($sql)){
//this next line will make all the array variables into normal variables -
//if you had a "last_name" field in the database you could now call it simply by using $last_name
stripslashes(extract($row));
echo "" . $title . "</h3> - [<a href='deletenews.php?id='$id' target='main'>delete</a>] [<a href='updatenews.php?id='$id' target='main'>edit</a>]";
echo '<br><br>';
}
?>
[/code]
but the links do not register the id number (ex: deletenews.php?id= ) thats what the link is it has no number after id....How do I fix that? -
The only thing before that was basic HTML but that was before the <?php, and I took that out and still I am getting the same error....Any other ideas?
-
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/theblizz/public_html/mitch/admin/editnews.php:10) in /home/theblizz/public_html/mitch/admin/editnews.php on line 11
I keep getting that? What does that mean, if you need the script let me know. -
Wow, thanks a lot!
Although when I copy the code and paste it into DW its like triple spaced? :D -
haha, well thank you!
-
Ah, thank you for the hint.
But im still getting the email error. -
hmmm, no im still getting the same thing.
here is the link so you can see:
http://theblizz.org/studiocommunity/registration.php -
Thank you, that worked! But now I cannot figure out why the email check is not working, im not getting an error anymore, but it is saying that my email is not valid right off the bat, and its showing 2 forms.
-
I keep getting this error for my script that I just finished making:
Parse error: parse error, unexpected $ in /home/theblizz/public_html/studiocommunity/registration.php on line 81
here is my script:
[code=php:0]
<?
include('header.php');
function checkEmail($email)
{
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) #checking to see if valid characters
{
return FALSE;
}
if( (!$name) or (!$uname) or (!$pass) or (!$pass_two) or (!$email) )
{
echo('<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>
'); }
if( (checkEmail($email) == TRUE) && ($pass == $passTwo) )
{
require_once('db_connect.php');
$conn = db_connect();
$db = mysql_select_db('theblizz_studio', $conn)
or die ('Registration failure, try again.');
$sql = 'SELECT * FROM users';
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$usertaken = $row['uname'];
if( $uname == $usertaken )
{
echo('Username is already in use, please choose another<br>
<a href="registration.php">Go Back</a>'); }
else {
$sql = 'INSERT INTO users
(name, email, uname, pass) VALUES
("$name", "$email", "$uname", "$pass")';
$result = mysql_query($sql, $conn)
or die ('Registration failure, try again.');
if ( $result )
{
echo('Thanks, $name, you are now a member of the Studio Community!');
}}}
else {
if( $pass != $passTwo )
{
echo('<font color="red">*Your passwords did not match.</font>
<br><br>
<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>');
}
else {
echo('<font color="red">*Your E-mail address was not valid.</font>
<br><br>
<center><h2>New User Registration</h2>
<br>
<form actoin="$php_self" method="post">
<table border="0">
<tr><td>Name:</td><td><input type="text" name="name" value="$name"></td></tr>
<tr><td>Email:</td><td><input type="text" name="email" value="$email"></td></tr>
<tr><td>Username:</td><td><input type="text" name="uname" value="$uname"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" value="$pass"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass_two" value="$passTwo"></td></tr>');
}}
?>
[/code] -
anybody?
num_rows argument not valid? HELP!
in PHP Coding Help
Posted
[b]
Warning: Wrong parameter count for mysql_query() in /home/theblizz/public_html/whitedevil/calendertest.php on line 14
SELECT DAY(event_date) AS day, COUNT(event_id) FROM calender_events WHERE MONTH(event_date) = 01 AND YEAR(event_date) = 2007 GROUP BY day
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/theblizz/public_html/whitedevil/calendertest.php on line 16[/b]