SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast grubindex.com's Avatar
    Join Date
    Apr 2001
    Location
    DC
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why doesn't this work?
    PHP Code:
    <html>

    <?

    print "<table><tr>";
    $db=mysql_connect("localhost","root"," ");
    mysql_select_db("grubinde",$db);
    $result=mysql_query("SELECT * FROM cat");
    $numrows mysql_numrows($result);
    $i 1;
    while(
    $row=mysql_fetch_array($result)) {
       
    extract($row);
       
    printf('<td><a href='crap.php?id=%s'>%s</a></td><a href='crap.php?id=%s'>%s</a>'$id$category, ((($i%2) == 0) && ($i != $numrows)) ? "</tr><tr>\n" "");
       
    $i++;
       }
    if((
    $numrows%== 1)) {
       print 
    "<td>&nbsp;</td></tr>";
       } 
    else {
       print 
    "</tr>";
       }
    print 
    "</table>";

    ?>

    </html>

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use mysql_num_rows

    not mysql_numrows
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Enthusiast grubindex.com's Avatar
    Join Date
    Apr 2001
    Location
    DC
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <html>

    <?

    print "<table><tr>";
    $db=mysql_connect("localhost","root","");
    mysql_select_db("grubinde",$db);
    $result=mysql_query("SELECT * FROM cat");
    $numrows mysql_num_rows($result);
    $i 1;
    while(
    $row=mysql_fetch_array($result)) {
       
    extract($row);
       
    printf('<td><a href='crap.php?id=%s'>%s</a></td><a href='crap.php?id=%s'>%s</a>'$id$category, ((($i%2) == 0) && ($i != $numrows)) ? "</tr><tr>\n" "");
       
    $i++;
       }
    if((
    $numrows%== 1)) {
       print 
    "<td>&nbsp;</td></tr>";
       } 
    else {
       print 
    "</tr>";
       }
    print 
    "</table>";

    ?>

    </html>
    still doesn't work
    Last edited by grubindex.com; Apr 30, 2001 at 19:47.

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The next obvious problem is that this
    printf('<td><a*href='crap.php? ...

    Should be
    printf("<td><a*href='crap.php? ...

    That is, you need a double quote at the begining of the print string not a single quote.

    May I make a couple of suggestions. First, try to keep the posts concerning one
    problem/topic in just the one thread. Otherwise ppl get confused (or I do anyway)
    and it gets messy if ppl reply to two different threads which are really trying to
    solve the same problem.

    Second, let us know more about what the problem is. "This doesn't work" is
    ambiguous. Did you receive a parse error? If so which line did it stop parsing
    at - and tell us which line that is in your code (there must be a syntax error on or
    above that line). Or, did you receive another error that occured during execution of
    your code (then tell us the details of the error message you receive). It helps try to
    pinpoint the problem.

    Third, try and keep the length of each line of code in the post reasonable (put a line
    break in the post where necessary). As you can see that this causes the page for the
    thread to become very wide in the browser. This wasn't a problem before vBulletin 2
    when each post was in a seperate table but is now

    Cheers.
    Last edited by freakysid; Apr 30, 2001 at 20:19.

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi freakysid,

    I really HAAAAAAAAATE the posts being too wide. What a blunder in the coding.
    By the way....what is wrong with this code?

    !!@#$@$.php.java.html.cpp
    PHP Code:
    <?php
    $pattern2
    ="^" $var "[\.,:]"
    $pattern3=$var "[\.,:]$";
    //$pattern4=$var . " ";
    echo "$pattern1|$pattern2|$pattern3"....";
    $new_paragraph=eregi_replace("$pattern1|$pattern2|$pattern3"$replace$paragraph);
    echo 
    $new_paragraph;
    public class 
    Dates 
    {
        public static 
    void main(String[] args
        {
            
    String[] dates = {"10/39/99""02/28/00"};
            
    StringBuffer[] fdates = new StringBuffer[10];
            
    String[][] sections = new String[10][3];
            
    int index 0;
            
    int[] count = new int[3];
        }
    }
    <!
    DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    >
    <
    html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <
    head>
    <
    title>Title</title>
    </
    head>
    <
    body>
    <
    table>
    <
    tr><td style="background-color:blue;">test</td><td style="background-color:yellow;">test</td></tr>
    <
    tr><td style="background-color:yellow;">test</td><td style="background-color:blue;">test</td></tr>
    </
    table>
    </
    body>
    </
    html>
    #include <iostream>
    using namespace std;

    int main()
    {
        
    int number 0u;
        
    cout << endl
             
    << "Enter an integer which you want the last bit switched: "
             
    << endl;
        
    cin >> number;
        
        
    int mask 1;
        
    int switched 0;
        
        
    switched number^mask;

        
    cout << "Your number with the last bit switched is: "
             
    << switched
             
    << endl;

        return 
    0;
    }


            for (
    int i=0i2i++)
            {
                for (
    int j=0j3i++)
                {
                
                    if (
    dates[i].indexOf('/') != -1)
                    {
                        
    sections[i][j] = dates[i].substring(indexdates[i].indexOf('/');
                        
    index dates[i].indexOf('/') + 1;
                        
    count[j]++;
                    }
                    else if (
    dates[i].indexOf('/') == -count[j] < 3)
                    {
                        
    System.out.println("Error in data.  Must be in this format: month/day/year");
                    }
                }
            }
            
            for (
    int i=0i2i++)
            {
                switch (
    sections[i][1])
                {
                    case 
    "01":
                    case 
    "1":
                        
    fdates[i] = "1st ";
                        break;
                    case 
    "02":
                    case 
    "2":
                        
    fdates[i] = "2nd ";
                        break;
                    case 
    "03":
                    case 
    "3":
                        
    fdates[i] = "3rd ";
                    case 
    "04":
                    case 
    "4":
                        
    fdates[i] = "4th ";


                    

                
                }
                
                
                
                switch (
    dates[i].substring(02)
                {
                    case 
    "01":
                        
    fdate[i] = "January" 

            
            
    }
            }
        }
    }
    ?>
    Last edited by 7stud; May 1, 2001 at 04:21.

  6. #6
    SitePoint Zealot DarkMonkey's Avatar
    Join Date
    Apr 2001
    Location
    uk
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dude, you can't just post your entire page and say 'what's wrong with this' you realise it takes quite a long time to go over that much coding, especially when your looking for a mistake, these people are like answerings tons of questions (give em a pat on the back, they rule) I'm sure they'd appreciate just a tiny bit of info on where the errror is, preferably which line and what type of error it is... Do you see?

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    He isn't really looking for help DarKMonkey, if yu read the code you will see it could never work, its a combo of several laguages together, php, java and I think C. But I am not to sure.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    7stud, I recommend you do the following:

    1) Open the script that contains that code in your favorite text editer - notepad will do.

    2) Select all the text.

    3) Press the Delete key.

    4) Save the file.

    That should solve the errors. As a bonus you will also find that the script executes much faster too.

  9. #9
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uhhh...The error is on line 76.
    Last edited by 7stud; May 1, 2001 at 12:26.

  10. #10
    SitePoint Zealot DarkMonkey's Avatar
    Join Date
    Apr 2001
    Location
    uk
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    These forums are too satirical for me.

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree, while we should have fun here, please keep the fake posts to a minimum.

    This is a php/mysql forum not a "Who can guess what made up script I have made with a combination of three or 4 languages"

    Let's try to focus on people asking question about php/mysql and us answering them.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  12. #12
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Grub, printing with single quotes is ok, but the HTML links should have double quotes:

    <a href='crap.php?id=%s'>

    should be like:

    <a href="crap.php?id=%s">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •