bobocheez
-
Posts
19 -
Joined
-
Last visited
Never
Posts posted by bobocheez
-
-
Oh, I didn't know that.
Thanks. Works like a charm.
-
That would normally work, but show turns out to be a command of some sort....so it gives out a syntax error
"Definition: The show tables SQL command is used to display all of the tables in a MySQL database and is phrased as: show tables;
Examples: This would list all of the tables in your database:
show tables;"
-By Angela Bradley, About.com Guide
So all is needed here is a change in column name.
Thanks for trying.
-
I tried without the second where and it did not work.
-
How would you format the following so that a row that has both $season and $show in it?
$query = "SELECT * FROM episodes WHERE season_no='$season' AND WHERE show='$show'";
-
Hi,
I have a piece of code where, $n is a sequential number from 1-20, and $display is from the database with numbers 1-20, but in a random order.
How can the following code be edited so that $display will equal $n?
$n = 0; while ($n < 20) { $n++; $query_d = "SELECT display FROM hits_d WHERE id='$n' ORDER BY display DESC"; $result_d = mysql_query($query_d) or die('Sorry, could not access the database'); $row_d=mysql_fetch_array($result_d, MYSQL_BOTH); $display = $row_d['display']; $ad = '$ad'."$n"; if ($display == $n) {$showad = $ad;} echo "n: $n display: $display showad: $showad<br/>"; }
-
I'll go with a new table, for now, since I don't know much about the other methods.
Thanks
-
So I have a random number script, but I'm not sure how to store the array values in once cell. Then query the db again and set individual variables for each number.
I would just make 5 cells for each number, but more numbers will be added so I don't want the table to get too big.
$max = 5; $min = 1; $amount = 5; $x = 0; $numbers[0] = 0; if (($max - $min) > $amount) die('$amount is larger number than $max - $min'); while (count($numbers) < $amount) { $ranvar = rand($min, $max); while(in_array($ranvar, $numbers)) { $ranvar = rand($min, $max); } $numbers[$x] = $ranvar; $x++; } echo "$numbers[0]<br/>"; echo "$numbers[1]<br/>"; echo "$numbers[2]<br/>"; echo "$numbers[3]<br/>"; echo "$numbers[4]<br/>"; $query_rand = "UPDATE hits WHERE id=2 SET order='something', "; mysql_query($query_rand);
-
How can the following code be altered so that the select options menu shows all of the subcat choices?
This is just a form that queries the database first
<?php include('config.php'); $query = "SELECT * FROM subcategories ORDER BY cat_id ASC"; $result = mysql_query($query) or die('Sorry, could not access the database'); mysql_num_rows($result); $subcat_id = $row['subcat_id']; $subcat = $row['subcategorie_name']; $cat_id = $row['cat_id']; ?> <form action="addchan2.php" method="post"> <select name="subcat"> <?php while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $cat = $row['cat']; echo "<option value=\"$subcat\">$subcat</option>"; } ?> </select> <input type="text" name="chan"> <input type="text" name="subcat_id" value="<?echo"$subcat_id";?>"> <input type="text" name="cat_id" value="<?echo"$cat_id";?>"> <input type="submit" value="Add"> </form>
-
You can just use the decimal equivalent:
25% = 0.25
I'm not sure how the math works in php but you might have to define a floating number.
And this should be posted in the math section.
-
Oh
So, $_SESSION['valid_user'] carries over to all other pages where the session start function is included, and for those pages, $username would have to be set = to the session variable each time.
Therefore
session_start(); $username = $_SESSION['valid_user']; echo "Hello $username";
Would display Hello bob
Is this correct?
-
Hi,
I've looked over a few login tutorials about sessions, but my small brain cannot connect the dots from the different programming styles people have.
What I understand so far, and please correct me if I am wrong,:
1. For logins: after a user logs in and the info is processed through the database session variables are set
//connect & retrieve database info for bob then: $_SESSION['valid_user'] = $username; $_SESSION['user_id'] = $user_id; //This means that the session array valid_user is = to bob
2. Each page that has the session_start(); function can use those session variables.
So if $username is echoed, then the valid_user array would carry over and display bob
Therefore if the index page contains the session start function at the beginning, and includes the login form/processor, then any $_REQUEST information should be able to use those stored variables.
Now, I figured I must be missing something because the scraps of code that I put together do not work, or I just suck at writing things correctly.
Any input (good/bad) is appreciated
Thanks
-
hey retard, this goes in the math section
ask an admin to move it
-
That does not work either. But I figured it out.
The variable value has to be in double quotes....
So anyone else reading this, both codes will work if you just change the quotes
" change to '
' change to "
-
Hi,
I have the following code and it will not check to see if a registering user inputs the same data as another user.
The snippet:
$query = 'SELECT username FROM users WHERE username = "$username"'; $result = mysql_query($query); $row = mysql_fetch_array($result, MYSQL_BOTH); if ($row['username'] == $username) {
However, it does insert the entry so it is connected to the database.
Thoughts?
-
nevermind
ignore this noob
it was the //TEST command
didnt realize that after update it should have been the table name instead of the database name
-
yes
But I don't see why its saying that there is no
tutorial.tutorial
Shouldnt it at least say
tutorial
-
Ok, so I have this code and I'm getting a wierd error
Table 'tutorial.tutorial' doesn't exist
The error if from the //TEST below
I'm using xampp if thats of any use
//OPENS CONNECTION TO MYSQL SERVER
$dbc = mysql_connect('localhost','root','');
if (!$dbc){
die('Not connected:' . mysql_error());
}
//SELECT DATABASE
$db_selected = mysql_select_db('tutorial', $dbc);
if (!$db_selected){
die ('cant connect:' . mysql_error());
}
//TEST
$query="UPDATE tutorial SET email='hope_this_works' WHERE username='bobo'";
$result=mysql_query($query);
if (!$result){
die ('update failed ->' . mysql_error());
}
-
1)
My social network site recently crashed and I had to upload everything again, but for some reason something is broken.
I had a referral script implemented into the SN script so that they work as one. However, I don't think that I have the original mod of the referral script that worked with the SN.
The script can be used as a standalone program but when it was integrated, the user only had to login once from the SN. From there on, the referral center could be used just as if it were part of the SN itself. I'm not sure what is wrong with it, and I'm not sure what needs to be done to reverse the effects of the crash, but I do know that it used a database, and the original data is still there, so I'm hoping that can help you somehow.
Quote?
2)
If the above project is completed then a page where the usernames are displayed along with how many referrals they have. would also be great.
Depending on how much project number 1 is worth, then I can provide more details on what should be on the page.
Thank You
P.S. I'll provide more indepth details when you want to do the project.
Email me at bobo_ra@hotmail.com and tell me that you are from here
check sql record with while?
in PHP Coding Help
Posted
Hey,
I'm trying to check if a username is unique, but for some reason none of the methods that I've looked up seem to work.
I'm aiming for the code to check if a username is unique, and if get the user to input the name again.
The error comes from the while line, but it comes up during the first check because the record is empty.
This is the error:
"Fatal error: Call to undefined function mysql_num_row()"