Re: what am i doing wrong..??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Echo out your queries!
$query = "insert into joke values('',".$_POST['joke_text'].",'date')";
---> echo $query;
$result= mysql_query($query);

This will tell you what is going on, perhaps some of the information is not set?  You can even copy and paste the output to run against your mysql backend on the command line to see if additional information/errors are present.

-B

----- Original Message -----
From: Aalee <ayyaali@xxxxxxxxxxx>
Date: Thursday, November 4, 2004 7:54 am
Subject:  what am i doing wrong..??

> Hi there please have a look the code below...I dont know wht am 
> doing wrong
> here...
> This code is suppose to show the number of jokes in a mysql 
> database and
> allows user to add a joke when the user clicks addjoke link. And 
> when the
> joke is added, it suppose to say that "Joke inserted, Thank you" 
> and list
> all the jokes below this line. So far am able to view all the 
> jokes and take
> the user to add joke page. But the problem is when the user clicks 
> insertjoke button, it does not display the message "Joke inserted, 
> Thank you" and
> the jokes are not listed. Infact it does not give any error 
> aswell, it just
> stays on the add joke form page. I checked the database and no 
> joke is
> added. Working on PHP ver 4.3.8 with register_globals turned OFF 
> and Apache
> 1.3.31. MySQL ver 4.0.20a on winXP pro SP1.
> Recently i started using registre_globals OFF and all these probs 
> strtedcoming up. This code was working fine with globals ON. But 
> my hosting has it
> off. So need to do so. I was able to fix all the other issues came 
> coz of
> this global thing in this code. But stuck on the issue i just 
> mentioned. Any
> help would be GREATLY appreciated.
> 
> <?php
> if (isset($_GET['addjoke'])){
> ?>
> <form name="form1" method="post" action="<?php 
> $_SERVER['PHP_SELF'] ?>">
>  Type your joke :<br>
>  <textarea name="jokeText" id="jokeText"></textarea>
>   <br>
>  <input name="insert" type="submit" id="submit" value="Insert Joke">
> </form>
> 
> 
> <?php
> }
> else { // start main else statement
> if(isset ($_POST['insert'])) {
> $db = mysql_connect("localhost","homesite","test") ;
> mysql_select_db("jokes",$db);
> $query = mysql_query("INSERT INTO jokes SET
> JokeText = '".$_POST['jokeText']."' ,
> JokeDate = CURDATE() ");
> echo " Joke inserted, Thank you <BR><BR>";
> echo mysql_error();
> }
> $color1 = "#66CCFF";
> $color2 = "#66CC99";
> $row_count = 1;
> 
> // ---------- Following lines list the jokes in the
> database ----------------
> echo "<b><H3> These are the jokes we have got so far</H3></B>";
> $db = mysql_connect("localhost","homesite","test")  or 
> die(mysql_error());mysql_select_db("jokes",$db);
> $sql = "SELECT id, JokeText, JokeDate from jokes";
> $query = mysql_query($sql);
> echo "<table border=1>
>   <tr>
>    <td><b>ID<b></td>
>  <td><b>Joke Text<b></td>
>  <td><b>Joke Date<b></td></tr>";
> while ($myrow = mysql_fetch_array($query))
> {
> $row_color = ($row_count % 2) ? $color1 : $color2;
>  echo"<tr bgcolor = $row_color>".
>  "<td>". $myrow["id"]."</td>".
>  "<td>". $myrow["JokeText"]. "</td>".
>  "<td>". $myrow["JokeDate"]."</td></tr>";
>  $row_count++;
> }
> echo "</table>";
> 
> $current_url = $_SERVER['PHP_SELF'];
> echo("<P>" ."Add a Joke!</P>");
> 
> 
> } // end main else statement
> ?>
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux