phingoc
-
Posts
15 -
Joined
-
Last visited
Posts posted by phingoc
-
-
Warning: mysql_num_rows() expects parameter 1 to be resource
what am i doing wrong?
i have checked, double checked and tripple checked everything.
include("mysql_connect.php"); $query = "SELECT * FROM prod2011 WHERE dato BETWEEN '$nyfra' AND '$nytil'"; $antall = mysql_num_rows($query); // I get error on this line. echo "Antall linjer i listen: " . $antall;
-
found out a way to sort it out.
$endredato = strtotime($dato); $nydato = date('d-m-Y', $endredato);
easy, but had to change about 15 php files.
Thank you guys for answers.
-
<input type="text" size="12" maxlength="10" name="dato" value="<?php echo date('d.m.Y'); ?>">
user has the ability to remove the php generated date, and input his own date.
-
yeah...
in norway, we use dd.mm.yyyy, but mysql date uses yyyy.mm.dd..
Is there any php lines i can use to rearrange the input dates?
And also, rearrange the date when i query the mysql for the dates?
-
thank you. that sorted it out, but that brings a new problem that i will make a new tread for under php help..
becouse in norway, we use dd.mm.yyyy, so all my inputs will be in that format, and then the dates dont get stored right in the db.
-
if i change it to date, mysql will automaticly sett the current server date when the row is created?
since in the add form, i need to add another date, than the current server date..
-
Hi.
i want to sort out mysql rows and display them only between dates. The date is stored inn dd.mm.yyyy... i have now 3 entries in the DB (just for testing);
04.12.2011
02.12.2011
04.12.2011
when i try to fetch rows between dates:
01.12.2011 and 03.12.2011, i get 1 return witch is correct..
01.12.2011 and 05.12.2011, i get 3 returns witch is correct..
03.12.2011 and 05.12.2011, i get 2 returns witch is correct..
But.... when i try between 01.01.2000 and 01.01.2020, i get 0 returns..
why?
I works when between 01.01.2000 and 31.12.2020...
form
<form method="POST" action="listebetween.php" target="_BLANK"> <table width="600" border="0"> <tr> <td width="50%" align="center">Fra dato:<input type="text" name="fra" maxlength="10" size="12"></td> <td width="50%" align="center" rowspan="2"><INPUT TYPE="submit" VALUE="Utfør"></td> </tr> <tr> <td width="50%" align="center">Til dato:<input type="text" name="til" maxlength="10" size="12"></td> </tr> </table></form>
script
<?php include("mysqlconnect.php"); $fra = $_POST['fra']; $til = $_POST['til']; $query = "SELECT * FROM prod2011 WHERE dato BETWEEN '$fra' AND '$til'"; $result = mysql_query($query) or die(mysql_error()); echo "<center><table border='1'>"; echo "<tr> <th width='90'>Dato</th> <th width='90'>Ordre</th> <th width='50'>Solgt</th> <th width='50'>Brukt</th> <th width='100'>Kommentar</th> </tr>"; while($row = mysql_fetch_array( $result )) { echo "<tr><td>"; echo $row['dato']; echo "</td><td>"; echo $row['ordre']; echo "</td><td>"; echo $row['solgt']; echo "</td><td>"; echo $row['brukt']; echo "</td><td>"; echo $row['kommentar']; echo "</td></tr>"; } echo "</table>"; ?>
-
thanks.. changed this line
"SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts ORDER BY DATE DESC";
-
Hi.
How can i order the news that gets viewed by date? newest first.
<?php include ('mysql_connect.php'); $query = "SELECT id, title, author, post, DATE_FORMAT(date, '%M %d, %Y') as sd FROM news_posts"; $result = @mysql_query($query); if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $url = 'comments.php?id='.$row['id']; echo '<p><b>'.$row['title'].'</b><br /> '.$row['sd'].'<br /> Skrevet av : <b>'.$row['author'].'</b><br /><br /> '.$row['post'].'<br /><br /> <a href="javascript:openComments(\''.$url.'\')">Legg til eller les komentarer.</a></p><br /><hr>'; } } else { echo 'Det er for tiden ingen nyheter'; } ?>
-
Hi. i get this error msg when trying to run this script:
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\reg.php on line 14
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\reg.php on line 20
reg.php
<?php $connect = mysql_connect("localhost","xx","xx") or die("Kunne ikke koble til database."); mysql_select_db("xxx") or die("Kunne ikke finne database"); $username = $_POST['brukernavn']; $password = $_POST['passord']; $confirm_password = $_POST['confirm_password']; $email = $_POST['epost']; $name = $_POST['navn']; $place = $_POST['bosted']; $queryuser=mysql_query("SELECT * FROM brukere WHERE brukernavn='$username' "); $checkuser=mysql_num_rows($queryuser); if($checkuser != 0) { echo "Beklager, ".$username." er allerede i bruk. Venligst velg ett annet brukernavn."; } else { $querymail=mysql_query("SELECT * FROM brukere WHERE epost='$email' "); $checkmail=mysql_num_rows($querymail); if($checkmail != 0) { echo "Beklager, ".$email." er allerede i bruk."; } else { if($password != $confirm_password) { echo "Passordene du tastet matcher ikke."; } else { $insert_user=mysql_query("INSERT INTO brukere (brukernavn, passord, epost, navn, bosted) VALUES ('$username', '$password', '$email', '$name', '$place')"); if($insert_user) { echo "Gratulerer, du er nå registrert. Du kan nå logge inn på venstre side."; } else { echo "Noe galt skjedde under registreringen, venligst gå tilbake og prøv på nytt."; } }}} ?>
Someone know why? i have check, double checkd and tripple checkd the variables in the script, form and database.
-
Thank you. Removed all empty lines before session_start(); and additional moved "session_start();" from the script to line 2.
Thank you so much!
-
loginform.php
<form method="POST" action="login.php">
<INPUT class="login" TYPE="TEXT" NAME="brukernavn" value="Brukernavn">
<INPUT class="login" TYPE="PASSWORD" NAME="passord" value="Passord">
<br><br>
<INPUT class="button" TYPE="submit" value="Logg inn"> <input value="Registrere" class="button" Type="button" onClick="parent.location='login/registrer.php'">
</form>
login.php (where session is created)
<?php
include("css.php");
include("header.php");
include("meny.php");
?>
<td width="596" valign="top"><table width="100%" border="0" cellpadding="15">
<tr>
<td class="tabell" valign="top" align="left">
<?php
session_start();
$username = $_POST['brukernavn'];
$password = $_POST['passord'];
IF ($username&&$password)
{
$connect = mysql_connect("localhost", "xxx", "xxx") or die("Kunne koble til database");
mysql_select_db("smarttreff") or die("Kunne ikke finne database");
$query = mysql_query("SELECT * FROM bruker WHERE brukernavn='$username'");
$numrows = mysql_num_rows($query);
if ($numrows!=0)
{
while ($row = mysql_fetch_assoc($query))
{
$dbusername = $row['brukernavn'];
$dbpassword = $row['passord'];
}
if ($username==$dbusername&&$password==$dbpassword)
{
echo "Du er nå logget inn. Vennligst klikk <a href='innlogget.php'>her</a> for å gå videre til brukersidene.";
$_SESSION['username'] = $dbusername;
}
else
echo "Feil passord";
}
else
echo "Kunne ikke finne brukernavn";
}
else
echo "Venligst tast inn ett brukernavn og passord";
?>
</td>
</tr>
</table></td>
</tr>
</table>
<?php
include("footer.php");
?>
-
<?php
All those leading spaces have to go. You can't have any output whatsoever, even spaces and blank lines, before calling session_start().
Removed the empty lines, but no luck.
-
Hi.
Link to project: www.smarttreff.moo.no
Login user: admin
login pw: 123
When i login the login form wont disapear. If i return to the index(Hjem) page without logging out, the loginform disapear. I am ussing session for the login
So the basicly, i want the loginform do disapear at once when the user has pushed login button(Logg in)
(dont laught at my "cut and past" for the include meny.. i just made the design and chopped it to bits and put it into includes)
Index.php
<?php session_start(); include("css.php"); include("header.php"); include("meny.php"); ?> <td width="596" valign="top"><table width="100%" border="0" cellpadding="15"> <tr> <td class="tabell" valign="top" align="left"> Main </td> </tr> </table></td> </tr> </table> <?php include("footer.php"); ?>
meny.php
<table width="800" border="0"> <tr> <td width="198" valign="top"><table width="100%" border="0" cellpadding="15"> <tr> <td align="left" valign="top" class="tabell"> <a href="index.php">Hjem</a> <br /> Når og hvor <br /> For hvem <br /> Spørsmål og svar<br /> Forum <br /> <br /> <br /> Samarbeidspartnere </td> </tr> </table> <br /> <table width="100%" border="0" cellpadding="15"> <tr> <td class="tabell" valign="top" align="left"> <?php if(isset($_SESSION['username'])) echo "Velkommen, " .$_SESSION['username']. "!<a href='innlogget.php'>Medlemsnyheter</a><br><a href='logout.php'>Log ut</a>"; else { include("loginform.php"); } ?> </td> </tr> </table></td> <td width="15"> </td>
Problems With Php Mail Function.
in PHP Coding Help
Posted · Edited by phingoc
Hi. When i fill out my form and press "send", i get a email, so that is working.. But the email only contains "name" and "subject".. The senders email adress and message is missing from the mail i reciev.
Form
And "send_contact.php"
What to do?